예제 #1
0
  @Override
  public void onPageSelected(int position) {
    this.enableOverlays();

    if (readingAdapter.getStory(position) != null) {
      addStoryToMarkAsRead(readingAdapter.getStory(position));
      checkStoryCount(position);
    }
  }
예제 #2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int currentItem = pager.getCurrentItem();
    Story story = readingAdapter.getStory(currentItem);
    UserDetails user = PrefsUtils.getUserDetails(this);

    if (item.getItemId() == android.R.id.home) {
      finish();
      return true;
    } else if (item.getItemId() == R.id.menu_reading_original) {
      if (story != null) {
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(story.permalink));
        startActivity(i);
      }
      return true;
    } else if (item.getItemId() == R.id.menu_reading_sharenewsblur) {
      if (story != null) {
        ReadingItemFragment currentFragment =
            (ReadingItemFragment) readingAdapter.instantiateItem(pager, currentItem);
        DialogFragment newFragment =
            ShareDialogFragment.newInstance(
                currentFragment, story, currentFragment.previouslySavedShareText);
        newFragment.show(getSupportFragmentManager(), "dialog");
      }
      return true;
    } else if (item.getItemId() == R.id.menu_shared) {
      Intent intent = new Intent(android.content.Intent.ACTION_SEND);
      intent.setType("text/plain");
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
      intent.putExtra(Intent.EXTRA_SUBJECT, story.title);
      final String shareString = getResources().getString(R.string.share);
      intent.putExtra(
          Intent.EXTRA_TEXT,
          String.format(shareString, new Object[] {story.title, story.permalink}));
      startActivity(Intent.createChooser(intent, "Share using"));
      return true;
    } else if (item.getItemId() == R.id.menu_textsize) {
      float currentValue =
          getSharedPreferences(PrefConstants.PREFERENCES, 0)
              .getFloat(PrefConstants.PREFERENCE_TEXT_SIZE, 0.5f);
      TextSizeDialogFragment textSize = TextSizeDialogFragment.newInstance(currentValue);
      textSize.show(getSupportFragmentManager(), TEXT_SIZE);
      return true;
    } else if (item.getItemId() == R.id.menu_reading_save) {
      FeedUtils.saveStory(story, Reading.this, apiManager);
      return true;
    } else if (item.getItemId() == R.id.menu_reading_markunread) {
      this.markStoryUnread(story);
      return true;
    } else {
      return super.onOptionsItemSelected(item);
    }
  }
예제 #3
0
 @Override
 public void updatePartialSync() {
   stories.requery();
   readingAdapter.notifyDataSetChanged();
   this.enableOverlays();
   checkStoryCount(pager.getCurrentItem());
 }
예제 #4
0
 @Override
 public void updateAfterSync() {
   setSupportProgressBarIndeterminateVisibility(false);
   stories.requery();
   readingAdapter.notifyDataSetChanged();
   this.enableOverlays();
   checkStoryCount(pager.getCurrentItem());
 }