Java Code Examples for com.mikepenz.materialdrawer.model.PrimaryDrawerItem

The following are top voted examples for showing how to use com.mikepenz.materialdrawer.model.PrimaryDrawerItem. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: MyAnimeViewer   File: MainActivity.java   Source Code and License 6 votes vote down vote up
private void initialDrawerItems() {
    //Menu Items
    mDrawerItem_Parser = new PrimaryDrawerItem().withName("Source").withIcon(R.mipmap.ic_launcher).withIdentifier(1);
    mDrawerItem_Catalog = new PrimaryDrawerItem().withName(R.string.menu_title_catalog).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_public_black_24dp : R.drawable.ic_public_white_24dp).withIdentifier(2);
    mDrawerItem_Library = new PrimaryDrawerItem().withName(R.string.menu_title_library).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_home_black_24dp : R.drawable.ic_home_white_24dp).withIdentifier(3);
    mDrawerItem_Favorites = new PrimaryDrawerItem().withName(R.string.menu_title_favorites).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_favorite_black_24dp : R.drawable.ic_favorite_white_24dp).withIdentifier(4);
    mDrawerItem_History = new PrimaryDrawerItem().withName(R.string.menu_title_history).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_history_black_24dp : R.drawable.ic_history_white_24dp).withIdentifier(5);
    mDrawerItem_Downloads = new PrimaryDrawerItem().withName(R.string.menu_title_downloads).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_save_black_24dp : R.drawable.ic_save_white_24dp).withIdentifier(6);
    mDrawerItem_AllManga = new PrimaryDrawerItem().withName(R.string.menu_title_all_anime).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_public_black_24dp : R.drawable.ic_public_white_24dp).withIdentifier(7);
    mDrawerItem_Genres = new PrimaryDrawerItem().withName(R.string.menu_title_genres).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_filter_list_black_24dp : R.drawable.ic_filter_list_white_24dp).withIdentifier(8);
    mDrawerItem_LatestReleases = new PrimaryDrawerItem().withName(R.string.menu_title_latest_releases).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_new_releases_black_24dp : R.drawable.ic_new_releases_white_24dp).withIdentifier(9);
    mDrawerItem_RandomManga = new PrimaryDrawerItem().withName(R.string.menu_title_random_anime).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_help_outline_black_24dp : R.drawable.ic_help_outline_white_24dp).withIdentifier(10);
    mDrawerItem_AdvancedSearch = new PrimaryDrawerItem().withName(R.string.menu_title_advanced_search).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_search_black_24dp : R.drawable.ic_search_white_24dp).withIdentifier(11);
    mDrawerItem_NewSeries = new PrimaryDrawerItem().withName(R.string.menu_title_new_series).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_today_black_24dp : R.drawable.ic_today_white_24dp).withIdentifier(12);
    //new PrimaryDrawerItem().withName(R.string.menu_title_queue).withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_comment_list)).withIdentifier(14);
    mDrawerItem_ServerSearch = new PrimaryDrawerItem().withName("Search Online").withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_search_black_24dp : R.drawable.ic_search_white_24dp).withIdentifier(15);
    mDrawerItem_Settings = new PrimaryDrawerItem().withName(R.string.menu_title_settings).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_settings_black_24dp : R.drawable.ic_settings_white_24dp).withIdentifier(16);
    mDrawerItem_Patreon = new PrimaryDrawerItem().withName(R.string.menu_title_patreon).withIcon(R.drawable.patreon).withIdentifier(17);
    mDrawerItem_Version = new SecondaryDrawerItem().withName("Version: " + BuildConfig.VERSION_NAME).withSelectable(false);
}
 
Example 2
Project: githubclient   File: MainActivity.java   Source Code and License 6 votes vote down vote up
private void switchMenu(PrimaryDrawerItem item) {
    String tag = item.getName().getText(this);
    AppLog.d("switch menu tag:" + tag);

    Fragment fragment = mFragmentManager.findFragmentByTag(tag);
    AppLog.d("switch menu fragment:" + fragment);

    if (fragment != null) {
        if (fragment == mCurrentFragment) return;

        mFragmentManager.beginTransaction().show(fragment).commit();
    }
    else {
        fragment = Fragment.instantiate(this, (String) item.getTag());
        mFragmentManager.beginTransaction().add(R.id.content_frame, fragment, tag).commit();
    }

    if (mCurrentFragment != null) {
        mFragmentManager.beginTransaction().hide(mCurrentFragment).commit();
    }

    mCurrentFragment = fragment;
    setTitle(tag);
}
 
Example 3
Project: ocreader   File: DrawerManager.java   Source Code and License 6 votes vote down vote up
private IDrawerItem getDrawerItem(Realm realm, TreeItem item) {
    boolean shouldSelect;

    PrimaryDrawerItem drawerItem = new TreeItemDrawerItem(item);

    if (item instanceof Feed) {
        shouldSelect = state.isFeedSelected();
    } else {
        shouldSelect = !state.isFeedSelected();
    }

    shouldSelect = shouldSelect && state.getStartDrawerItem().getId() == item.getId();

    drawerItem.withBadge(item.getCount(realm));

    return drawerItem.withSetSelected(shouldSelect);
}
 
Example 4
Project: ocreader   File: DrawerManager.java   Source Code and License 6 votes vote down vote up
@Override
protected List<IDrawerItem> reloadDrawerItems(Realm realm, boolean showOnlyUnread) {
    List<Feed> feeds = state.getStartDrawerItem().getFeeds(realm, showOnlyUnread);
    List<IDrawerItem> drawerItems = new ArrayList<>((feeds != null ? feeds.size() : 0) + 1);

    if (state.isFeedSelected())
        return drawerItems;

    drawerItems.add(new SectionDrawerItem()
            .withDivider(false)
            .withName(state.getStartDrawerItem().getName()));

    if (feeds != null) {
        for (Feed feed : feeds) {
            PrimaryDrawerItem drawerItem = new TreeItemDrawerItem(feed);
            drawerItem.withIdentifier(feed.getId());
            drawerItem.withBadge(feed.getUnreadCount());

            drawerItem.withSetSelected(state.getEndDrawerItem() != null && state.getEndDrawerItem().getId() == feed.getId());
            drawerItems.add(drawerItem);
        }
    }

    return drawerItems;
}
 
Example 5
Project: cartolapp   File: ToolbarBase.java   Source Code and License 6 votes vote down vote up
@UiThread void initDrawer() {
  PrimaryDrawerItem home =
      new PrimaryDrawerItem().withName(R.string.home).withIcon(GoogleMaterial.Icon.gmd_home);
  new DrawerBuilder().withActivity((Activity) act)
      .withToolbar(toolbar)
      .withHasStableIds(true)
      .withTranslucentStatusBar(true)
      .withSelectedItem(-1)
      .withAccountHeader(headerResult)
      .addDrawerItems(home)
      .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
          switch (position) {
            case 1:
              context.startActivity(new Intent(context, MainActivity_.class));
              return true;
            default:
              return true;
          }
        }
      })
      .build();
}
 
Example 6
Project: LETO-Toggl_Android   File: MainActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    startTimer();
    getData();
    ((CoreApplication) getApplication()).mainActivityInstance=this;
    checkLocationPermission();

    //DrawerItems
    PrimaryDrawerItem beaconItem = ((PrimaryDrawerItem)drawer.getDrawerItem(2));
    PrimaryDrawerItem geofenceItem = ((PrimaryDrawerItem)drawer.getDrawerItem(3));
    beaconItem.withBadge(AppPreferences.getBeaconDetectionState()? "On":"Off");
    geofenceItem.withBadge(AppPreferences.getGeofenceDetectionState()? "On":"Off");
    drawer.updateItem(beaconItem);
    drawer.updateItem(geofenceItem);
}
 
Example 7
Project: MaterialDrawer   File: SecondDrawerFragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    // don't look at this layout it's just a listView to show how to handle the keyboard
    View view = inflater.inflate(R.layout.fragment_simple_sample, container, false);

    result = new DrawerBuilder()
            .withActivity(getActivity())
            .withRootView((ViewGroup) view.findViewById(R.id.rootView))
            .withDisplayBelowStatusBar(false)
            .withSavedInstance(savedInstanceState)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye)
            )
            .buildForFragment();

    TextView textView = (TextView) view.findViewById(R.id.title);
    textView.setText(getArguments().getString(KEY_TITLE));

    result.getDrawerLayout().setFitsSystemWindows(false);
    result.getSlider().setFitsSystemWindows(false);

    return view;
}
 
Example 8
Project: SteamGifts   File: Navbar.java   Source Code and 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 9
Project: SteamGifts   File: Navbar.java   Source Code and 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 10
Project: SteamGifts   File: Navbar.java   Source Code and 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 11
Project: SteamGifts   File: Navbar.java   Source Code and 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 12
Project: calendula   File: LeftDrawerMgr.java   Source Code and License 6 votes vote down vote up
public void onPharmacyModeChanged(boolean enabled) {
    PrimaryDrawerItem item = (PrimaryDrawerItem) drawer.getDrawerItem(PHARMACIES);
    BadgeStyle bs = new BadgeStyle();
    if (enabled) {
        addCalendarItem();
        Drawable bg = new IconicsDrawable(home)
                .icon(GoogleMaterial.Icon.gmd_check)
                .color(home.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 13
Project: Tusky   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void onFetchUserInfoSuccess(Account me, String domain) {
    // Add the header image and avatar from the account, into the navigation drawer header.
    ImageView background = headerResult.getHeaderBackgroundView();
    background.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark));
    Picasso.with(MainActivity.this)
            .load(me.header)
            .placeholder(R.drawable.account_header_default)
            .into(background);

    headerResult.clear();
    headerResult.addProfiles(
            new ProfileDrawerItem()
                    .withName(me.getDisplayName())
                    .withEmail(String.format("%[email protected]%s", me.username, domain))
                    .withIcon(me.avatar)
    );

    // Show follow requests in the menu, if this is a locked account.
    if (me.locked) {
        PrimaryDrawerItem followRequestsItem = new PrimaryDrawerItem()
                .withIdentifier(DRAWER_ITEM_FOLLOW_REQUESTS)
                .withName(R.string.action_view_follow_requests)
                .withSelectable(false)
                .withIcon(GoogleMaterial.Icon.gmd_person_add);
        drawer.addItemAtPosition(followRequestsItem, 3);
    }

    // Update the current login information.
    loggedInAccountId = me.id;
    loggedInAccountUsername = me.username;
    getPrivatePreferences().edit()
            .putString("loggedInAccountId", loggedInAccountId)
            .putString("loggedInAccountUsername", loggedInAccountUsername)
            .putBoolean("loggedInAccountLocked", me.locked)
            .apply();
}
 
Example 14
Project: FragmentNavigationPatternDemo   File: DrawerManager.java   Source Code and License 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
Project: FragmentNavigationPatternDemo   File: DrawerManager.java   Source Code and License 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 16
Project: sabbath-school-android   File: SSBaseActivity.java   Source Code and License 5 votes vote down vote up
private IDrawerItem[] getDrawerItems(){
    int primaryColor = Color.parseColor(SSColorTheme.getInstance().getColorPrimary());
    ssDrawerItems[0] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_read_now)).withIcon(GoogleMaterial.Icon.gmd_book).withIdentifier(MENU_READ_ID).withSelectable(false).withSelectedIconColor(primaryColor).withSelectedTextColor(primaryColor);
    ssDrawerItems[1] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_my_highlights)).withIcon(GoogleMaterial.Icon.gmd_border_color).withIdentifier(MENU_HIGHLIGHTS_ID).withSelectable(false).withSelectedIconColor(primaryColor).withSelectedTextColor(primaryColor);
    ssDrawerItems[2] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_my_notes)).withIcon(GoogleMaterial.Icon.gmd_comment).withIdentifier(MENU_NOTES_ID).withSelectable(false).withSelectedIconColor(primaryColor).withSelectedTextColor(primaryColor);
    ssDrawerItems[3] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_settings)).withIcon(GoogleMaterial.Icon.gmd_settings).withIdentifier(MENU_SETTINGS_ID).withSelectable(false).withSelectedIconColor(primaryColor).withSelectedTextColor(primaryColor);
    ssDrawerItems[4] = new DividerDrawerItem();
    ssDrawerItems[5] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_share_app)).withIdentifier(MENU_SHARE_ID).withSelectable(false).withSelectedTextColor(primaryColor);
    ssDrawerItems[6] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_about)).withIdentifier(MENU_ABOUT_ID).withSelectable(false).withSelectedTextColor(primaryColor);

    return ssDrawerItems;
}
 
Example 17
Project: duedo   File: BaseActivity.java   Source Code and License 5 votes vote down vote up
protected void setDrawer(Boolean upEnabled) {
    Toolbar toolbar_main = (Toolbar) findViewById(R.id.toolbar_main);
    setSupportActionBar(toolbar_main);

    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null)
        if (upEnabled) {
            supportActionBar.setDisplayHomeAsUpEnabled(true);
        } else {
            final Intent intent = new Intent(this, FormActivity.class);
            new DrawerBuilder()
                    .withActivity(this)
                    .withToolbar(toolbar_main)
                    .addDrawerItems(
                            new PrimaryDrawerItem()
                                    .withName(R.string.new_task)
                                    .withIcon(MaterialDesignIconic.Icon.gmi_plus)
                                    .withSelectable(false)
                                    .withIdentifier(1)
                    ).withSelectedItem(-1)
                    .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                        @Override
                        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                            switch (drawerItem.getIdentifier()) {
                                case 1:
                                    startActivityForResult(intent, NEW_TASK);
                                    break;
                            }
                            return false;
                        }
                    })
                    .build();
        }
}
 
Example 18
Project: ocreader   File: DrawerManager.java   Source Code and License 5 votes vote down vote up
@Override
protected List<IDrawerItem> reloadDrawerItems(Realm realm, boolean showOnlyUnread) {
    List<IDrawerItem> drawerItems = new ArrayList<>();

    ((AbstractSwitchableDrawerItem)topDrawerItems.get(0)).withChecked(showOnlyUnread);
    drawerItems.addAll(topDrawerItems);

    for(IDrawerItem drawerItem: topDrawerItems) {
        if(drawerItem.getTag() instanceof TreeItem) {
            TreeItem item = (TreeItem) drawerItem.getTag();
            int count = item.getCount(realm);
            if(count > 0 && drawerItem instanceof Badgeable)
                ((Badgeable) drawerItem).withBadge(String.valueOf(count));
            if (state.getStartDrawerItem().getId() == item.getId()) {
                drawerItem.withSetSelected(true);
                break;
            }
        }
    }

    final List<TreeItem> treeItems = new ArrayList<>();
    treeItems.addAll(Folder.getAll(realm, showOnlyUnread));
    treeItems.addAll(Queries.getFeedsWithoutFolder(realm, showOnlyUnread));

    if(treeItems.isEmpty()) {
        drawerItems.add(
                new PrimaryDrawerItem()
                    .withEnabled(false)
                    .withName(R.string.no_folders_to_show)
        );
    } else {
        for (TreeItem treeItem : treeItems) {
            drawerItems.add(getDrawerItem(realm, treeItem));
        }
    }

    return drawerItems;
}
 
Example 19
Project: Droid2JoyStick   File: MainActivity.java   Source Code and License 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 20
Project: LanCamera   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    PrimaryDrawerItem liveItem = new PrimaryDrawerItem().withName(R.string.live)
            .withIdentifier(ID_LIVE);
    mHistoryItem = new ExpandableDrawerItem().withName(history)
            .withSubItems(mHistoryItems)
            .withIdentifier(ID_HISTORY);
    PrimaryDrawerItem settingItem = new PrimaryDrawerItem().withName(R.string.setting)
            .withIdentifier(ID_SETTING);

    mDrawer = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withRootView(R.id.container)
            .withActionBarDrawerToggle(true)
            .withActionBarDrawerToggleAnimated(true)
            .addDrawerItems(liveItem)
            .addDrawerItems(mHistoryItem)
            .addDrawerItems(new DividerDrawerItem())
            .addDrawerItems(settingItem)
            .withOnDrawerItemClickListener(this)
            .build();

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);

    player = new GiraffePlayer(this);

    playLive();

    prepareHistory();
}
 
Example 21
Project: librus-client   File: FragmentPresenter.java   Source Code and License 5 votes vote down vote up
public PrimaryDrawerItem convertToDrawerItem(java8.util.function.Consumer<FragmentPresenter> displayFragment) {
    return new PrimaryDrawerItem()
            .withIconTintingEnabled(true)
            .withSelectable(false)
            .withName(getTitle())
            .withIcon(getIcon())
            .withIdentifier(getTitle())
            .withIconTintingEnabled(true)
            .withOnDrawerItemClickListener((v, p, d) -> {
                displayFragment.accept(this);
                return false;
            });
}
 
Example 22
Project: HACKxFDU-CrisisProbingUAV   File: BaseActivity.java   Source Code and License 5 votes vote down vote up
@NonNull
protected List<IDrawerItem> drawerItems() {
  return Arrays.<IDrawerItem>asList(
      new PrimaryDrawerItem()
          .withName(R.string.drawer_item_recognize_tags)
          .withOnDrawerItemClickListener(goToActivityListener(RecognizeConceptsActivity.class)),
      new SecondaryDrawerItem()
          .withName(R.string.drawer_item_recognize_colors)
          .withOnDrawerItemClickListener(goToActivityListener(RecognizeColorsActivity.class))
  );
}
 
Example 23
Project: MaterialDrawer   File: DrawerFragment.java   Source Code and License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    // don't look at this layout it's just a listView to show how to handle the keyboard
    View view = inflater.inflate(R.layout.fragment_simple_sample, container, false);

    result = new DrawerBuilder()
            .withActivity(getActivity())
            .withRootView((ViewGroup) view.findViewById(R.id.rootView))
            .withDisplayBelowStatusBar(false)
            .withSavedInstance(savedInstanceState)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new SectionDrawerItem().withName(R.string.drawer_item_section_header),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn)
            )
            .buildForFragment();

    TextView textView = (TextView) view.findViewById(R.id.title);
    textView.setText(getArguments().getString(KEY_TITLE));

    result.getDrawerLayout().setFitsSystemWindows(false);
    result.getSlider().setFitsSystemWindows(false);

    return view;
}
 
Example 24
Project: MaterialDrawer   File: CustomContainerActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_custom_container_dark_toolbar);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.drawer_item_custom_container_drawer);

    //Create the drawer
    result = new DrawerBuilder(this)
            //this layout have to contain child layouts
            .withRootView(R.id.drawer_container)
            .withToolbar(toolbar)
            .withDisplayBelowStatusBar(false)
            .withActionBarDrawerToggleAnimated(true)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new SectionDrawerItem().withName(R.string.drawer_item_section_header),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn)
            )
            .withSavedInstance(savedInstanceState)
            .build();
}
 
Example 25
Project: MaterialDrawer   File: ActionBarActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    //supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_actionbar);
    setTitle(R.string.drawer_item_action_bar_drawer);

    // Handle Toolbar
    result = new DrawerBuilder()
            .withActivity(this)
            .withSavedInstance(savedInstanceState)
            .withDisplayBelowStatusBar(false)
            .withTranslucentStatusBar(false)
            .withDrawerLayout(R.layout.material_drawer_fits_not)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    if (drawerItem instanceof Nameable) {
                        Toast.makeText(ActionBarActivity.this, ((Nameable) drawerItem).getName().getText(ActionBarActivity.this), Toast.LENGTH_SHORT).show();
                    }

                    return false;
                }
            }).build();

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
 
Example 26
Project: MaterialDrawer   File: MiniDrawer.java   Source Code and License 5 votes vote down vote up
/**
 * generates a MiniDrawerItem from a IDrawerItem
 *
 * @param drawerItem
 * @return
 */
public IDrawerItem generateMiniDrawerItem(IDrawerItem drawerItem) {
    if (drawerItem instanceof SecondaryDrawerItem) {
        return mIncludeSecondaryDrawerItems ? new MiniDrawerItem((SecondaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground) : null;
    } else if (drawerItem instanceof PrimaryDrawerItem) {
        return new MiniDrawerItem((PrimaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground);
    } else if (drawerItem instanceof ProfileDrawerItem) {
        MiniProfileDrawerItem mpdi = new MiniProfileDrawerItem((ProfileDrawerItem) drawerItem);
        mpdi.withEnabled(mEnableProfileClick);
        return mpdi;
    }
    return null;
}
 
Example 27
Project: YouJoin-Android   File: DrawerUtils.java   Source Code and License 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 28
Project: YouJoin-Android   File: MiniDrawer.java   Source Code and License 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 29
Project: Komica   File: KomicaHomeFragment.java   Source Code and License 5 votes vote down vote up
private List<IDrawerItem> getMainDrawerItems() {
    List<IDrawerItem> drawerItemList = new ArrayList<>();
    drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1001).withName(R.string.home_page).withIcon(R.drawable.ic_home)));
    drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1005).withName(R.string.refresh_menu).withIcon(R.drawable.ic_loop).withSelectable(false)));
    drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1006).withName(R.string.clear_cache).withIcon(R.drawable.ic_clear_cache).withSelectable(false)));
    drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1002).withName(R.string.sponsor).withIcon(R.drawable.ic_sponsor).withSelectable(false)));
    drawerItemList.add(new DividerDrawerItem());
    drawerItemList.add(new SecondaryDrawerItem().withName(R.string.others).withSelectable(false));
    drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1003).withName(R.string.rating).withIcon(R.drawable.ic_rate).withSelectable(false)));
    drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1004).withName(R.string.feedback).withIcon(R.drawable.ic_feedback).withSelectable(false)));
    return drawerItemList;
}
 
Example 30
Project: Komica   File: KomicaHomeFragment.java   Source Code and License 5 votes vote down vote up
private IDrawerItem[] getDynamicalDrawerItems() {
        List<IDrawerItem> drawerItemList = getMainDrawerItems();
        for (KomicaMenuGroup group : KomicaManager.getInstance().getMenuGroupList()) {
            drawerItemList.add(new DividerDrawerItem());
//            drawerItemList.add(new SecondaryDrawerItem().withName(group.getTitle()).withTextColor(Color.RED));
            List<IDrawerItem> memberList = new ArrayList<>();
            List<Long> identifiers = new ArrayList<>();
            for (KomicaMenuMember member : group.getMemberList()) {
                if (!KomicaManager.getInstance().checkVisible(member.getTitle())) {
                    continue;
                }
                memberList.add(
                        getColorSetting(
                                new PrimaryDrawerItem().withIdentifier(member.getMemberId()).withName(member.getTitle())
                        )
                );
                identifiers.add((long) member.getMemberId());
            }
            drawerIdentifiers = new long[identifiers.size()];
            for (int i = 0; i < identifiers.size(); i++) {
                drawerIdentifiers[i] = identifiers.get(i);
            }
            ExpandableDrawerItem expandableDrawerItem =
                    new ExpandableDrawerItem().withArrowColorRes(R.color.colorPrimary)
                            .withName(group.getTitle())
                            .withTextColor(Color.RED)
                            .withSelectable(false).withSubItems(memberList);
            drawerItemList.add(expandableDrawerItem);
        }
        IDrawerItem[] items = new IDrawerItem[drawerItemList.size()];
        return drawerItemList.toArray(items);
    }
 
Example 31
Project: Roach   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void initialiseDrawerItems() {
    mDrawerItems = new HashMap<>();
    mDrawerItems.put(R.id.tab_card_db, new PrimaryDrawerItem()
            .withIdentifier(R.id.tab_card_db)
            .withName(R.string.card_database)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_database, getTheme())));
    mDrawerItems.put(R.id.tab_public_decks, new PrimaryDrawerItem()
            .withIdentifier(R.id.tab_public_decks)
            .withName(R.string.public_decks)
            .withSelectable(BuildConfig.DEBUG)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_public, getTheme())));
    mDrawerItems.put(R.id.tab_decks, new PrimaryDrawerItem()
            .withIdentifier(R.id.tab_decks)
            .withName(R.string.deck_builder)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_cards_filled, getTheme())));
    mDrawerItems.put(R.id.tab_collection, new PrimaryDrawerItem()
            .withIdentifier(R.id.tab_collection)
            .withName(R.string.collection_manager)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_cards_outline, getTheme())));
    mDrawerItems.put(R.id.tab_results, new PrimaryDrawerItem()
            .withIdentifier(R.id.tab_results)
            .withName(R.string.results)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_chart, getTheme())));
    mDrawerItems.put(R.id.tab_helper, new PrimaryDrawerItem()
            .withIdentifier(R.id.tab_helper)
            .withSelectable(false)
            .withName(R.string.keg_helper)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_help, getTheme())));
    mDrawerItems.put(R.id.tab_news, new PrimaryDrawerItem()
            .withIdentifier(R.id.tab_news)
            .withSelectable(false)
            .withName(R.string.news)
            .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_news, getTheme())));
}
 
Example 32
Project: xTun-android   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private ArrayList<IDrawerItem> getDrawerItems() {
    SectionDrawerItem profileItem = new SectionDrawerItem().withName(R.string.profiles)
            .withTextColorRes(R.color.accentColor).setDivider(false);

    PrimaryDrawerItem addItem = new PrimaryDrawerItem().withName(R.string.add_profile)
            .withIdentifier(Action.ADD.ordinal()).withIcon(GoogleMaterial.Icon.gmd_add_circle_outline)
            .withCheckable(false);

    SectionDrawerItem settingItem = new SectionDrawerItem().withName(R.string.settings)
            .withTextColorRes(R.color.accentColor);

    PrimaryDrawerItem recoveryItem = new PrimaryDrawerItem().withName(R.string.recovery)
            .withIdentifier(Action.RECOVERY.ordinal()).withIcon(GoogleMaterial.Icon.gmd_restore)
            .withCheckable(false);

    PrimaryDrawerItem aboutItem = new PrimaryDrawerItem().withName(R.string.about)
            .withIdentifier(Action.ABOUT.ordinal()).withIcon(GoogleMaterial.Icon.gmd_info_outline)
            .withCheckable(false);

    ArrayList<IDrawerItem> items = new ArrayList<>();
    items.add(profileItem);
    items.addAll(getProfileList());
    items.add(addItem);
    items.add(settingItem);
    items.add(recoveryItem);
    items.add(aboutItem);
    return items;
}
 
Example 33
Project: minx   File: MainActivity.java   Source Code and 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 34
Project: top-github   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void setupDrawer() {
    // Create the drawer
    mDrawer = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(mToolbar)
            .withTranslucentStatusBar(false)
            .withActionBarDrawerToggle(true)
            .withHeader(R.layout.drawer_header)
            .build();

    // Add the items to it
    addItemsToDrawer();

    // Set a Click Listener on every drawer's item.
    // If the item is clicked start a new search
    mDrawer.setOnDrawerItemClickListener((View view, int i, IDrawerItem iDrawerItem) -> {
        PrimaryDrawerItem drawerItem = (PrimaryDrawerItem) iDrawerItem;
        String language = drawerItem.getName().getText();
        mMyDataStore.selectedLanguage().put(language);
        mSelectedLanguage = language;
        getSupportActionBar().setTitle(mSelectedLanguage);
        startSearch();
        return false;
    });

    // Set the selected drawer's item
    mDrawer.setSelection(mSelectedItemId, false);

    // Set the Click Listener on the drawer header button
    // If it is clicked show the LanguagesFragment
    mDrawer.getHeader().findViewById(R.id.imageview_change_languages).setOnClickListener((View v) -> {
        LanguagesFragment newFragment = new LanguagesFragment();
        newFragment.show(getSupportFragmentManager().beginTransaction(), LanguagesFragment.TAG);
    });
}
 
Example 35
Project: top-github   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void addItemsToDrawer() {
    int itemId = 0;

    // Add the "All" programming language
    PrimaryDrawerItem allDrawerItem = new PrimaryDrawerItem()
            .withName("All")
            .withIdentifier(itemId)
            .withIcon(Utilities.getDrawableFromLanguage(this, "All"))
            .withIconTintingEnabled(true)
            .withSelectedIconColor(Color.WHITE)
            .withIconColorRes(R.color.primary_dark)
            .withTintSelectedIcon(true);
    mDrawer.addItem(allDrawerItem);
    mSelectedItemId = 0;

    // Add the every other programming language
    for (String languageName : mLanguages.getUserLanguages()) {
        itemId++;
        PrimaryDrawerItem drawerItem = new PrimaryDrawerItem()
                .withName(languageName)
                .withIdentifier(itemId)
                .withIcon(Utilities.getDrawableFromLanguage(this, languageName))
                .withIconTintingEnabled(true)
                .withSelectedIconColor(Color.WHITE)
                .withIconColorRes(R.color.primary_dark)
                .withTintSelectedIcon(true);
        mDrawer.addItem(drawerItem);
        if (mSelectedLanguage.equals(languageName)) {
            mSelectedItemId = itemId;
        }
    }
}
 
Example 36
Project: BabyFace   File: MainDrawerActivity.java   Source Code and License 5 votes vote down vote up
private List<IDrawerItem> facesToDrawerItems() {
	List<IDrawerItem> drawerItems = new ArrayList<>();
	for (Face face : facesManager.getFaces()) {
		drawerItems.add(new PrimaryDrawerItem()
				.withName(face.getName())
				.withIconTintingEnabled(true)
				.withIcon(R.drawable.ic_faces)
				.withTag(face));
	}
	return drawerItems;
}
 
Example 37
Project: BabyFace   File: MainDrawerActivity.java   Source Code and License 5 votes vote down vote up
private IDrawerItem createAddFaceDrawerItem() {
	return new PrimaryDrawerItem()
			.withName(getString(R.string.add_album))
			.withIconTintingEnabled(true)
			.withIcon(R.drawable.ic_add_white_36px)
			.withIdentifier(ID_NEW_ALBUM);
}
 
Example 38
Project: MaterialDrawer-Xamarin   File: DrawerUtils.java   Source Code and License 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 39
Project: MaterialDrawer-Xamarin   File: MiniDrawer.java   Source Code and License 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 40
Project: Mobile-Applications-for-Android   File: BaseDrawerActivity.java   Source Code and License 5 votes vote down vote up
private void setupDrawer() {
    Intent intent = getIntent();
    long currentIdentifier = intent.getLongExtra(EXTRA_IDENTIFIER, 1);

    Toolbar toolbar = getToolbar();
    mDrawer = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .addDrawerItems(new PrimaryDrawerItem()
                    .withIdentifier(1)
                    .withName("Persons List")
            )
            .addDrawerItems(new ExpandableDrawerItem()
                    .withName("APIs")
                    .withSubItems(
                            new SecondaryDrawerItem()
                                    .withIdentifier(3)
                                    .withName("Location")
                    ))
            .addStickyDrawerItems(
                    new PrimaryDrawerItem()
                            .withIdentifier(2)
                            .withName("Profile")
            )
            .withSelectedItem(currentIdentifier)
            .withOnDrawerItemClickListener(this)
            .build();

}
 
Example 41
Project: hipda   File: DrawerHelper.java   Source Code and License 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 42
Project: dawebmail   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void setToolbarTitle(IDrawerItem drawerItem) {
    String currentUserName = User.getUserThreeLetterName(CurrentUser.getCurrentUser(this));
    String toolbarTitle = "";
    if (((PrimaryDrawerItem) drawerItem).getName().getText().equals(pInbox.getName().getText()))
        toolbarTitle = getString(R.string.drawer_inbox) + " : " + currentUserName;
    if (((PrimaryDrawerItem) drawerItem).getName().getText().equals(pSentBox.getName().getText()))
        toolbarTitle = getString(R.string.drawer_sent) + " : " + currentUserName;
    if (((PrimaryDrawerItem) drawerItem).getName().getText().equals(pSmartBox.getName().getText()))
        toolbarTitle = getString(R.string.drawer_smartbox) + " : " + currentUserName;
    if (((PrimaryDrawerItem) drawerItem).getName().getText().equals(pTrashBox.getName().getText()))
        toolbarTitle = getString(R.string.drawer_trash) + " : " + currentUserName;
    getSupportActionBar().setTitle(toolbarTitle);
}
 
Example 43
Project: dawebmail   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void setDrawerSelection(IDrawerItem drawerItem) {
    if (((PrimaryDrawerItem) drawerItem).getName().getText().equals(pInbox.getName().getText()))
        drawer.setSelection(pInbox);
    if (((PrimaryDrawerItem) drawerItem).getName().getText().equals(pSentBox.getName().getText()))
        drawer.setSelection(pSentBox);
    if (((PrimaryDrawerItem) drawerItem).getName().getText().equals(pSmartBox.getName().getText()))
        drawer.setSelection(pSmartBox);
    if (((PrimaryDrawerItem) drawerItem).getName().getText().equals(pTrashBox.getName().getText()))
        drawer.setSelection(pTrashBox);
}
 
Example 44
Project: hochwasser-app   File: MainDrawerActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setSupportActionBar(toolbar);

	// show first fragment
	showFragment(new NewsFragment(), false);
	toolbar.setTitle(R.string.nav_home);
	visibleFragmentId = ID_NEWS;

	// setup account in nav drawer
	Account account = loginManager.getAccount().get();
	AccountHeader accountHeader = new AccountHeaderBuilder()
			.withActivity(this)
			.withHeaderBackground(R.drawable.drawer_background)
			.addProfiles(new ProfileDrawerItem().withName(account.name).withIcon(getResources().getDrawable(R.drawable.ic_duck)))
			.withSelectionListEnabledForSingleProfile(false)
			.withProfileImagesClickable(false)
			.withHeaderBackgroundScaleType(ImageView.ScaleType.CENTER_CROP)
			.build();

	// setup actual nav drawer
	drawer = new DrawerBuilder()
			.withActivity(this)
			.withToolbar(toolbar)
			.withAccountHeader(accountHeader)
			.addDrawerItems(
					new PrimaryDrawerItem().withName(R.string.nav_home).withIconTintingEnabled(true).withIcon(R.drawable.ic_home).withIdentifier(ID_NEWS),
					new PrimaryDrawerItem().withName(R.string.nav_alarms).withIconTintingEnabled(true).withIcon(R.drawable.ic_alert).withIdentifier(ID_ALARMS),
					new PrimaryDrawerItem().withName(R.string.nav_stations).withIconTintingEnabled(true).withIcon(R.drawable.ic_gauge).withIdentifier(ID_STATION_LEVELS),
					new PrimaryDrawerItem().withName(R.string.nav_river_graphs).withIconTintingEnabled(true).withIcon(R.drawable.ic_chart).withIdentifier(ID_RIVER_GRAPHS)
			)
			.addStickyDrawerItems(
					new PrimaryDrawerItem().withName(R.string.nav_settings).withIconTintingEnabled(true).withIcon(R.drawable.ic_settings).withIdentifier(ID_SETTINGS),
					new PrimaryDrawerItem().withName(R.string.nav_feedback).withIconTintingEnabled(true).withIcon(R.drawable.ic_email).withIdentifier(ID_FEEDBACK)
			)
			.withOnDrawerItemClickListener(this)
			.build();
}
 
Example 45
Project: hacker-news-android   File: MainViewModel.java   Source Code and License 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 46
Project: wifi_backend   File: MainActivity.java   Source Code and License 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 47
Project: Local-GSM-Backend   File: MainActivity.java   Source Code and License 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 48
Project: calendula   File: LeftDrawerMgr.java   Source Code and License 5 votes vote down vote up
private void addCalendarItem() {
    drawer.addItemAtPosition(new PrimaryDrawerItem()
            .withName(R.string.title_activity_pickup_calendar_short)
            .withIcon(IconUtils.icon(home, CommunityMaterial.Icon.cmd_calendar_check, R.color.black).alpha(110))
            .withEnabled(true)
            .withIdentifier(CALENDAR), 7);
}
 
Example 49
Project: WatchIt   File: BaseActivity.java   Source Code and License 4 votes vote down vote up
private void setupDrawer() {
    drawer = new DrawerBuilder()
            .withActivity(this)
            .withTranslucentStatusBar(true)
            .withFooterDivider(false)
            .withStickyFooter(R.layout.nav_footer)
            .addDrawerItems(
                    new SectionDrawerItem().withName("Explore").withDivider(false),
                    new PrimaryDrawerItem().withName("Movies")
                            .withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_movie_alt).sizeDp(24)),
                    new PrimaryDrawerItem().withName("TV Series")
                            .withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_tv_alt_play).sizeDp(24)),
                    new PrimaryDrawerItem().withName("Watch Later")
                            .withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_calendar_check).sizeDp(24)),
                    new SectionDrawerItem().withName("About"),
                    new SecondaryDrawerItem().withName("Settings")
                            .withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_settings).sizeDp(24).colorRes(R.color.colorLightGray)),
                    new SecondaryDrawerItem().withName("Open Source Acknowledgements")
                            .withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_github_alt).sizeDp(24).colorRes(R.color.colorLightGray)))
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    Util.debugLog(TAG, "onItemClick: Position " + position);
                    switch (position) {
                        case 1:
                            Bundle bundleMovies = new Bundle();
                            bundleMovies.putBoolean("IS_MOVIES", true);
                            switchFragment(new MainFragment(), bundleMovies, "MOVIES_FRAG");
                            break;
                        case 2:
                            Bundle bundleTv = new Bundle();
                            bundleTv.putBoolean("IS_MOVIES", false);
                            switchFragment(new MainFragment(), bundleTv, "TV_FRAG");
                            break;
                        case 3:
                            Intent watchLaterIntent = new Intent(BaseActivity.this, WatchLaterActivity.class);
                            startActivity(watchLaterIntent);
                            break;
                        case 5:
                            switchFragment(new SettingsFragment(), null, "SETTINGS_FRAG");
                            break;
                        case 6:
                            switchFragment(new OpenSourceFragment(), null, "OPEN_SOURCE_FRAG");
                            break;
                    }
                    return false;
                }
            })
            .build();
}
 
Example 50
Project: androidgithub   File: SearchActivity.java   Source Code and License 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.distance_180dp)
            .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.mipmap.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) {
                    Logger.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.setOnItemClickListener(mItemtClickListener);
    mAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
    mRepoList.setAdapter(mAdapter);

    // default is null
    mCurrentLang = "";
}
 
Example 51
Project: librus-client   File: MainActivity.java   Source Code and License 4 votes vote down vote up
private PrimaryDrawerItem getLuckyNumberDrawerItem(LuckyNumber luckyNumber) {
    return new PrimaryDrawerItem().withIconTintingEnabled(true).withSelectable(false)
            .withName(getString(R.string.lucky_number) + ": " + (luckyNumber == null ? 0 : luckyNumber.luckyNumber()))
            .withIcon(R.drawable.ic_sentiment_very_satisfied_black_24dp)
            .withOnDrawerItemClickListener(showLuckyNumber(luckyNumber));
}
 
Example 52
Project: amrita-info-desk   File: Landing.java   Source Code and License 4 votes vote down vote up
@SuppressLint("ShortAlarm")
@Override
public void init(Bundle savedInstanceState) {
    setupLayout(R.layout.activity_landing, "Amrita Info Desk");
    toolbar.setBackgroundColor(getResources().getColor(R.color.white));
    setRecentHeaderColor(getResources().getColor(R.color.white));
    checkForUpdates();

    AccountHeader headerResult = new AccountHeaderBuilder()
            .withActivity(this)
            .withHeaderBackground(R.drawable.header)
            .addProfiles(
                    new ProfileDrawerItem().withName("Amrita Info Desk").withEmail("Version " + BuildConfig.VERSION_NAME).setSelectable(false)
            )
            .withSelectionListEnabledForSingleProfile(false)
            .build();

    headerResult.getHeaderBackgroundView().setColorFilter(Color.rgb(170, 170, 170), android.graphics.PorterDuff.Mode.MULTIPLY);
    Drawer result = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withAccountHeader(headerResult)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName("Home").withIcon(R.drawable.ic_action_home).withCheckable(false),
                    new PrimaryDrawerItem().withName("News").withIcon(R.drawable.ic_action_speaker_notes).withCheckable(false),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName("About the app").withIcon(R.drawable.ic_action_info).withCheckable(false),
                    new PrimaryDrawerItem().withName("Invite").withIcon(R.drawable.ic_action_info).withCheckable(false),
                    new PrimaryDrawerItem().withName("Settings").withIcon(R.drawable.ic_action_settings).withCheckable(false)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) {
                    switch (position) {
                        case 1:
                            startActivity(new Intent(baseContext, NewsActivity.class));
                            break;
                        case 3:
                            startActivity(new Intent(baseContext, App.class));
                            break;
                        case 4:
                            Intent intent = new AppInviteInvitation.IntentBuilder("Invite users")
                                    .setMessage("Spread the word to fellow Amrititans")
                                    .setCallToActionText("Invite")
                                    .build();
                            startActivityForResult(intent, 211);
                            break;
                        case 5:
                            startActivity(new Intent(baseContext, SettingsActivity.class));
                            break;
                    }
                    return false;
                }
            })
            .withCloseOnClick(true)
            .build();

    setupGrid();

    File aumsCookieFile = new File(getApplicationContext().getFilesDir().getParent() + "/shared_prefs/" + PersistentCookieStore.AUMS_COOKIE_PREFS + ".xml");
    if (aumsCookieFile.exists()) {
        aumsCookieFile.delete();
    }

    File gpmsCookieFile = new File(getApplicationContext().getFilesDir().getParent() + "/shared_prefs/" + PersistentCookieStore.GPMS_COOKIE_PREFS + ".xml");
    if (gpmsCookieFile.exists()) {
        gpmsCookieFile.delete();
    }

    AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarm.set(
            AlarmManager.RTC_WAKEUP,
            System.currentTimeMillis() + (1000 * 60 * 60 * 6),
            PendingIntent.getService(this, 0, new Intent(this, NewsUpdateService.class), 0)
    );

    startService(new Intent(baseContext, NewsUpdateService.class));
}
 
Example 53
Project: idec-mobile   File: ManageDatabaseActivity.java   Source Code and License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(Config.appTheme);
    super.onCreate(savedInstance);

    setContentView(R.layout.activity_tools);
    ButterKnife.bind(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    boolean isTablet = SimpleFunctions.isTablet(this);
    Intent gotIntent = getIntent();

    if (savedInstanceState != null) {
        shouldOpenDrawer = savedInstanceState.getBoolean("openDrawer");
        savedInstance = savedInstanceState;
    }

    database_item = new PrimaryDrawerItem().withIdentifier(1).withName(R.string.database).withIcon(GoogleMaterial.Icon.gmd_storage);
    blacklist_item = new PrimaryDrawerItem().withIdentifier(2).withName(R.string.blacklist).withIcon(GoogleMaterial.Icon.gmd_delete);
    xfile_item = new PrimaryDrawerItem().withIdentifier(3).withName(R.string.node_files).withIcon(GoogleMaterial.Icon.gmd_folder_shared);

    DrawerBuilder drawerBuilder = new DrawerBuilder()
            .withActivity(this)
            .withActionBarDrawerToggleAnimated(true)
            .withTranslucentStatusBar(false)
            .addDrawerItems(database_item, blacklist_item, xfile_item)
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    if (drawerItem != null) {
                        int itemId = (int) drawerItem.getIdentifier();

                        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
                        android.support.v4.app.FragmentTransaction transaction = fm.beginTransaction();
                        android.support.v4.app.Fragment fragm;

                        int title;

                        switch (itemId) {
                            case 1:
                                fragm = new Database_Fragment();
                                title = R.string.database;
                                break;
                            case 2:
                                fragm = new Blacklist_Fragment();
                                title = R.string.blacklist;
                                break;
                            default:
                            case 3:
                                fragm = new xfile_Fragment();
                                title = R.string.node_files;
                                break;
                        }

                        transaction.replace(R.id.filelist_fragment, fragm);
                        transaction.commit();
                        SimpleFunctions.setActivityTitle(ManageDatabaseActivity.this, getString(title));
                    }
                    return false;
                }
            });

    if (isTablet) {
        drawer = drawerBuilder.buildView();
        ((ViewGroup) findViewById(R.id.drawer_holder)).addView(drawer.getSlider());
    } else {
        drawer = drawerBuilder.withToolbar(toolbar).build();
    }

    if (savedInstanceState == null) {
        firstFragment = Database_Fragment.newInstance();
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.filelist_fragment, firstFragment).commit();
        SimpleFunctions.setActivityTitle(ManageDatabaseActivity.this, getString(R.string.database));
    }
}
 
Example 54
Project: GithubApp   File: SearchActivity.java   Source Code and License 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 55
Project: TrinityLocker   File: MainSettingsActivity.java   Source Code and License 4 votes vote down vote up
private void createDrawer(Toolbar toolbar) {
	result = new DrawerBuilder()
			.withActivity(this)
			.withToolbar(toolbar)
			.withAccountHeader(header)
			.addDrawerItems(
					new PrimaryDrawerItem().withName(R.string.nav_lock_profile_text).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_view_carousel).color(ContextCompat.getColor(getApplicationContext(), R.color.material_drawer_dark_primary_icon))).withIdentifier(Constants.navLocker),
					new PrimaryDrawerItem().withName(R.string.nav_visual_text).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_photo_library).color(ContextCompat.getColor(getApplicationContext(), R.color.material_drawer_dark_primary_icon))).withIdentifier(Constants.navVisual),
					new PrimaryDrawerItem().withName(R.string.nav_notify_text).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_notifications_active).color(ContextCompat.getColor(getApplicationContext(), R.color.material_drawer_dark_primary_icon))).withIdentifier(Constants.navNotify),
					new PrimaryDrawerItem().withName(R.string.nav_security_text).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_lock).color(ContextCompat.getColor(getApplicationContext(), R.color.material_drawer_dark_primary_icon))).withIdentifier(Constants.navSecurity),
					new PrimaryDrawerItem().withName(R.string.nav_misc_text).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_list).color(ContextCompat.getColor(getApplicationContext(), R.color.material_drawer_dark_primary_icon))).withIdentifier(Constants.navMisc),
					new DividerDrawerItem(),
					new PrimaryDrawerItem().withName(R.string.nav_tips_tricks_text).withIdentifier(Constants.navTips),
					new PrimaryDrawerItem().withName(R.string.nav_backup_restore_text).withIdentifier(Constants.navBackup),
					new PrimaryDrawerItem().withName(R.string.nav_about_text).withIdentifier(Constants.navAbout)
			)
			.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
				@Override
				public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
					Fragment fragment = null;
					FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
					Intent intent = null;
					if (drawerItem.getIdentifier() == Constants.navLocker) {
						fragment = new LockProfilePref();
					} else if (drawerItem.getIdentifier() == Constants.navVisual) {
						//fragment = new VisualOptionFragment();
					} else if (drawerItem.getIdentifier() == Constants.navNotify) {
						//fragment = new NotificationOptionFragment();
					} else if (drawerItem.getIdentifier() == Constants.navSecurity) {
						//fragment = new SecurityOptionFragment();
					} else if (drawerItem.getIdentifier() == Constants.navMisc) {
						//fragment = new MiscOptionFragment();
					} else if (drawerItem.getIdentifier() == Constants.navTips) {

					} else if (drawerItem.getIdentifier() == Constants.navBackup) {

					} else if (drawerItem.getIdentifier() == Constants.navAbout) {
						intent = new Intent(MainSettingsActivity.this, AboutAppActivity.class);
					}

					//Execute the fragments/intents when selected
					if (fragment != null) {
						fragmentTransaction.replace(R.id.main_settings_container, fragment).commit();
					}

					if (intent != null) {
						MainSettingsActivity.this.startActivity(intent);
					}

					return false;
				}
			})
			.build();

	result.setSelection(Constants.navLocker, true);
}
 
Example 56
Project: MaterialDrawer   File: CollapsingToolbarActivity.java   Source Code and License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_collapsing_toolbar);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbarLayout.setTitle(getString(R.string.drawer_item_collapsing_toolbar_drawer));

    headerResult = new AccountHeaderBuilder()
            .withActivity(this)
            .withCompactStyle(false)
            .withHeaderBackground(R.drawable.header)
            .withSavedInstance(savedInstanceState)
            .build();

    result = new DrawerBuilder()
            .withActivity(this)
            .withAccountHeader(headerResult)
            .withToolbar(toolbar)
            .withFullscreen(true)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new SectionDrawerItem().withName(R.string.drawer_item_section_header),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn)
            )
            .withSavedInstance(savedInstanceState)
            .build();

    fillFab();
    loadBackdrop();
}
 
Example 57
Project: MaterialDrawer   File: NonTranslucentDrawerActivity.java   Source Code and License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    //supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_nontranslucent);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.drawer_item_non_translucent_status_drawer);

    // Create a few sample profile
    result = new DrawerBuilder()
            .withActivity(this)
            .withTranslucentStatusBar(false)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new SectionDrawerItem().withName(R.string.drawer_item_section_header),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    if (drawerItem instanceof Nameable) {
                        Toast.makeText(NonTranslucentDrawerActivity.this, ((Nameable) drawerItem).getName().getText(NonTranslucentDrawerActivity.this), Toast.LENGTH_SHORT).show();
                    }
                    return false;
                }
            })
            .withSelectedItemByPosition(2)
            .withSavedInstance(savedInstanceState)
            .build();

    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
 
Example 58
Project: MaterialDrawer   File: FullscreenDrawerActivity.java   Source Code and License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_fullscreen_dark_toolbar);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setBackgroundColor(Color.BLACK);
    toolbar.getBackground().setAlpha(90);
    getSupportActionBar().setTitle(R.string.drawer_item_fullscreen_drawer);

    //Create the drawer
    result = new DrawerBuilder()
            .withActivity(this)
            .withFullscreen(true)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    //add some more items to get a scrolling list
                    new SectionDrawerItem().withName(R.string.drawer_item_section_header),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn),
                    new SectionDrawerItem().withName(R.string.drawer_item_section_header),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye)
            )
            .withSavedInstance(savedInstanceState)
            .build();

    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);

    /*
    //USE THIS CODE TO GET A FULL TRANSPARENT STATUS BAR
    //YOU HAVE TO UNCOMMENT THE setWindowFlag too.
    if (Build.VERSION.SDK_INT >= 19 && Build.VERSION.SDK_INT < 21) {
        setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, true);
    }
    if (Build.VERSION.SDK_INT >= 19) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }
    if (Build.VERSION.SDK_INT >= 21) {
        setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    */

    if (Build.VERSION.SDK_INT >= 19) {
        result.getDrawerLayout().setFitsSystemWindows(false);
    }
}
 
Example 59
Project: MaterialDrawer   File: AdvancedActivity.java   Source Code and License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.drawer_item_advanced_drawer);

    // Create a few sample profile
    profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("[email protected]").withIcon(getResources().getDrawable(R.drawable.profile));
    profile2 = new ProfileDrawerItem().withName("Max Muster").withEmail("[email protected]").withIcon(getResources().getDrawable(R.drawable.profile2)).withIdentifier(2);
    profile3 = new ProfileDrawerItem().withName("Felix House").withEmail("[email protected]").withIcon(getResources().getDrawable(R.drawable.profile3));
    profile4 = new ProfileDrawerItem().withName("Mr. X").withEmail("[email protected]").withIcon(getResources().getDrawable(R.drawable.profile4)).withIdentifier(4);
    profile5 = new ProfileDrawerItem().withName("Batman").withEmail("[email protected]").withIcon(getResources().getDrawable(R.drawable.profile5));

    // Create the AccountHeader
    buildHeader(false, savedInstanceState);

    //Create the drawer
    result = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home),
                    //here we use a customPrimaryDrawerItem we defined in our sample app
                    //this custom DrawerItem extends the PrimaryDrawerItem so it just overwrites some methods
                    new OverflowMenuDrawerItem().withName(R.string.drawer_item_menu_drawer_item).withDescription(R.string.drawer_item_menu_drawer_item_desc).withMenu(R.menu.fragment_menu).withOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                        @Override
                        public boolean onMenuItemClick(MenuItem item) {
                            Toast.makeText(AdvancedActivity.this, item.getTitle(), Toast.LENGTH_SHORT).show();
                            return false;
                        }
                    }).withIcon(GoogleMaterial.Icon.gmd_filter_center_focus),
                    new CustomPrimaryDrawerItem().withBackgroundRes(R.color.accent).withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withDescription("This is a description").withIcon(FontAwesome.Icon.faw_eye),
                    new CustomUrlPrimaryDrawerItem().withName(R.string.drawer_item_fragment_drawer).withDescription(R.string.drawer_item_fragment_drawer_desc).withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460"),
                    new SectionDrawerItem().withName(R.string.drawer_item_section_header),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cart_plus),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_database).withEnabled(false),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withSelectedIconColor(Color.RED).withIconTintingEnabled(true).withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_plus).actionBar().paddingDp(5).colorRes(R.color.material_drawer_dark_primary_text)).withTag("Bullhorn"),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false)
            ) // add the items we want to use with our Drawer
            .withOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() {
                @Override
                public boolean onNavigationClickListener(View clickedView) {
                    //this method is only called if the Arrow icon is shown. The hamburger is automatically managed by the MaterialDrawer
                    //if the back arrow is shown. close the activity
                    AdvancedActivity.this.finish();
                    //return true if we have consumed the event
                    return true;
                }
            })
            .addStickyDrawerItems(
                    new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog).withIdentifier(10),
                    new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github)
            )
            .withSavedInstance(savedInstanceState)
            .build();


}
 
Example 60
Project: facepunchdroid   File: MainActivity.java   Source Code and License 4 votes vote down vote up
protected void addDrawerItems() {

        //if you want to update the items at a later time it is recommended to keep it in a variable
        PrimaryDrawerItem nav_home = new PrimaryDrawerItem().withIdentifier(1).withName(getString(R.string.nav_home)).withIcon(GoogleMaterial.Icon.gmd_home).withSelectable(false);
        PrimaryDrawerItem nav_events = new PrimaryDrawerItem().withIdentifier(2).withName(getString(R.string.nav_events)).withIcon(GoogleMaterial.Icon.gmd_event).withSelectable(false);
        PrimaryDrawerItem nav_popular = new PrimaryDrawerItem().withIdentifier(3).withName(getString(R.string.nav_popular)).withIcon(GoogleMaterial.Icon.gmd_favorite).withSelectable(false);
        PrimaryDrawerItem nav_read = new PrimaryDrawerItem().withIdentifier(4).withName(getString(R.string.nav_read)).withIcon(GoogleMaterial.Icon.gmd_markunread_mailbox).withSelectable(false);
        PrimaryDrawerItem nav_search = new PrimaryDrawerItem().withIdentifier(5).withName(getString(R.string.nav_search)).withIcon(GoogleMaterial.Icon.gmd_search).withSelectable(false);
        PrimaryDrawerItem nav_messages = new PrimaryDrawerItem().withIdentifier(6).withName(getString(R.string.nav_messages)).withIcon(GoogleMaterial.Icon.gmd_mail_outline).withSelectable(false);
        PrimaryDrawerItem nav_cpanel = new PrimaryDrawerItem().withIdentifier(7).withName(getString(R.string.nav_controlpanel)).withIcon(GoogleMaterial.Icon.gmd_build).withSelectable(false);
        PrimaryDrawerItem nav_ticker = new PrimaryDrawerItem().withIdentifier(12).withName(getString(R.string.nav_ticker)).withIcon(GoogleMaterial.Icon.gmd_link).withSelectable(false);

        PrimaryDrawerItem nav_settings = new PrimaryDrawerItem().withIdentifier(8).withName(getString(R.string.action_settings)).withIcon(GoogleMaterial.Icon.gmd_settings).withSelectable(false);

        if (sharedPref.getBoolean("isLoggedIn", false)) {
            nav_logout = new PrimaryDrawerItem().withIdentifier(9).withName(getString(R.string.nav_logout)).withIcon(GoogleMaterial.Icon.gmd_lock_open).withSelectable(false).withEnabled(true);
        } else {
            nav_logout = new PrimaryDrawerItem().withIdentifier(9).withName(getString(R.string.nav_logout)).withIcon(GoogleMaterial.Icon.gmd_lock_open).withSelectable(false).withEnabled(false);
        }


        PrimaryDrawerItem nav_donate = new PrimaryDrawerItem().withIdentifier(10).withName(getString(R.string.nav_donate)).withIcon(GoogleMaterial.Icon.gmd_card_giftcard).withSelectable(false);


        drawer.addItems(
                nav_home,
                nav_events,
                nav_popular,
                nav_read,
                nav_search,
                nav_messages,
                nav_cpanel,
                nav_ticker
        );

        // Get Pinned items
        RealmResults<PinnedItem> pinnedItems = realm.where(PinnedItem.class).findAll();

        Log.d("Pitem list", pinnedItems.toString());

        if (pinnedItems.size() > 0) {
            drawer.addItem(new SectionDrawerItem().withName(getString(R.string.nav_pinnedpages)));
            for (PinnedItem pitem : pinnedItems) {

                drawer.addItem(new PrimaryDrawerItem().withName(pitem.getTitle()).withSelectable(false).withTag(pitem.getUrl()).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {

                        if (sharedPref.getBoolean("settings_pagepinning_goto_newest_post", true)) {
                            if (drawerItem.getTag().toString().contains("?")) {
                                webview.loadUrl(drawerItem.getTag().toString() + "&goto=newpost");
                            } else {
                                webview.loadUrl(drawerItem.getTag().toString() + "?goto=newpost");
                            }
                            return false;
                        }

                        webview.loadUrl(drawerItem.getTag().toString());
                        return false;
                    }
                }));
            }
            drawer.addItem(new SecondaryDrawerItem().withName(getString(R.string.nav_editpinnedpages)).withIcon(GoogleMaterial.Icon.gmd_edit).withIdentifier(11).withSelectable(false));
        }

        drawer.addItem(new DividerDrawerItem());
        drawer.addItem(nav_settings);
        drawer.addItem(nav_logout);
        drawer.addItem(new DividerDrawerItem());
        drawer.addItem(nav_donate);
    }