Пример #1
0
    protected void onPostExecute(HNFeed result) {
      if (progress != null && progress.isShowing()) progress.dismiss();

      if (result != null
          && result.getUserAcquiredFor() != null
          && result.getUserAcquiredFor().equals(Settings.getUserName(App.getInstance())))
        showFeed(result);
    }
Пример #2
0
    public LongPressMenuListAdapter(HNPost post, int position) {
      pos = position;
      mPost = post;
      mIsLoggedIn = Settings.isUserLoggedIn(MainActivity.this);
      mUpVotingEnabled =
          !mIsLoggedIn
              || (mPost.getUpvoteURL(Settings.getUserName(MainActivity.this)) != null
                  && !mUpvotedPosts.contains(mPost));

      mItems = new ArrayList<CharSequence>();
      if (mUpVotingEnabled) mItems.add(getString(R.string.upvote));
      else mItems.add(getString(R.string.already_upvoted));
      mItems.addAll(
          Arrays.asList(
              getString(R.string.pref_htmlprovider_original_url),
              getString(R.string.pref_htmlprovider_viewtext),
              getString(R.string.pref_htmlprovider_google),
              getString(R.string.pref_htmlprovider_instapaper),
              getString(R.string.external_browser)));
    }
Пример #3
0
  @Override
  protected void onResume() {
    super.onResume();

    boolean registeredUserChanged =
        mFeed.getUserAcquiredFor() != null
            && (!mFeed.getUserAcquiredFor().equals(Settings.getUserName(this)));

    // We want to reload the feed if a new user logged in
    if (HNCredentials.isInvalidated() || registeredUserChanged) {
      showFeed(new HNFeed(new ArrayList<HNPost>(), null, ""));
      startFeedLoading();
    }

    // refresh if font size changed
    if (refreshFontSizes()) mPostsListAdapter.notifyDataSetChanged();

    // Ramesh kumar coding part for change background color using radio button
    if (refreshBackgroundColor()) mPostsListAdapter.notifyDataSetChanged();

    // ------------- kevin's codes. refresh the setup when changing the setting -----------------
    if (refreshHTMLContent()) {

      if (mCurrentHTMLContent.equals("display")) {

        new Thread(getURLContent_Thread).start();
      } else {
        List<HNPost> mPosts = mFeed.getPosts();
        for (int i = 0; i < mPosts.size(); i++) {

          mPosts.get(i).setContent("");
        }
        showFeed(mFeed);
      }
    }
    // restore vertical scrolling position if applicable
    if (mListState != null) mPostsList.onRestoreInstanceState(mListState);

    mListState = null;
  }
Пример #4
0
 @Override
 public void onClick(DialogInterface dialog, int item) {
   switch (item) {
     case 0:
       if (!mIsLoggedIn)
         Toast.makeText(MainActivity.this, R.string.please_log_in, Toast.LENGTH_LONG).show();
       else if (mUpVotingEnabled)
         vote(mPost.getUpvoteURL(Settings.getUserName(MainActivity.this)), mPost);
       break;
     case 1:
     case 2:
     case 3:
     case 4:
       openPostInApp(pos, mPost, getItem(item).toString(), MainActivity.this);
       break;
     case 5:
       openURLInBrowser(getArticleViewURL(mPost), MainActivity.this);
       break;
     default:
       break;
   }
 }