Example #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    launchWelcomeActivity();

    setContentView(R.layout.activity_main);
    setTitle(R.string.title_conversation_list);
    ButterKnife.bind(this);

    setSlidingTabEnabled(mPrefs.getBoolean(SettingsFragment.SLIDING_TAB, false));
    mSlidingMenu.setListener(this);
    mSlidingMenu.setContent();
    mSlidingMenu.setMenu();
    mSlidingMenu.showContent(false);
    mSlidingMenu.showMenu(false);

    FragmentManager fm = getFragmentManager();

    mConversationList = (ConversationListFragment) fm.findFragmentById(R.id.menu_frame);
    if (mConversationList == null) {
      mConversationList = new ConversationListFragment();
    }
    mConversationList = new ConversationListFragment();
    FragmentTransaction menuTransaction = fm.beginTransaction();
    menuTransaction.replace(R.id.menu_frame, mConversationList);
    menuTransaction.commit();

    mContent = (ContentFragment) fm.findFragmentById(R.id.content_frame);
    if (mContent == null) {
      mContent = ComposeFragment.getInstance(null);
    }
    FragmentTransaction contentTransaction = fm.beginTransaction();
    contentTransaction.replace(R.id.content_frame, (Fragment) mContent);
    contentTransaction.commit();

    onNewIntent(getIntent());
    showDialogIfNeeded(savedInstanceState);

    LiveViewManager.registerView(
        QKPreference.BACKGROUND,
        this,
        key -> {
          // Update the background color. This code is important during the welcome screen setup,
          // when the activity
          // in the ThemeManager isn't the MainActivity
          mRoot.setBackgroundColor(ThemeManager.getBackgroundColor());
        });

    // Adds a small/non intrusive snackbar that asks the user to rate the app
    SnackEngage.from(this)
        .withSnack(new QKRateSnack().withDuration(BaseSnack.DURATION_LONG))
        .build()
        .engageWhenAppropriate();
  }