コード例 #1
0
ファイル: ActivityMain.java プロジェクト: JCulver/NotePad-2
  private void handleSyncRequest() {
    boolean syncing = false;
    // GTasks
    if (SyncHelper.isGTasksConfigured(ActivityMain.this)) {
      syncing = true;
      SyncHelper.requestSyncIf(ActivityMain.this, SyncHelper.MANUAL);
    }

    // Others
    if (OrgSyncService.areAnyEnabled(this)) {
      syncing = true;
      OrgSyncService.start(this);
    }

    if (syncing) {
      // In case of connectivity problems, stop the progress bar
      new AsyncTask<Void, Void, Void>() {

        @Override
        protected Void doInBackground(Void... params) {
          try {
            Thread.sleep(30000);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
          return null;
        }

        @Override
        protected void onPostExecute(Void result) {
          // Notify PullToRefreshAttacher that the refresh has finished
          pullToRefreshAttacher.setRefreshComplete();
        }
      }.execute();
    }
  }