Search in sources :

Example 1 with TimberModule

use of io.palaima.debugdrawer.timber.TimberModule in project SeriesGuide by UweTrottmann.

the class BaseNavDrawerActivity method setupNavDrawer.

/**
     * Initializes the navigation drawer. Overriding activities should call this in their {@link
     * #onCreate(android.os.Bundle)} after {@link #setContentView(int)}.
     */
public void setupNavDrawer() {
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    actionBarToolbar = (Toolbar) drawerLayout.findViewById(R.id.sgToolbar);
    navigationView = (NavigationView) drawerLayout.findViewById(R.id.navigation);
    // setup nav drawer account header
    View headerView = navigationView.getHeaderView(0);
    ButterKnife.findById(headerView, R.id.containerDrawerAccountCloud).setOnClickListener(accountClickListener);
    ButterKnife.findById(headerView, R.id.containerDrawerAccountTrakt).setOnClickListener(accountClickListener);
    textViewHeaderUserCloud = ButterKnife.findById(headerView, R.id.textViewDrawerUserCloud);
    textViewHeaderUserTrakt = ButterKnife.findById(headerView, R.id.textViewDrawerUserTrakt);
    // setup nav drawer items
    navigationView.inflateMenu(R.menu.menu_drawer);
    navigationView.setItemIconTintList(ContextCompat.getColorStateList(this, Utils.resolveAttributeToResourceId(getTheme(), R.attr.sgColorNavDrawerIcon)));
    navigationView.setItemTextColor(ContextCompat.getColorStateList(this, Utils.resolveAttributeToResourceId(getTheme(), R.attr.sgColorNavDrawerText)));
    navigationView.setItemBackgroundResource(Utils.resolveAttributeToResourceId(getTheme(), R.attr.sgActivatedItemBackgroundDrawer));
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
            onNavItemClick(menuItem.getItemId());
            return false;
        }
    });
    if (BuildConfig.DEBUG) {
        // add debug drawer
        View debugLayout = getLayoutInflater().inflate(R.layout.debug_drawer, drawerLayout, true);
        DebugView debugView = ButterKnife.findById(debugLayout, R.id.debugView);
        ButtonAction buttonClearTraktRefreshToken = new ButtonAction("Clear trakt refresh token", new ButtonAction.Listener() {

            @Override
            public void onClick() {
                TraktOAuthSettings.storeRefreshData(getApplicationContext(), "", 3600);
            }
        });
        ButtonAction buttonInvalidateTraktAccessToken = new ButtonAction("Invalidate trakt access token", new ButtonAction.Listener() {

            @Override
            public void onClick() {
                TraktCredentials.get(getApplicationContext()).storeAccessToken("invalid-token");
            }
        });
        ButtonAction buttonInvalidateTraktRefreshToken = new ButtonAction("Invalidate trakt refresh token", new ButtonAction.Listener() {

            @Override
            public void onClick() {
                TraktOAuthSettings.storeRefreshData(getApplicationContext(), "invalid-token", 3600);
            }
        });
        debugView.modules(new ActionsModule(buttonClearTraktRefreshToken, buttonInvalidateTraktAccessToken, buttonInvalidateTraktRefreshToken), new TimberModule(), new DeviceModule(this));
    }
}
Also used : DeviceModule(io.palaima.debugdrawer.commons.DeviceModule) NavigationView(android.support.design.widget.NavigationView) ButtonAction(io.palaima.debugdrawer.actions.ButtonAction) MenuItem(android.view.MenuItem) DebugView(io.palaima.debugdrawer.view.DebugView) ActionsModule(io.palaima.debugdrawer.actions.ActionsModule) NavigationView(android.support.design.widget.NavigationView) DebugView(io.palaima.debugdrawer.view.DebugView) View(android.view.View) TextView(android.widget.TextView) TimberModule(io.palaima.debugdrawer.timber.TimberModule)

Aggregations

NavigationView (android.support.design.widget.NavigationView)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 TextView (android.widget.TextView)1 ActionsModule (io.palaima.debugdrawer.actions.ActionsModule)1 ButtonAction (io.palaima.debugdrawer.actions.ButtonAction)1 DeviceModule (io.palaima.debugdrawer.commons.DeviceModule)1 TimberModule (io.palaima.debugdrawer.timber.TimberModule)1 DebugView (io.palaima.debugdrawer.view.DebugView)1