Search in sources :

Example 1 with GistsPagerFragment

use of com.github.pockethub.android.ui.gist.GistsPagerFragment in project PocketHub by pockethub.

the class MainActivity method onNavigationItemSelected.

@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
    int itemId = menuItem.getItemId();
    if (itemId == R.id.navigation_home) {
        switchFragment(new HomePagerFragment(), org);
        getSupportActionBar().setTitle(getString(R.string.app_name));
        return true;
    } else if (itemId == R.id.navigation_gists) {
        switchFragment(new GistsPagerFragment(), null);
        getSupportActionBar().setTitle(menuItem.getTitle());
        return true;
    } else if (itemId == R.id.navigation_issue_dashboard) {
        switchFragment(new IssueDashboardPagerFragment(), null);
        getSupportActionBar().setTitle(menuItem.getTitle());
        return true;
    } else if (itemId == R.id.navigation_bookmarks) {
        switchFragment(new FilterListFragment(), null);
        getSupportActionBar().setTitle(menuItem.getTitle());
        return true;
    } else if (itemId == R.id.navigation_log_out) {
        AccountManager accountManager = getAccountManager();
        Account[] allGitHubAccounts = accountManager.getAccountsByType(getString(R.string.account_type));
        for (Account account : allGitHubAccounts) {
            accountManager.removeAccount(account, null, null);
        }
        Intent in = new Intent(this, LoginActivity.class);
        in.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(in);
        finish();
        return false;
    } else if (menuItemOrganizationMap.containsKey(menuItem)) {
        switchFragment(new HomePagerFragment(), menuItemOrganizationMap.get(menuItem));
        navigationView.getMenu().findItem(R.id.navigation_home).setChecked(true);
        return false;
    } else {
        throw new IllegalStateException("MenuItem " + menuItem + " not known");
    }
}
Also used : FilterListFragment(com.github.pockethub.android.ui.issue.FilterListFragment) Account(android.accounts.Account) IssueDashboardPagerFragment(com.github.pockethub.android.ui.issue.IssueDashboardPagerFragment) AccountManager(android.accounts.AccountManager) Intent(android.content.Intent) HomePagerFragment(com.github.pockethub.android.ui.user.HomePagerFragment) GistsPagerFragment(com.github.pockethub.android.ui.gist.GistsPagerFragment)

Aggregations

Account (android.accounts.Account)1 AccountManager (android.accounts.AccountManager)1 Intent (android.content.Intent)1 GistsPagerFragment (com.github.pockethub.android.ui.gist.GistsPagerFragment)1 FilterListFragment (com.github.pockethub.android.ui.issue.FilterListFragment)1 IssueDashboardPagerFragment (com.github.pockethub.android.ui.issue.IssueDashboardPagerFragment)1 HomePagerFragment (com.github.pockethub.android.ui.user.HomePagerFragment)1