@Override
  protected void doRefresh(final RefreshableFragment which, final boolean force) {

    mFragment =
        new CommentListingFragment(
            this,
            mUrls,
            null,
            force ? CacheRequest.DownloadType.FORCE : CacheRequest.DownloadType.IF_NECESSARY);

    mPane.removeAllViews();
    mPane.addView(mFragment.onCreateView());
    OptionsMenuUtility.fixActionBar(this, "More Comments"); // TODO string
  }
  public void onCreate(final Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    super.onCreate(savedInstanceState);

    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    OptionsMenuUtility.fixActionBar(this, getString(R.string.app_name));

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    final boolean solidblack =
        PrefsUtility.appearance_solidblack(this, sharedPreferences)
            && PrefsUtility.appearance_theme(this, sharedPreferences)
                == PrefsUtility.AppearanceTheme.NIGHT;

    // TODO load from savedInstanceState

    final View layout = getLayoutInflater().inflate(R.layout.main_single, null);
    if (solidblack) layout.setBackgroundColor(Color.BLACK);
    setContentView(layout);
    mPane = (FrameLayout) layout.findViewById(R.id.main_single_frame);

    RedditAccountManager.getInstance(this).addUpdateListener(this);

    if (getIntent() != null) {

      final Intent intent = getIntent();

      final ArrayList<String> urls = intent.getStringArrayListExtra("urls");

      for (final String url : urls) {
        final RedditURLParser.RedditURL redditURL =
            RedditURLParser.parseProbableCommentListing(Uri.parse(url));
        if (redditURL != null) {
          mUrls.add(redditURL);
        }
      }

      doRefresh(RefreshableFragment.COMMENTS, false);

    } else {
      throw new RuntimeException("Nothing to show! (should load from bundle)"); // TODO
    }
  }
示例#3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);
    super.onCreate(savedInstanceState);

    final RRThemeAttributes theme = new RRThemeAttributes(this);

    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    editor = sharedPreferences.edit();
    final boolean solidblack =
        PrefsUtility.appearance_solidblack(this, sharedPreferences)
            && PrefsUtility.appearance_theme(this, sharedPreferences)
                == PrefsUtility.AppearanceTheme.NIGHT;

    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    final String title;

    isModmail = getIntent() != null && getIntent().getBooleanExtra("modmail", false);
    onlyUnread = sharedPreferences.getBoolean("onlyUnread", false);

    if (!isModmail) {
      title = getString(R.string.mainmenu_inbox);
    } else {
      title = getString(R.string.mainmenu_modmail);
    }

    OptionsMenuUtility.fixActionBar(this, title);

    final LinearLayout outer = new LinearLayout(this);
    outer.setOrientation(android.widget.LinearLayout.VERTICAL);

    if (solidblack) {
      outer.setBackgroundColor(Color.BLACK);
    }

    loadingView = new LoadingView(this, getString(R.string.download_waiting), true, true);

    notifications = new LinearLayout(this);
    notifications.setOrientation(android.widget.LinearLayout.VERTICAL);
    notifications.addView(loadingView);

    final ListView lv = new ListView(this);

    lv.setSmoothScrollbarEnabled(false);
    lv.setVerticalFadingEdgeEnabled(false);

    lv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            final Object item = lv.getAdapter().getItem(position);

            if (item != null && item instanceof RedditRenderableInboxItem) {
              ((RedditRenderableInboxItem) item).handleInboxClick(InboxListingActivity.this);
            }
          }
        });

    adapter = new InboxListingAdapter(this, theme);
    lv.setAdapter(adapter);

    registerForContextMenu(lv);

    outer.addView(notifications);
    outer.addView(lv);

    makeFirstRequest(this);

    setContentView(outer);
  }