Beispiel #1
0
  @Override
  protected void onCreate(Bundle savedInstanceBundle) {
    requestWindowFeature(Window.FEATURE_PROGRESS);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceBundle);

    setContentView(R.layout.activity_reading);
    this.overlayLeft = (Button) findViewById(R.id.reading_overlay_left);
    this.overlayRight = (Button) findViewById(R.id.reading_overlay_right);
    this.overlayCount = (TextView) findViewById(R.id.reading_overlay_count);

    fragmentManager = getSupportFragmentManager();

    storiesToMarkAsRead = new HashSet<Story>();
    storiesAlreadySeen = new HashSet<Story>();

    passedPosition = getIntent().getIntExtra(EXTRA_POSITION, 0);
    currentState = getIntent().getIntExtra(ItemsList.EXTRA_STATE, 0);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    contentResolver = getContentResolver();

    this.apiManager = new APIManager(this);

    // this value is expensive to compute but doesn't change during a single runtime
    this.overlayRangeTopPx = (float) UIUtils.convertDPsToPixels(this, OVERLAY_RANGE_TOP_DP);
    this.overlayRangeBotPx = (float) UIUtils.convertDPsToPixels(this, OVERLAY_RANGE_BOT_DP);

    // the unread count overlay defaults to neutral colour.  set it to positive if we are in focus
    // mode
    if (this.currentState == AppConstants.STATE_BEST) {
      ViewUtils.setViewBackground(this.overlayCount, R.drawable.positive_count_rect);
    }
  }
Beispiel #2
0
  /**
   * Sets up the local pager widget. Should be called from onCreate() after both the cursor and
   * adapter are created.
   */
  protected void setupPager() {
    syncFragment = (SyncUpdateFragment) fragmentManager.findFragmentByTag(SyncUpdateFragment.TAG);
    if (syncFragment == null) {
      syncFragment = new SyncUpdateFragment();
      fragmentManager.beginTransaction().add(syncFragment, SyncUpdateFragment.TAG).commit();
    }

    pager = (ViewPager) findViewById(R.id.reading_pager);
    pager.setPageMargin(UIUtils.convertDPsToPixels(getApplicationContext(), 1));
    pager.setPageMarginDrawable(R.drawable.divider_light);
    pager.setOnPageChangeListener(this);

    pager.setAdapter(readingAdapter);
    pager.setCurrentItem(passedPosition);
    this.enableOverlays();
  }