コード例 #1
0
  public static void switchAccessToken(final AccessToken accessToken) {
    AccessTokenManager.setAccessToken(accessToken);
    if (BasicSettings.getStreamingMode()) {
      MessageUtil.showToast(R.string.toast_destroy_streaming);
      sUserStreamAdapter.stop();
      new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
          sTwitterStream.cleanUp();
          sTwitterStream.shutdown();
          return null;
        }

        @Override
        protected void onPostExecute(Void status) {
          sTwitterStream.setOAuthAccessToken(accessToken);
          new Handler()
              .postDelayed(
                  new Runnable() {
                    @Override
                    public void run() {
                      MessageUtil.showToast(R.string.toast_create_streaming);
                      sUserStreamAdapter.start();
                      sTwitterStream.user();
                    }
                  },
                  5000);
        }
      }.execute();
    }
    EventBus.getDefault().post(new AccountChangeEvent());
  }
コード例 #2
0
 public static void startStreaming() {
   if (sTwitterStream != null) {
     if (!sTwitterStreamConnected) {
       sUserStreamAdapter.start();
       sTwitterStream.setOAuthAccessToken(AccessTokenManager.getAccessToken());
       sTwitterStream.user();
     }
     return;
   }
   sTwitterStream = getTwitterStream();
   sUserStreamAdapter = new MyUserStreamAdapter();
   sTwitterStream.addListener(sUserStreamAdapter);
   sTwitterStream.addConnectionLifeCycleListener(new MyConnectionLifeCycleListener());
   sTwitterStream.user();
   BasicSettings.resetNotification();
 }
コード例 #3
0
  public static void stopStreaming() {
    if (sTwitterStream == null) {
      return;
    }
    BasicSettings.setStreamingMode(false);
    sUserStreamAdapter.stop();
    new AsyncTask<Void, Void, Void>() {
      @Override
      protected Void doInBackground(Void... params) {
        sTwitterStream.cleanUp();
        sTwitterStream.shutdown();
        return null;
      }

      @Override
      protected void onPostExecute(Void status) {}
    }.execute();
  }
コード例 #4
0
 public static void resumeStreaming() {
   if (sUserStreamAdapter != null) {
     sUserStreamAdapter.resume();
   }
 }
コード例 #5
0
 public static void pauseStreaming() {
   if (sUserStreamAdapter != null) {
     sUserStreamAdapter.pause();
   }
 }