Ejemplo n.º 1
0
  @Override
  public void onResume() {
    if (shouldRestart) {
      restartAndRefresh();
    }
    super.onResume();
    // activate monitor
    if (syncStatusReceiver != null) {
      syncStatusReceiver.startMonitoring(this);
    }

    // Sync if appropriate
    if (SyncHelper.enoughTimeSinceLastSync(this)) {
      SyncHelper.requestSyncIf(this, SyncHelper.ONAPPSTART);
      OrgSyncService.start(this);
    }

    // Check any upgrades
    checkPremium();
  }
Ejemplo n.º 2
0
  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();
    }
  }