com.mikepenz.materialdrawer.model.PrimaryDrawerItem Java Examples

The following examples show how to use com.mikepenz.materialdrawer.model.PrimaryDrawerItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Navbar.java    From SteamGifts with MIT License 6 votes vote down vote up
/**
 * Add all discussion-related items.
 */
private void addDiscussionItems(SteamGiftsUserData account, String mode) {
    if ("full".equals(mode)) {
        // Full mode: Show all different categories in the navbar
        drawer.addItem(new SectionDrawerItem().withName(R.string.navigation_discussions).withDivider(true));
        for (DiscussionListFragment.Type type : DiscussionListFragment.Type.values()) {
            // We only want to have 'Created Discussions' if we're actually logged in.
            if (type == DiscussionListFragment.Type.CREATED && !account.isLoggedIn())
                continue;

            drawer.addItem(new PrimaryDrawerItem().withName(type.getNavbarResource()).withIdentifier(type.getNavbarResource()).withIcon(type.getIcon()));
        }
    } else if ("compact".equals(mode)) {
        // Compact mode: we only add a single item called 'Discussions' that links to all discussions,
        // and there's a menu item in the 'discussions' list to switch between different categories.
        drawer.addItem(new PrimaryDrawerItem().withName(R.string.navigation_discussions).withIdentifier(DiscussionListFragment.Type.ALL.getNavbarResource()).withIcon(DiscussionListFragment.Type.ALL.getIcon()));
    }
}
 
Example #2
Source File: Navbar.java    From SteamGifts with MIT License 6 votes vote down vote up
/**
 * Add all Navbar icons related to giveaways.
 */
private void addGiveawayItems(SteamGiftsUserData account) {
    // All different giveaway views
    drawer.addItems(
            new SectionDrawerItem().withName(R.string.navigation_giveaways).withDivider(!account.isLoggedIn()),
            new PrimaryDrawerItem().withName(R.string.navigation_giveaways_all).withIdentifier(R.string.navigation_giveaways_all).withIcon(FontAwesome.Icon.faw_gift));

    // If we're logged in, we can look at group and wishlist giveaways.
    if (account.isLoggedIn()) {
        drawer.addItems(
                new PrimaryDrawerItem().withName(R.string.navigation_giveaways_group).withIdentifier(R.string.navigation_giveaways_group).withIcon(FontAwesome.Icon.faw_users),
                new PrimaryDrawerItem().withName(R.string.navigation_giveaways_wishlist).withIdentifier(R.string.navigation_giveaways_wishlist).withIcon(FontAwesome.Icon.faw_heart),
                new PrimaryDrawerItem().withName(R.string.navigation_giveaways_recommended).withIdentifier(R.string.navigation_giveaways_recommended).withIcon(FontAwesome.Icon.faw_thumbs_up));
    }
    drawer.addItems(new PrimaryDrawerItem().withName(R.string.navigation_giveaways_new).withIdentifier(R.string.navigation_giveaways_new).withIcon(FontAwesome.Icon.faw_refresh));
}
 
Example #3
Source File: MainActivity.java    From minx with MIT License 5 votes vote down vote up
private void setUpDrawer() {

        AccountHeader accountHeader = new AccountHeaderBuilder()
                .withActivity(MainActivity.this)
                .withHeaderBackground(R.drawable.minx_small)
                .withHeaderBackgroundScaleType(ImageView.ScaleType.FIT_CENTER)
                .withHeightDp(200)
                .build();

        result = new DrawerBuilder()
                .withHeaderDivider(true)
                .withActivity(this)
                .withAccountHeader(accountHeader)
                .withToolbar(toolbar)
                .addDrawerItems(
                        new PrimaryDrawerItem().withName(R.string.drawer_item_home),
                        new DividerDrawerItem(),
                        new SecondaryDrawerItem().withName(R.string.drawer_item_saved),
                        new SecondaryDrawerItem().withName(R.string.drawer_item_share),
                        new SecondaryDrawerItem().withName(R.string.drawer_item_settings),
                        new SecondaryDrawerItem().withName(R.string.drawer_item_about)
                )
                .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) {
                        // do something with the clicked item :D
                        Toast.makeText(MainActivity.this, "You clicked on item : " + position, Toast.LENGTH_SHORT).show();
                        loadFragment(position);
                        return false;
                    }
                })
                .build();
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);

    }
 
Example #4
Source File: MainActivity.java    From Local-GSM-Backend with Apache License 2.0 5 votes vote down vote up
private void updateTitle() {
    IDrawerItem item = drawer == null ? null : drawer.getDrawerItem(drawer.getCurrentSelection());

    if (item != null && item instanceof PrimaryDrawerItem) {
        toolbar.setSubtitle(((PrimaryDrawerItem) item).getName().getText(this));
    } else {
        toolbar.setSubtitle(null);
    }
}
 
Example #5
Source File: MainActivity.java    From wifi_backend with GNU General Public License v3.0 5 votes vote down vote up
private void updateTitle() {
    IDrawerItem item = drawer == null ? null : drawer.getDrawerItem(drawer.getCurrentSelection());

    if (item != null && item instanceof PrimaryDrawerItem) {
        toolbar.setSubtitle(((PrimaryDrawerItem) item).getName().getText(this));
    } else {
        toolbar.setSubtitle(null);
    }
}
 
Example #6
Source File: MainViewModel.java    From hacker-news-android with Apache License 2.0 5 votes vote down vote up
List<IDrawerItem> getDrawerItems() {
    if (mDrawerItems != null && !mDrawerItems.isEmpty()) {
        return mDrawerItems;
    }

    List<PrimaryDrawerItem> primaryDrawerItems = new ArrayList<>();
    List<SecondaryDrawerItem> secondaryDrawerItems = new ArrayList<>();
    mDrawerItems = new ArrayList<>();

    primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_TOP).withName(R.string.title_section_top).withIcon(R.drawable.ic_action_whatshot));
    primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_BEST).withName(R.string.title_section_best).withIcon(R.drawable.ic_action_grade));
    primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_NEWEST).withName(R.string.title_section_newest).withIcon(R.drawable.ic_action_note_add));
    primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_SHOW_HN).withName(R.string.title_section_show).withIcon(R.drawable.ic_action_visibility));
    primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_SHOW_HN_NEW).withName(R.string.title_section_show_new).withIcon(R.drawable.ic_action_visibility));
    primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_ASK).withName(R.string.title_section_ask).withIcon(R.drawable.ic_action_live_help));
    primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_SAVED).withName(R.string.title_section_saved).withIcon(R.drawable.ic_action_archive));
    mDrawerItems.addAll(primaryDrawerItems);

    mDrawerItems.add(new DividerDrawerItem());

    secondaryDrawerItems.add(new SecondaryDrawerItem().withIdentifier(SECTION_SETTINGS).withName(R.string.title_section_settings).withCheckable(false));
    secondaryDrawerItems.add(new SecondaryDrawerItem().withIdentifier(SECTION_ABOUT).withName(R.string.title_section_about).withCheckable(false));

    mDrawerItems.addAll(secondaryDrawerItems);

    return mDrawerItems;
}
 
Example #7
Source File: DrawerHelper.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
public static IDrawerItem getPrimaryMenuItem(DrawerItem drawerItem) {
    PrimaryDrawerItem primaryDrawerItem = new PrimaryDrawerItem()
            .withName(drawerItem.name)
            .withIdentifier(drawerItem.id)
            .withIcon(drawerItem.icon);

    if (drawerItem.withBadge) {
        primaryDrawerItem
                .withBadgeStyle(new BadgeStyle()
                        .withTextColor(Color.WHITE)
                        .withColorRes(R.color.grey));
    }
    return primaryDrawerItem;
}
 
Example #8
Source File: MiniDrawer.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * generates a MiniDrawerItem from a IDrawerItem
 *
 * @param drawerItem
 * @return
 */
public IDrawerItem generateMiniDrawerItem(IDrawerItem drawerItem) {
    if (drawerItem instanceof PrimaryDrawerItem) {
        return new MiniDrawerItem((PrimaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground);
    } else if (drawerItem instanceof SecondaryDrawerItem && mIncludeSecondaryDrawerItems) {
        return new MiniDrawerItem((SecondaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground);
    } else if (drawerItem instanceof ProfileDrawerItem) {
        MiniProfileDrawerItem mpdi = new MiniProfileDrawerItem((ProfileDrawerItem) drawerItem);
        mpdi.withEnabled(mEnableProfileClick);
        return mpdi;
    }
    return null;
}
 
Example #9
Source File: DrawerUtils.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * helper method to fill the sticky footer with it's elements
 *
 * @param drawer
 * @param container
 * @param onClickListener
 */
public static void fillStickyDrawerItemFooter(DrawerBuilder drawer, ViewGroup container, View.OnClickListener onClickListener) {
    //add all drawer items
    for (IDrawerItem drawerItem : drawer.mStickyDrawerItems) {
        //get the selected_color
        int selected_color = UIUtils.getThemeColorFromAttrOrRes(container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected);
        if (drawerItem instanceof PrimaryDrawerItem) {
            selected_color = ColorHolder.color(((PrimaryDrawerItem) drawerItem).getSelectedColor(), container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected);
        } else if (drawerItem instanceof SecondaryDrawerItem) {
            selected_color = ColorHolder.color(((SecondaryDrawerItem) drawerItem).getSelectedColor(), container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected);
        }

        View view = drawerItem.generateView(container.getContext(), container);
        view.setTag(drawerItem);

        if (drawerItem.isEnabled()) {
            UIUtils.setBackground(view, DrawerUIUtils.getSelectableBackground(container.getContext(), selected_color));
            view.setOnClickListener(onClickListener);
        }

        container.addView(view);

        //for android API 17 --> Padding not applied via xml
        DrawerUIUtils.setDrawerVerticalPadding(view);
    }
    //and really. don't ask about this. it won't set the padding if i don't set the padding for the container
    container.setPadding(0, 0, 0, 0);
}
 
Example #10
Source File: HomeActivity.java    From wmn-safety with MIT License 5 votes vote down vote up
private void createNavDrawer(Toolbar toolbar) {
    result = new DrawerBuilder()
            .withActivity(this)
            .withAccountHeader(headerResult)
            .withToolbar(toolbar)
            .withSelectedItem(-1)
            .withHasStableIds(true)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName("Trusted Contacts")
                            .withIdentifier(1).withIcon(R.drawable.ic_contact_phone_black_24dp),
                    new PrimaryDrawerItem().withName("Explore")
                            .withIdentifier(2).withIcon(R.drawable.ic_explore_black_24dp),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName("Settings")
                            .withIdentifier(3).withIcon(R.drawable.ic_settings_black_24dp),
                    new PrimaryDrawerItem().withName("Help & Feedback")
                            .withIcon(R.drawable.ic_feedback_black_24dp)
                            .withIdentifier(5),
                    new PrimaryDrawerItem().withName("About")
                            .withIcon(R.drawable.ic_info_outline_black_24dp)
                            .withIdentifier(6),
                    new PrimaryDrawerItem().withName("Rate Us")
                            .withIcon(R.drawable.ic_star_black_24dp)
                            .withIdentifier(7)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    // add click listeners for nav drawer items
                    switch ((int) drawerItem.getIdentifier()) {
                        case 1:
                            startActivity(new Intent(mContext, TrustedContactsActivity.class));
                            break;
                        case 2:
                            startActivity(new Intent(mContext,ExploreActivity.class));
                            break;
                        case 3:
                            startActivity(new Intent(mContext, SettingsActivity.class));
                            break;
                        case 6:
                            startActivity(new Intent(mContext, AboutActivity.class));
                            break;
                        case 7:
                            Toast.makeText(mContext,"Coming soon on Play Store",Toast.LENGTH_SHORT).show();
                    }
                    return false;
                }
            })
            .build();
}
 
Example #11
Source File: MainActivity.java    From ShoppingList with Apache License 2.0 5 votes vote down vote up
private void buildDrawer() {
    result = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withHeader(R.layout.drawer_header)
            .withTranslucentStatusBar(false)
            .withActionBarDrawerToggle(true)
            .withActionBarDrawerToggleAnimated(false)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.nav_item_home).withTag(CONSTS.TAG_LIST).withIcon(R.drawable.ic_toc_black_),
                    new PrimaryDrawerItem().withName(R.string.nav_item_cached).withTag(CONSTS.TAG_CACHED).withIcon(R.drawable.ic_toc_black_),
                    new PrimaryDrawerItem().withName(R.string.nav_item_favorites).withTag(CONSTS.TAG_FAVORITES).withIcon(R.drawable.ic_star_rate_black)
            )
            .addStickyDrawerItems(
                    new SecondaryDrawerItem().withName(R.string.nav_item_about).withTag(CONSTS.TAG_ABOUT).withIcon(R.drawable.ic_action_about),
                    new SecondaryDrawerItem().withName(R.string.nav_item_settings).withTag(CONSTS.TAG_SETTINGS).withIcon(R.drawable.ic_action_settings)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    fragmentSelector(Integer.parseInt(drawerItem.getTag().toString()));
                    return false;
                }
            })
            .withSelectedItem(0)
            .build();
}
 
Example #12
Source File: MainActivity.java    From Droid2JoyStick with Apache License 2.0 5 votes vote down vote up
private void setupNavigationDrawer() {
    ProfileDrawerItem section = new ProfileDrawerItem()
            .withSetSelected(false)
            .withSetSelected(false)
            .withEnabled(false);
    PrimaryDrawerItem joyType0DrawerItem = new PrimaryDrawerItem().withName("Basic Gamepad").withTag(KEY_BASIC_GAMEPAD_1).withLevel(2);
    PrimaryDrawerItem joyType1DrawerItem = new PrimaryDrawerItem().withName("Assault Horizon").withTag(KEY_ASSAULT_HORIZON).withLevel(2);
    PrimaryDrawerItem joyType2DrawerItem = new PrimaryDrawerItem().withName("Awesomenauts").withTag(KEY_AWESOMENAUTS).withLevel(2);
    PrimaryDrawerItem joyType3DrawerItem = new PrimaryDrawerItem().withName("BombSquad").withTag(KEY_BOMBSQUAD).withLevel(2);
    PrimaryDrawerItem joyType4DrawerItem = new PrimaryDrawerItem().withName("Final Fantasy XIII").withTag(KEY_FINAL_FANTASY_XIII).withLevel(2);
    SectionDrawerItem sectionDrawerItem = new SectionDrawerItem().withName("Joystick Type").withTextColorRes(R.color.colorAccent);
    PrimaryDrawerItem deviceDrawerItem = new PrimaryDrawerItem().withName("Device Connection").withTag(KEY_DEVICE_CONNECTION).withIcon(GoogleMaterial.Icon.gmd_devices);
    PrimaryDrawerItem settingsDrawerItem = new PrimaryDrawerItem().withName("Settings").withTag("settings").withIcon(GoogleMaterial.Icon.gmd_settings);

    ndMenu = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(tbMain)
            .withCloseOnClick(true)
            .withFireOnInitialOnClick(true)
            .withSelectedItemByPosition(6)
            .withDelayDrawerClickEvent(300)
            .withDisplayBelowStatusBar(true)
            .withTranslucentStatusBar(false)
            .withOnDrawerItemClickListener(this)
            .addDrawerItems(section, deviceDrawerItem, settingsDrawerItem, sectionDrawerItem, joyType0DrawerItem, joyType1DrawerItem, joyType2DrawerItem, joyType3DrawerItem, joyType4DrawerItem)
            .build();
}
 
Example #13
Source File: DrawerManager.java    From FragmentNavigationPatternDemo with Apache License 2.0 5 votes vote down vote up
private void decorate(ArrayList<IDrawerItem> items) {
    for (IDrawerItem item : items) {
        if (item instanceof PrimaryDrawerItem) {
            ((PrimaryDrawerItem) item).withSelectedColorRes(R.color.menu_item_selected);
        }
    }
}
 
Example #14
Source File: DrawerManager.java    From FragmentNavigationPatternDemo with Apache License 2.0 5 votes vote down vote up
/**
 * @return the list of items
 */
public ArrayList<IDrawerItem> getDrawerItems() {

    // The menu items in the drawer
    ArrayList<IDrawerItem> items = new ArrayList<>();

    // Dashboard
    //if you want to update the items at a later time it is recommended to keep it in a variable
    //@formatter:off
    items.add(new PrimaryDrawerItem()
                    .withName(MenuItem.MENU_ITEM1.mLabel).withIcon(Octicons.Icon.oct_dashboard)
                    .withIconColorRes(R.color.menu_item_1).withSelectedIconColorRes(R.color.menu_item_1));

    items.add(new PrimaryDrawerItem()
                    .withName(MenuItem.MENU_ITEM2.mLabel).withIcon(Octicons.Icon.oct_graph)
                    .withIconColorRes(R.color.menu_item_2).withSelectedIconColorRes(R.color.menu_item_2));

    items.add(new PrimaryDrawerItem()
                    .withName(MenuItem.MENU_ITEM3.mLabel).withIcon(FontAwesome.Icon.faw_sign_out)
                    .withIconColorRes(R.color.menu_item_3).withSelectedIconColorRes(R.color.menu_item_3));

    items.add(new PrimaryDrawerItem()
                    .withName(MenuItem.MENU_ITEM4.mLabel).withIcon(FontAwesome.Icon.faw_sign_out)
                    .withIconColorRes(R.color.menu_item_4).withSelectedIconColorRes(R.color.menu_item_4));

    items.add(new PrimaryDrawerItem()
                    .withName(MenuItem.MENU_ITEM5.mLabel).withIcon(FontAwesome.Icon.faw_sign_out)
                    .withIconColorRes(R.color.menu_item_5).withSelectedIconColorRes(R.color.menu_item_5));


    //@formatter:on
    decorate(items);

    return items;
}
 
Example #15
Source File: MainViewModel.java    From demo4Fish with MIT License 5 votes vote down vote up
private void setDrawer() {
    Application application = DemoApplication.getApplication();

    PrimaryDrawerItem item = new PrimaryDrawerItem()
            .withIcon(R.drawable.ic_menu_camera)
            .withIdentifier(1)
            .withName("Test 1")
            .withTextColorRes(R.color.colorTextNormal)
            .withSelectable(false)
            .withBadge("1,234.56")
            .withBadgeStyle(new BadgeStyle()
                    .withTextColorRes(R.color.colorPrimary));
    mDrawerItems.add(item);

    item = new PrimaryDrawerItem()
            .withIdentifier(2)
            .withName("Test 2")
            .withIcon(R.drawable.ic_menu_camera)
            .withTextColorRes(R.color.colorTextNormal)
            .withSelectable(false)
            .withBadgeStyle(new BadgeStyle(com.mikepenz.materialdrawer.R.drawable.material_drawer_badge,
                    application.getResources().getColor(R.color.colorPrimary),
                    application.getResources().getColor(R.color.colorPrimary),
                    application.getResources().getColor(R.color.colorWhite)))
            .withBadge("1个新回话");
    mDrawerItems.add(item);

    item = new PrimaryDrawerItem()
            .withIdentifier(3)
            .withName("Test 3")
            .withIcon(R.drawable.ic_menu_camera)
            .withTextColorRes(R.color.colorTextNormal)
            .withSelectable(false);
    mDrawerItems.add(item);
}
 
Example #16
Source File: LeftDrawerManager.java    From timecat with Apache License 2.0 5 votes vote down vote up
private void addCalendarItem() {
    drawer.addItemAtPosition(new PrimaryDrawerItem()
            .withName("Description")
            .withIcon(IconUtil.icon(mainActivity, CommunityMaterial.Icon.cmd_calendar_check, R.color.black).alpha(110))
            .withEnabled(true)
            .withIdentifier(CALENDAR), 7);
}
 
Example #17
Source File: LeftDrawerManager.java    From timecat with Apache License 2.0 5 votes vote down vote up
public void onPharmacyModeChanged(boolean enabled) {
    PrimaryDrawerItem item = (PrimaryDrawerItem) drawer.getDrawerItem(SCHEDULES);
    BadgeStyle bs = new BadgeStyle();
    if (enabled) {
        addCalendarItem();
        Drawable bg = new IconicsDrawable(mainActivity).icon(GoogleMaterial.Icon.gmd_check).color(mainActivity.getResources().getColor(R.color.dark_grey_text)).sizeDp(18);
        bs.withBadgeBackground(bg);
    } else {
        drawer.removeItem(CALENDAR);
        bs.withBadgeBackground(new ColorDrawable(Color.TRANSPARENT));
    }
    item.withBadgeStyle(bs);
    item.withBadge(" ");
    drawer.updateItem(item);
}
 
Example #18
Source File: DrawerActivity.java    From outlay with Apache License 2.0 4 votes vote down vote up
public void setupDrawer(User currentUser) {
    String email = TextUtils.isEmpty(currentUser.getEmail()) ? "Guest" : currentUser.getEmail();

    AccountHeader headerResult = new AccountHeaderBuilder()
            .withActivity(this)
            .withTextColor(getOutlayTheme().secondaryTextColor)
            .withAlternativeProfileHeaderSwitching(false)
            .withSelectionListEnabledForSingleProfile(false)
            .withProfileImagesClickable(false)
            .withCloseDrawerOnProfileListClick(false)
            .addProfiles(
                    new ProfileDrawerItem()
                            .withEmail(email)
            )
            .build();

    List<IDrawerItem> items = new ArrayList<>();
    if (currentUser.isAnonymous()) {
        items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_create_user).withIcon(MaterialDesignIconic.Icon.gmi_account_add).withIdentifier(ITEM_CREATE_USER));
    }

    items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_analysis).withIcon(MaterialDesignIconic.Icon.gmi_trending_up).withIdentifier(ITEM_ANALYSIS));
    items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_categories).withIcon(MaterialDesignIconic.Icon.gmi_apps).withIdentifier(ITEM_CATEGORIES));
    items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_feedback).withIcon(MaterialDesignIconic.Icon.gmi_email).withIdentifier(ITEM_FEEDBACK));
    items.add(new PrimaryDrawerItem().withName(R.string.menu_item_settings).withIcon(MaterialDesignIconic.Icon.gmi_settings).withIdentifier(ITEM_SETTINGS));
    items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_signout).withIcon(MaterialDesignIconic.Icon.gmi_sign_in).withIdentifier(ITEM_SING_OUT));


    mainDrawer = new DrawerBuilder()
            .withFullscreen(true)
            .withActivity(this)
            .withAccountHeader(headerResult)
            .withSelectedItem(-1)
            .addDrawerItems(items.toArray(new IDrawerItem[items.size()]))
            .withOnDrawerItemClickListener((view, i, iDrawerItem) -> {
                if (iDrawerItem != null) {
                    int id = (int) iDrawerItem.getIdentifier();
                    switch (id) {
                        case ITEM_CATEGORIES:
                            analytics().trackViewCategoriesList();
                            SingleFragmentActivity.start(this, CategoriesFragment.class);
                            break;
                        case ITEM_ANALYSIS:
                            analytics().trackAnalysisView();
                            SingleFragmentActivity.start(this, AnalysisFragment.class);
                            break;
                        case ITEM_SETTINGS:
                            SingleFragmentActivity.start(this, SettingsFragment.class);
                            break;
                        case ITEM_FEEDBACK:
                            analytics().trackFeedbackClick();
                            Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                                    "mailto", Constants.CONTACT_EMAIL, null));
                            emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{Constants.CONTACT_EMAIL});
                            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Outlay Feedback");
                            try {
                                startActivity(Intent.createChooser(emailIntent, getString(app.outlay.R.string.label_send_email)));
                            } catch (android.content.ActivityNotFoundException ex) {
                                Alert.error(getRootView(), getString(app.outlay.R.string.error_no_email_clients));
                            }
                            break;
                        case ITEM_ABOUT:
                            SingleFragmentActivity.start(this, AboutFragment.class);
                            break;
                        case ITEM_SING_OUT:
                            analytics().trackSingOut();
                            signOut();
                            break;
                        case ITEM_CREATE_USER:
                            createUser();
                            break;
                    }

                    mainDrawer.setSelection(-1);
                    mainDrawer.closeDrawer();
                }
                return false;
            })
            .build();
}
 
Example #19
Source File: UtilsUI.java    From Moticons with GNU General Public License v3.0 4 votes vote down vote up
public static Drawer showNavigationDrawer(final Context context, Toolbar toolbar, final MoticonAdapter moticonAdapter, final MoticonAdapter moticonPositiveAdapter, final MoticonAdapter moticonNegativeAdapter, final MoticonAdapter moticonFunnyAdapter, final MoticonAdapter moticonAnimalsAdapter, final MoticonAdapter moticonSpecialAdapter, final RecyclerView recyclerView) {
    Activity activity = (Activity) context;

    AccountHeader headerResult = new AccountHeaderBuilder()
            .withActivity(activity)
            .withHeaderBackground(R.drawable.header)
            .build();
    return new DrawerBuilder()
            .withActivity(activity)
            .withToolbar(toolbar)
            .withAccountHeader(headerResult)
            .withStatusBarColor(context.getResources().getColor(R.color.primary_dark))
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(context.getResources().getString(R.string.app_name)).withIcon(R.mipmap.ic_launcher),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_positive)).withIcon(FontAwesome.Icon.faw_thumbs_up).withBadge("(/^▽^)/"),
                    new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_negative)).withIcon(FontAwesome.Icon.faw_thumbs_down).withBadge("(>_<)"),
                    new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_funny)).withIcon(FontAwesome.Icon.faw_child).withBadge("¯\\_(ツ)_/¯"),
                    new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_animal)).withIcon(FontAwesome.Icon.faw_paw).withBadge("∪・ω・∪"),
                    new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_special)).withIcon(FontAwesome.Icon.faw_star).withBadge("ʕ•̬͡•ʕ•̫͡•♥"),
                    new DividerDrawerItem(),
                    new SecondaryDrawerItem().withName(context.getResources().getString(R.string.action_about)).withCheckable(false)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(AdapterView<?> adapterView, View view, int position, long id, IDrawerItem iDrawerItem) {
                    switch (position) {
                        case 0:
                            recyclerView.setAdapter(moticonAdapter);
                            break;
                        case 2:
                            recyclerView.setAdapter(moticonPositiveAdapter);
                            break;
                        case 3:
                            recyclerView.setAdapter(moticonNegativeAdapter);
                            break;
                        case 4:
                            recyclerView.setAdapter(moticonFunnyAdapter);
                            break;
                        case 5:
                            recyclerView.setAdapter(moticonAnimalsAdapter);
                            break;
                        case 6:
                            recyclerView.setAdapter(moticonSpecialAdapter);
                            break;
                        case 8:
                            context.startActivity(new Intent(context, AboutActivity.class));
                            break;
                        default:
                            break;
                    }

                    return false;
                }
            }).build();
}
 
Example #20
Source File: SearchActivity.java    From GithubApp with Apache License 2.0 4 votes vote down vote up
private void initViews() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    setTitle(R.string.search);

    mSearchView.setVoiceSearch(false);
    mSearchView.setSuggestions(getResources().getStringArray(R.array.query_suggestions));
    mSearchView.setOnQueryTextListener(mQueryListener);
    mSearchView.post(new Runnable() {
        @Override
        public void run() {
            mSearchView.showSearch(false);
        }
    });

    mDrawer = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withTranslucentStatusBar(false)
            .withDisplayBelowStatusBar(true)
            .withActionBarDrawerToggleAnimated(true)
            .withDrawerWidthRes(R.dimen.dimen_180)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName("Java").withIcon(DevIcon.Icon.dev_java_plain),
                    new PrimaryDrawerItem().withName("Objective-C").withIcon(DevIcon.Icon.dev_apple_plain),
                    new PrimaryDrawerItem().withName("Swift").withIcon(R.drawable.ic_swift),
                    new PrimaryDrawerItem().withName("JavaScript").withIcon(DevIcon.Icon.dev_javascript_plain),
                    new PrimaryDrawerItem().withName("Python").withIcon(DevIcon.Icon.dev_python_plain),
                    new PrimaryDrawerItem().withName("HTML").withIcon(DevIcon.Icon.dev_html5_plain),
                    new PrimaryDrawerItem().withName("C#").withIcon(DevIcon.Icon.dev_csharp_plain_wordmark),
                    new PrimaryDrawerItem().withName("C++").withIcon(DevIcon.Icon.dev_cplusplus_plain_wordmark),
                    new PrimaryDrawerItem().withName("Ruby").withIcon(DevIcon.Icon.dev_ruby_plain)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    AppLog.d("onItemClick, position = " + position + ", item = " + ((Nameable)drawerItem).getName());

                    mCurrentLang = ((Nameable)drawerItem).getName().toString();
                    search(mCurrentKey, mCurrentLang);
                    mDrawer.closeDrawer();
                    return true;
                }
            })
            .build();

    mAdapter = new RepoListRecyclerAdapter(null);
    mAdapter.setOnRecyclerViewItemClickListener(mItemtClickListener);

    mRepoListView.setLayoutManager(new LinearLayoutManager(this));
    mRepoListView.addItemDecoration(new HorizontalDividerItemDecoration
            .Builder(this)
            .color(Color.TRANSPARENT)
            .size(getResources().getDimensionPixelSize(R.dimen.divider_height))
            .build());

    mRepoListView.setAdapter(mAdapter);

    // default is null
    mCurrentLang = "";
}
 
Example #21
Source File: MainActivity.java    From Faker with Apache License 2.0 4 votes vote down vote up
private void configureDrawer(Bundle savedInstanceState) {

        drawer = new DrawerBuilder()
                .withActivity(this)
                .withHeader(R.layout.header_drawer)
                .withToolbar(toolbar)
                .withTranslucentStatusBar(true)
                .addDrawerItems(
                        new PrimaryDrawerItem().withName("Random data").withIdentifier(RANDOM_WIDGETS_FRAGMENT),
                        new PrimaryDrawerItem().withName("Target views").withIdentifier(TARGET_VIEWS_FRAGMENT),
                        new PrimaryDrawerItem().withName("\"Specific\" random data").withIdentifier(PROFILE_FRAGMENT),
                        new SectionDrawerItem().withName("FAKER  COMPONENTS"),
                        new PrimaryDrawerItem()
                                .withName("Lorem")
                                .withIcon(GoogleMaterial.Icon.gmd_text_format)
                                .withIconTintingEnabled(true)
                                .withIdentifier(LOREM_FRAGMENT),
                        new PrimaryDrawerItem()
                                .withName("Name")
                                .withIcon(GoogleMaterial.Icon.gmd_person)
                                .withIconTintingEnabled(true)
                                .withIdentifier(NAME_FRAGMENT),
                        new PrimaryDrawerItem()
                                .withName("Number")
                                .withIcon(GoogleMaterial.Icon.gmd_filter_9_plus)
                                .withIconTintingEnabled(true)
                                .withIdentifier(NUMBER_FRAGMENT),
                        new PrimaryDrawerItem()
                                .withName("Phone")
                                .withIcon(GoogleMaterial.Icon.gmd_call)
                                .withIconTintingEnabled(true)
                                .withIdentifier(PHONE_FRAGMENT),
                        new PrimaryDrawerItem()
                                .withName("Internet")
                                .withIcon(GoogleMaterial.Icon.gmd_public)
                                .withIconTintingEnabled(true)
                                .withIdentifier(INTERNET_FRAGMENT),
                        new PrimaryDrawerItem()
                                .withName("Url")
                                .withIcon(GoogleMaterial.Icon.gmd_photo)
                                .withIconTintingEnabled(true)
                                .withIdentifier(URL_FRAGMENT),
                        new PrimaryDrawerItem()
                                .withName("Color")
                                .withIcon(GoogleMaterial.Icon.gmd_invert_colors)
                                .withIconTintingEnabled(true)
                                .withIdentifier(COLOR_FRAGMENT),
                        new PrimaryDrawerItem()
                                .withName("Address")
                                .withIcon(GoogleMaterial.Icon.gmd_home)
                                .withIconTintingEnabled(true)
                                .withIdentifier(ADDRESS_FRAGMENT)

                )
                .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(AdapterView<?> adapterView, View view, int i, long l, IDrawerItem iDrawerItem) {
                        if (iDrawerItem != null) {
                            showFragment(iDrawerItem.getIdentifier());
                        }

                        return false;
                    }
                })
                .withSelectedItem(0)
                .withSavedInstance(savedInstanceState)
                .build();
    }
 
Example #22
Source File: Navbar.java    From SteamGifts with MIT License 4 votes vote down vote up
/**
 * Rebuilds the list of all navigation items, in particular:
 * <ol>
 * <li>the header, indicating whether or not the user is logged in</li>
 * <li>list of accessible giveaway filters (new, group, wishlist, all)</li>
 * </ol>
 */
public void reconfigure() {
    // Rebuild the header.
    accountHeader.clear();

    // Update the account header.
    SteamGiftsUserData account = SteamGiftsUserData.getCurrent(activity);
    if (account.isLoggedIn()) {
        profile = (CustomProfileDrawerItem) new CustomProfileDrawerItem().withName(account.getName()).withEmail("...").withIdentifier(1);

        if (account.getImageUrl() != null && !account.getImageUrl().isEmpty())
            profile.withIcon(account.getImageUrl());

        accountHeader.addProfile(profile, 0);
    } else {
        profile = (CustomProfileDrawerItem) new CustomProfileDrawerItem().withName(activity.getString(R.string.guest)).withEmail("Not logged in").withIcon(R.drawable.default_avatar).withIdentifier(1);
        accountHeader.addProfile(profile, 0);
    }


    // Rebuild all items
    drawer.removeAllItems();

    // If we're not logged in, log in is the top.
    if (!account.isLoggedIn())
        drawer.addItem(new PrimaryDrawerItem().withName(R.string.login).withIdentifier(R.string.login).withSelectable(false).withIcon(FontAwesome.Icon.faw_sign_in));

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
    String mode = sharedPreferences.getString("preference_sidebar_discussion_list", "full");

    addGiveawayItems(account);

    if ("compact".equals(mode))
        drawer.addItem(new DividerDrawerItem());
    addDiscussionItems(account, mode);

    drawer.addItems(new DividerDrawerItem());
    drawer.addItem(new PrimaryDrawerItem().withName(R.string.navigation_saved_elements).withIdentifier(R.string.navigation_saved_elements).withIcon(FontAwesome.Icon.faw_star));
    drawer.addItem(new PrimaryDrawerItem().withName(R.string.preferences).withIdentifier(R.string.preferences).withSelectable(false).withIcon(FontAwesome.Icon.faw_cog));
    drawer.addItem(new PrimaryDrawerItem().withName(R.string.navigation_help).withIdentifier(R.string.navigation_help).withSelectable(false).withIcon(FontAwesome.Icon.faw_question));
    drawer.addItem(new PrimaryDrawerItem().withName(R.string.navigation_about).withIdentifier(R.string.navigation_about).withSelectable(false).withIcon(FontAwesome.Icon.faw_info));
}
 
Example #23
Source File: MainActivity.java    From openapk with GNU General Public License v3.0 4 votes vote down vote up
public static Drawer setNavigationDrawer(final Context context, final Toolbar toolbar, final RecyclerView recyclerView, boolean badge, final AppAdapter appInstalledAdapter, final AppAdapter appSystemAdapter, final AppAdapter appDisabledAdapter, final AppAdapter appHiddenAdapter, final AppAdapter appFavoriteAdapter) {
    AppPreferences appPreferences = App.getAppPreferences();
    final Activity activity = (Activity) context;
    int header;

    // check for dark theme
    Integer badgeColor;
    BadgeStyle badgeStyle;
    if (appPreferences.getTheme().equals("0")) {
        badgeColor = ContextCompat.getColor(context, R.color.badge_light);
        badgeStyle = new BadgeStyle(badgeColor, badgeColor).withTextColor(context.getResources().getColor(R.color.text_light));
        header = R.drawable.header_day;
    } else {
        badgeColor = ContextCompat.getColor(context, R.color.badge_dark);
        badgeStyle = new BadgeStyle(badgeColor, badgeColor).withTextColor(context.getResources().getColor(R.color.text_dark));
        header = R.drawable.header_night;
    }

    AccountHeader headerResult = new AccountHeaderBuilder()
            .withActivity(activity)
            .withHeaderBackground(header)
            .build();

    DrawerBuilder drawerBuilder = new DrawerBuilder();
    drawerBuilder.withActivity(activity);
    drawerBuilder.withToolbar(toolbar);
    drawerBuilder.withAccountHeader(headerResult);
    drawerBuilder.withStatusBarColor(OtherUtils.dark(appPreferences.getPrimaryColor(), 0.8));

    if (badge) {
        String installedApps = Integer.toString(appInstalledAdapter.getItemCount());
        String systemApps = Integer.toString(appSystemAdapter.getItemCount());
        String disabledApps = Integer.toString(appDisabledAdapter.getItemCount());
        String hiddenApps = Integer.toString(appHiddenAdapter.getItemCount());
        String favoriteApps = Integer.toString(appFavoriteAdapter.getItemCount());
        drawerBuilder.addDrawerItems(
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_installed)).withIcon(GoogleMaterial.Icon.gmd_phone_android).withBadge(installedApps).withBadgeStyle(badgeStyle).withIdentifier(0),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_system)).withIcon(GoogleMaterial.Icon.gmd_android).withBadge(systemApps).withBadgeStyle(badgeStyle).withIdentifier(1),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_disabled)).withIcon(GoogleMaterial.Icon.gmd_remove_circle_outline).withBadge(disabledApps).withBadgeStyle(badgeStyle).withIdentifier(2),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_hidden)).withIcon(GoogleMaterial.Icon.gmd_visibility_off).withBadge(hiddenApps).withBadgeStyle(badgeStyle).withIdentifier(3),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_favorite)).withIcon(GoogleMaterial.Icon.gmd_star).withBadge(favoriteApps).withBadgeStyle(badgeStyle).withIdentifier(4),
                new DividerDrawerItem(),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.settings)).withIcon(GoogleMaterial.Icon.gmd_settings).withSelectable(false).withIdentifier(5),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.about)).withIcon(GoogleMaterial.Icon.gmd_info).withSelectable(false).withIdentifier(6));
    } else {
        drawerBuilder.addDrawerItems(
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_installed)).withIcon(GoogleMaterial.Icon.gmd_phone_android).withIdentifier(0),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_system)).withIcon(GoogleMaterial.Icon.gmd_android).withIdentifier(1),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_disabled)).withIcon(GoogleMaterial.Icon.gmd_remove_circle_outline).withIdentifier(2),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_hidden)).withIcon(GoogleMaterial.Icon.gmd_visibility_off).withIdentifier(3),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_favorite)).withIcon(GoogleMaterial.Icon.gmd_star).withIdentifier(4),
                new DividerDrawerItem(),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.settings)).withIcon(GoogleMaterial.Icon.gmd_settings).withSelectable(false).withIdentifier(5),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.about)).withIcon(GoogleMaterial.Icon.gmd_info).withSelectable(false).withIdentifier(6));
    }

    drawerBuilder.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            switch (drawerItem.getIdentifier()) {
                case 0:
                    recyclerView.setAdapter(appInstalledAdapter);
                    App.setCurrentAdapter(0);
                    OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_installed));
                    break;
                case 1:
                    recyclerView.setAdapter(appSystemAdapter);
                    App.setCurrentAdapter(1);
                    OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_system));
                    break;
                case 2:
                    recyclerView.setAdapter(appDisabledAdapter);
                    App.setCurrentAdapter(2);
                    OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_disabled));
                    break;
                case 3:
                    recyclerView.setAdapter(appHiddenAdapter);
                    App.setCurrentAdapter(3);
                    OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_hidden));
                    break;
                case 4:
                    recyclerView.setAdapter(appFavoriteAdapter);
                    App.setCurrentAdapter(4);
                    OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_favorite));
                    break;
                case 5:
                    context.startActivity(new Intent(context, SettingsActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                    break;
                case 6:
                    context.startActivity(new Intent(context, AboutActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                    break;
                default:
                    break;
            }
            return false;
        }
    });
    return drawerBuilder.build();
}
 
Example #24
Source File: CurrencyListTabsActivity.java    From CryptoBuddy with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_currency_list_tabs);
    context = this;
    mToolbar = findViewById(R.id.toolbar_currency_list);
    setSupportActionBar(mToolbar);
    TabLayout tabLayout = findViewById(R.id.currency_list_tabs);
    mViewPager = findViewById(R.id.currency_list_tabs_container);
    libsBuilder = new LibsBuilder()
            //provide a style (optional) (LIGHT, DARK, LIGHT_DARK_TOOLBAR)
            .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
            .withAboutIconShown(true)
            .withLicenseShown(true)
            .withVersionShown(true)
            .withAboutVersionShownName(true)
            .withAboutVersionShownCode(true)
            .withAboutVersionString("Version: " + BuildConfig.VERSION_NAME)
            .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
            .withActivityTitle("CryptoBuddy")
            .withLibraries("easyrest", "materialabout", "androiddevicenames", "customtabs", "togglebuttongroup", "materialfavoritebutton");

    TextDrawable t = new TextDrawable(this);
    t.setText("ART");
    t.setTextAlign(Layout.Alignment.ALIGN_CENTER);
    t.setTextColor(Color.BLACK);
    t.setTextSize(10);
    AccountHeader headerResult = new AccountHeaderBuilder()
            .withActivity(this)
            .withHeaderBackground(t).build();
    drawer = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(mToolbar)
            .withSelectedItem(1)
            .withAccountHeader(headerResult)
            .addDrawerItems(
                new PrimaryDrawerItem().withIdentifier(1).withName(R.string.Home).withIcon(FontAwesome.Icon.faw_home),
                new PrimaryDrawerItem().withIdentifier(2).withName(R.string.News).withIcon(FontAwesome.Icon.faw_newspaper),
                new PrimaryDrawerItem().withIdentifier(3).withName("About").withIcon(FontAwesome.Icon.faw_question_circle),
                new PrimaryDrawerItem().withIdentifier(4).withName("Open Source").withIcon(FontAwesome.Icon.faw_github_square),
                new PrimaryDrawerItem().withIdentifier(5).withName("Rate on Google Play").withIcon(FontAwesome.Icon.faw_thumbs_up)
            )
            .withTranslucentStatusBar(false)
            .build();
    drawer.setOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            switch (position) {
                case 1:
                    drawer.closeDrawer();
                    return true;
                case 2:
                    drawer.closeDrawer();
                    drawer.setSelection(1);
                    startActivity(new Intent(context, NewsListActivity.class));
                    return true;
                case 3:
                    drawer.closeDrawer();
                    drawer.setSelection(1);
                    startActivity(new Intent(context, AboutTheDevActivity.class));
                    return true;
                case 4:
                    drawer.closeDrawer();
                    drawer.setSelection(1);
                    libsBuilder.start(context);
                default:
                    return true;
            }
        }
    });

    mSectionsPagerAdapter = new SectionsPagerAdapterCurrencyList(getSupportFragmentManager());
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(2);
    mViewPager.addOnPageChangeListener(this);
    tabLayout.setupWithViewPager(mViewPager);
    tabLayout.setSelectedTabIndicatorColor(Color.WHITE);
}
 
Example #25
Source File: MainActivity.java    From wifi_backend with GNU General Public License v3.0 4 votes vote down vote up
@AfterViews
protected void init() {
    toolbar.setTitle(R.string.app_title);

    drawer = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withFireOnInitialOnClick(drawerState == null)
            .withSavedInstance(drawerState)
            .addDrawerItems(
                    new PrimaryDrawerItem()
                            .withName(R.string.drawer_settings)
                            .withIcon(GoogleMaterial.Icon.gmd_settings)
                            .withIdentifier(SETTINGS),

                    new PrimaryDrawerItem()
                            .withName(R.string.drawer_advanced)
                            .withIcon(GoogleMaterial.Icon.gmd_settings_applications)
                            .withIdentifier(ADVANCED)
            )
            .addStickyDrawerItems(
                    new PrimaryDrawerItem()
                            .withName(R.string.drawer_libraries)
                            .withIcon(GoogleMaterial.Icon.gmd_info_outline)
                            .withSelectable(false)
                            .withIdentifier(LIBRARIES),

                    new PrimaryDrawerItem()
                            .withName(R.string.drawer_website)
                            .withIcon(GoogleMaterial.Icon.gmd_info)
                            .withSelectable(false)
                            .withIdentifier(WEBSITE)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    if (drawerItem != null) {
                        final int id = drawerItem.getIdentifier();

                        if(id == SETTINGS) {
                            setFragment(new MainSettingsFragment_());
                        } else if (id == ADVANCED) {
                            setFragment(new AdvancedSettingsFragment_());
                        } else if (id == LIBRARIES) {
                            new LibsBuilder()
                                    .withFields(R.string.class.getFields())
                                    .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
                                    .start(MainActivity.this);
                        } else if (id == WEBSITE) {
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.WEBSITE)));
                        }
                    }

                    return false;
                }
            })
            .build();

    updateTitle();

    if(action == Action.request_permission) {
        drawer.setSelection(SETTINGS);
    }
}
 
Example #26
Source File: MainActivity.java    From Local-GSM-Backend with Apache License 2.0 4 votes vote down vote up
@AfterViews
protected void init() {
    toolbar.setTitle(R.string.app_name);

    drawer = new DrawerBuilder()
            .withActivity(this)
            .withSavedInstance(drawerState)
            .withToolbar(toolbar)
            .addDrawerItems(
                    new PrimaryDrawerItem()
                            .withName(R.string.fragment_update_database_title)
                            .withIcon(GoogleMaterial.Icon.gmd_folder)
                            .withIdentifier(DATABASE),

                    new PrimaryDrawerItem()
                            .withName(R.string.fragment_settings_title)
                            .withIcon(GoogleMaterial.Icon.gmd_settings)
                            .withIdentifier(SETTINGS),

                    new PrimaryDrawerItem()
                            .withName(R.string.fragment_settings_advanced_title)
                            .withIcon(GoogleMaterial.Icon.gmd_settings_applications)
                            .withIdentifier(SETTINGS_ADVANCED)
            )
            .addStickyDrawerItems(
                    new PrimaryDrawerItem()
                            .withName(R.string.activity_main_libraries)
                            .withIcon(GoogleMaterial.Icon.gmd_info_outline)
                            .withSelectable(false)
                            .withIdentifier(LIBRARIES),

                    new PrimaryDrawerItem()
                            .withName(R.string.activity_main_about)
                            .withIcon(GoogleMaterial.Icon.gmd_info)
                            .withSelectable(false)
                            .withIdentifier(ABOUT)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    if (drawerItem != null) {
                        final int id = drawerItem.getIdentifier();

                        if (id == SETTINGS) {
                            setFragment(new SettingsFragment_());
                        } else if (id == DATABASE) {
                            setFragment(new UpdateDatabaseFragment_());
                        } else if (id == LIBRARIES) {
                            new LibsBuilder()
                                    .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
                                    .withFields(R.string.class.getFields())
                                    .start(MainActivity.this);
                        } else if (id == SETTINGS_ADVANCED) {
                            setFragment(new AdvancedSettingsFragment_());
                        } else if (id == ABOUT) {
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Config.ABOUT_URL)));
                        }
                    }

                    return false;
                }
            })
            .withFireOnInitialOnClick(drawerState == null)
            .build();

    updateTitle();
    if(action == Action.request_permission) {
        drawer.setSelection(SETTINGS);
    }

}