Search in sources :

Example 1 with HomePagerFragment

use of com.github.pockethub.android.ui.user.HomePagerFragment in project PocketHub by pockethub.

the class MainActivity method onLoadFinished.

@Override
public void onLoadFinished(Loader<List<User>> listLoader, final List<User> orgs) {
    if (orgs.isEmpty()) {
        return;
    }
    org = orgs.get(0);
    this.orgs = orgs;
    setUpNavigationView();
    Window window = getWindow();
    if (window == null) {
        return;
    }
    View view = window.getDecorView();
    if (view == null) {
        return;
    }
    view.post(new Runnable() {

        @Override
        public void run() {
            MainActivity.this.switchFragment(new HomePagerFragment(), org);
            if (!userLearnedDrawer) {
                drawerLayout.openDrawer(GravityCompat.START);
            }
        }
    });
}
Also used : Window(android.view.Window) HomePagerFragment(com.github.pockethub.android.ui.user.HomePagerFragment) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 2 with HomePagerFragment

use of com.github.pockethub.android.ui.user.HomePagerFragment 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

HomePagerFragment (com.github.pockethub.android.ui.user.HomePagerFragment)2 Account (android.accounts.Account)1 AccountManager (android.accounts.AccountManager)1 Intent (android.content.Intent)1 NavigationView (android.support.design.widget.NavigationView)1 SearchView (android.support.v7.widget.SearchView)1 View (android.view.View)1 Window (android.view.Window)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)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