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()); }
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(); }
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(); }
public static void resumeStreaming() { if (sUserStreamAdapter != null) { sUserStreamAdapter.resume(); } }
public static void pauseStreaming() { if (sUserStreamAdapter != null) { sUserStreamAdapter.pause(); } }