Esempio n. 1
1
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setupDrawer();
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
    MetricsManager.register(getApplication());

    mContext = this;

    if (mPreferences.useAutoSync()) {
      SyncScheduler.schedule(this, mPreferences.isRequiresCharging());
    }

    Intent i = getIntent();
    if (i != null) {
      mOpenChangelog = i.getBooleanExtra(EXTRA_FROM_NOTIFICATION, false);
      i.removeExtra(EXTRA_FROM_NOTIFICATION);
    }

    int filterId = Filters.TAB_ALL;
    if (savedInstanceState != null && !mOpenChangelog) {
      filterId = savedInstanceState.getInt("tab_id", Filters.TAB_ALL);
      AppLog.d("Restore tab: " + filterId);
    }

    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(mViewPager);
    mViewPager.setCurrentItem(filterId);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    mRefreshAnim = new MenuItemAnimation(this, R.anim.rotate);
  }
Esempio n. 2
0
  public boolean requestRefresh() {
    AppLog.d("Refresh pressed");
    if (!isAuthenticated()) {
      showAccountsDialogWithCheck();
      return false;
    }

    Toast.makeText(this, "Refresh scheduled", Toast.LENGTH_SHORT).show();
    ManualSyncService.startActionSync(this);
    return false;
  }
Esempio n. 3
0
  @Override
  protected Result doInBackgroundConnected(Boolean... params) {
    SyncConnectedWorker worker = new SyncConnectedWorker(mContext, getGoogleApiClient());
    try {
      worker.doSyncInBackground();
    } catch (Exception e) {
      AppLog.e(e);
      return new Result(false, e);
    }

    return new Result(true, null);
  }
Esempio n. 4
0
  @Override
  protected void onResume() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(SyncAdapter.SYNC_PROGRESS);
    filter.addAction(SyncAdapter.SYNC_STOP);
    filter.addAction(GcmTaskService.SERVICE_ACTION_EXECUTE_TASK);
    registerReceiver(mSyncFinishedReceiver, filter);
    mSyncFinishedReceiverRegistered = true;
    super.onResume();

    AppLog.d("Mark updates as viewed.");
    mPreferences.markViewed(true);

    notifySyncStop();
    CrashManager.register(this, Util.getAppIdentifier(this), App.provide(this).crashListener());
  }