Java Code Examples for com.mikepenz.materialdrawer.model.interfaces.IDrawerItem#getIdentifier()

The following examples show how to use com.mikepenz.materialdrawer.model.interfaces.IDrawerItem#getIdentifier() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From ChipsLayoutManager with Apache License 2.0 6 votes vote down vote up
private boolean onDrawerItemClickListener(View view, int position, IDrawerItem drawerItem) {
    int id = (int) drawerItem.getIdentifier();
    switch (id) {
        case 1:
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.fragmentContainer, ItemsFragment.newInstance())
                    .commit();
            drawer.closeDrawer();
            break;
        case 2:
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.fragmentContainer, BottomSheetFragment.newInstance())
                    .commit();
            drawer.closeDrawer();
            break;
    }
    return true;
}
 
Example 2
Source File: MiniDrawer.java    From MaterialDrawer-Xamarin with Apache License 2.0 6 votes vote down vote up
/**
 * call this method to trigger the onItemClick on the MiniDrawer
 *
 * @param selectedDrawerItem
 * @return
 */
public boolean onItemClick(IDrawerItem selectedDrawerItem) {
    //We only need to clear if the new item is selectable
    if (selectedDrawerItem.isSelectable()) {
        //crossfade if we are cross faded
        if (mCrossFader != null) {
            if (mCrossFader.isCrossfaded()) {
                mCrossFader.crossfade();
            }
        }

        //get the identifier
        int identifier = selectedDrawerItem.getIdentifier();

        //update everything
        setSelection(identifier);

        return false;
    } else {
        return true;
    }
}
 
Example 3
Source File: MainActivity.java    From IdeaTrackerPlus with MIT License 5 votes vote down vote up
@Override
public void onCheckedChanged(IDrawerItem drawerItem, CompoundButton buttonView, boolean isChecked) {

    int id = (int) drawerItem.getIdentifier();
    switch (id) {

        case ID_TOGGLE_DONE:
            toggleDoneTab();
            break;

        case ID_TOGGLE_BIG_TEXT:
            if (isChecked) {
                HorizontalAdapter.setBigText(true);
                mTinyDB.putBoolean(getString(R.string.big_text_pref), true);
                DatabaseHelper.notifyAllLists();

            } else {
                HorizontalAdapter.setBigText(false);
                mTinyDB.putBoolean(getString(R.string.big_text_pref), false);
                DatabaseHelper.notifyAllLists();
            }
            break;

        case ID_DARK_THEME:
            changeDarkTheme(isChecked);
            break;
    }

}
 
Example 4
Source File: BaseDrawerAdapter.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
@Override
public long getItemId(int position) {
    IDrawerItem item = getItem(position);
    if (item != null && item.getIdentifier() != -1) {
        return item.getIdentifier();
    }
    return super.getItemId(position);
}
 
Example 5
Source File: Drawer.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * get the current selected item identifier
 *
 * @return
 */
public int getCurrentSelection() {
    IDrawerItem drawerItem = mDrawerBuilder.getDrawerItem(mDrawerBuilder.mCurrentSelection);
    if (drawerItem != null) {
        return drawerItem.getIdentifier();
    }
    return -1;
}
 
Example 6
Source File: DrawerUtils.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * gets the drawerItem with the specific identifier from a drawerItem list
 *
 * @param drawerItems
 * @param identifier
 * @return
 */
public static IDrawerItem getDrawerItem(List<IDrawerItem> drawerItems, int identifier) {
    if (identifier >= 0) {
        for (IDrawerItem drawerItem : drawerItems) {
            if (drawerItem.getIdentifier() == identifier) {
                return drawerItem;
            }
        }
    }
    return null;
}
 
Example 7
Source File: MiniDrawer.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * update a MiniDrawerItem (after updating the main Drawer) via its identifier
 *
 * @param identifier the identifier of the item which was updated
 */
public void updateItem(int identifier) {
    if (mDrawer != null && mDrawerAdapter != null && mDrawerAdapter.getDrawerItems() != null && identifier != -1) {
        IDrawerItem drawerItem = DrawerUtils.getDrawerItem(getDrawerItems(), identifier);
        for (int i = 0; i < mDrawerAdapter.getDrawerItems().size(); i++) {
            if (mDrawerAdapter.getDrawerItems().get(i).getIdentifier() == drawerItem.getIdentifier()) {
                IDrawerItem miniDrawerItem = generateMiniDrawerItem(drawerItem);
                if (miniDrawerItem != null) {
                    mDrawerAdapter.setDrawerItem(i, miniDrawerItem);
                }
            }
        }
    }
}
 
Example 8
Source File: SheetMusicActivity.java    From MidiSheetMusic-Android with GNU General Public License v3.0 4 votes vote down vote up
/** Handle clicks on the drawer menu */
public boolean drawerItemClickListener(IDrawerItem item) {
    switch ((int)item.getIdentifier()) {
        case R.id.song_settings:
            changeSettings();
            drawer.closeDrawer();
            break;
        case R.id.save_images:
            showSaveImagesDialog();
            drawer.closeDrawer();
            break;
        case ID_LOOP_START:
            // Note that we display the measure numbers starting at 1,
            // but the actual playMeasuresInLoopStart field starts at 0.
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(R.string.play_measures_in_loop_start);
            String[] items = makeStringList(1, options.lastMeasure + 1);
            builder.setItems(items, (dialog, i) -> {
                options.playMeasuresInLoopStart = Integer.parseInt(items[i]) - 1;
                // Make sure End is not smaller than Start
                if (options.playMeasuresInLoopStart > options.playMeasuresInLoopEnd) {
                    options.playMeasuresInLoopEnd = options.playMeasuresInLoopStart;
                    drawer.updateBadge(ID_LOOP_END, new StringHolder(items[i]));
                }
                ((SecondaryDrawerItem) item).withBadge(items[i]);
                drawer.updateItem(item);
            });
            AlertDialog alertDialog = builder.create();
            alertDialog.show();
            alertDialog.getListView().setSelection(options.playMeasuresInLoopStart);
            break;
        case ID_LOOP_END:
            // Note that we display the measure numbers starting at 1,
            // but the actual playMeasuresInLoopEnd field starts at 0.
            builder = new AlertDialog.Builder(this);
            builder.setTitle(R.string.play_measures_in_loop_end);
            items = makeStringList(1, options.lastMeasure + 1);
            builder.setItems(items, (dialog, i) -> {
                options.playMeasuresInLoopEnd = Integer.parseInt(items[i]) - 1;
                // Make sure End is not smaller than Start
                if (options.playMeasuresInLoopStart > options.playMeasuresInLoopEnd) {
                    options.playMeasuresInLoopStart = options.playMeasuresInLoopEnd;
                    drawer.updateBadge(ID_LOOP_START, new StringHolder(items[i]));
                }
                ((SecondaryDrawerItem) item).withBadge(items[i]);
                drawer.updateItem(item);
            });
            alertDialog = builder.create();
            alertDialog.show();
            alertDialog.getListView().setSelection(options.playMeasuresInLoopEnd);
            break;
    }
    return true;
}
 
Example 9
Source File: LeftDrawerManager.java    From timecat with Apache License 2.0 4 votes vote down vote up
@Override
    public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {

        int identifier = iDrawerItem.getIdentifier();

        switch (identifier) {
            case HOME:
//                mainActivity.showPagerItem(0, false);
                break;
            case USERS:
                Intent intent = new Intent(mainActivity, LoginActivity.class);
                mainActivity.startActivityForResult(intent, REQUEST_LOGIN);
                mainActivity.overridePendingTransition(R.anim.push_left_to_right, R.anim.push_right_to_left);
                drawer.setSelection(HOME, false);
                break;

            case SCHEDULES:
                mainActivity.showPagerItem(0, false);
                break;
            case ROUTINES:
                mainActivity.showPagerItem(1, false);
                break;
            case NOTES:
                mainActivity.showPagerItem(2, false);
                break;
            case PLANS:
                mainActivity.showPagerItem(3, false);
                break;
            case CALENDAR:
//                launchActivity(new Intent(mainActivity, CalendarActivity.class));
                drawer.setSelection(HOME, false);
                break;
            case POMODOROS:
                launchActivity(new Intent(mainActivity, PomodoroActivity.class));
                break;

            case STATISTICS:
                launchActivity(new Intent(mainActivity, StatisticalActivity.class));
                drawer.setSelection(HOME, false);
                break;
            case ACHIEVEMENTS:
                launchActivity(new Intent(mainActivity, AchievementActivity.class));
                drawer.setSelection(HOME, false);
                break;
            case THEME:
                //mainActivity.showTutorial();
//                launchActivity(new Intent(mainActivity, MaterialIntroActivity.class));
                DialogThemeFragment themeDialog = new DialogThemeFragment();
                themeDialog.setClickListener(mainActivity);
                themeDialog.show(mainActivity.getSupportFragmentManager(), "theme");
                drawer.setSelection(HOME, false);
                break;
            case SETTINGS:
                launchActivity(new Intent(mainActivity, SettingActivity.class));
                drawer.setSelection(HOME, false);
                break;

            case ABOUT:
                launchActivity(new Intent(mainActivity, AboutActivity.class));
                drawer.setSelection(HOME, false);
                break;
            default:
                return false;
        }
//        drawer.closeDrawer();
        return true;
    }
 
Example 10
Source File: MainActivity.java    From ETSMobile-Android2 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
    FragmentManager fm = getSupportFragmentManager();

    if (drawerItem != null) {

        switch ((int) drawerItem.getIdentifier()) {
            case PROFILE_ITEM:
                goToFragment(new ProfilFragment(), ProfilFragment.class.getName());
                break;
            case SCHEDULE_ITEM:
                goToFragment(new HoraireFragment(), HoraireFragment.class.getName());
                break;
            case TODAY_ITEM:
                goToFragment(new TodayFragment(), TodayFragment.class.getName());
                break;
            case MOODLE_ITEM:
                goToFragment(new MoodleFragment(), MoodleFragment.class.getName());
                break;
            case COURSE_ITEM:
                goToFragment(new NotesFragment(), NotesFragment.class.getName());
                break;
            case MONETS_ITEM:
                Utility.openChromeCustomTabs(MainActivity.this, getString(R.string.url_mon_ets));
                break;
            case BANDWIDTH_ITEM:
                goToFragment(new BandwidthFragment(), BandwidthFragment.class.getName());
                break;
            case NEWS_ITEM:
                goToFragment(new NewsFragment(), NewsFragment.class.getName());
                break;
            case LIBRARY_ITEM:
                Utility.openChromeCustomTabs(MainActivity.this, getString(R.string.url_biblio));
                break;
            case DIRECTORY_ITEM:
                goToFragment(new BottinFragment(), BottinFragment.class.getName());
                break;
            case SECURITY_ITEM:
                goToFragment(new SecuriteFragment(), SecuriteFragment.class.getName());
                break;
            case FAQ_ITEM:
                Utility.openChromeCustomTabs(MainActivity.this, getString(R.string.url_applets_faq));
                break;
            case ACHIEVEMENTS_ITEM:
                goToFragment(new OtherAppsFragment(), OtherAppsFragment.class.getName());
                break;
            case ABOUT_ITEM:
                goToFragment(new AboutFragment(), AboutFragment.class.getName());
                break;
            case LOGIN:
                prefs.edit().putBoolean(Constants.FIRST_LOGIN, false).apply();
                accountManager.addAccount(Constants.ACCOUNT_TYPE, Constants.AUTH_TOKEN_TYPE, null, null, MainActivity.this, future -> {
                    // Login successful
                    // Recreate the activity to see the changes. using recreate() directly causes some bugs so let's redo it the old way.
                    Intent intent = getIntent();
                    finish();
                    startActivity(intent);
                }, null);
                break;
            case LOGOUT:
                openLogoutDialogAlert();
                break;
            case BETA_VERSION_ITEM:
                goToBetaVersion();
                break;
        }

    }
    return false;
}
 
Example 11
Source File: MainFrameActivity.java    From hipda with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean onItemClick(View view, int position, IDrawerItem iDrawerItem) {

    if (iDrawerItem.getIdentifier() == Constants.DRAWER_NO_ACTION)
        return false;

    switch ((int) iDrawerItem.getIdentifier()) {
        case Constants.DRAWER_SEARCH:
            FragmentUtils.showSimpleListActivity(MainFrameActivity.this, false, SimpleListJob.TYPE_SEARCH);
            break;
        case Constants.DRAWER_NEW_POSTS:
            FragmentUtils.showSimpleListActivity(MainFrameActivity.this, false, SimpleListJob.TYPE_NEW_POSTS);
            break;
        case Constants.DRAWER_MYPOST:
            FragmentUtils.showSimpleListActivity(MainFrameActivity.this, false, SimpleListJob.TYPE_MYPOST);
            break;
        case Constants.DRAWER_MYREPLY:
            FragmentUtils.showSimpleListActivity(MainFrameActivity.this, false, SimpleListJob.TYPE_MYREPLY);
            break;
        case Constants.DRAWER_FAVORITES:
            FragmentUtils.showSimpleListActivity(MainFrameActivity.this, false, SimpleListJob.TYPE_FAVORITES);
            break;
        case Constants.DRAWER_HISTORIES:
            FragmentUtils.showSimpleListActivity(MainFrameActivity.this, false, SimpleListJob.TYPE_HISTORIES);
            break;
        case Constants.DRAWER_SMS:
            FragmentUtils.showSimpleListActivity(MainFrameActivity.this, false, SimpleListJob.TYPE_SMS);
            break;
        case Constants.DRAWER_THREADNOTIFY:
            FragmentUtils.showSimpleListActivity(MainFrameActivity.this, false, SimpleListJob.TYPE_THREAD_NOTIFY);
            break;
        case Constants.DRAWER_SETTINGS:
            Intent intent = new Intent(MainFrameActivity.this, SettingActivity.class);
            ActivityCompat.startActivity(MainFrameActivity.this, intent,
                    FragmentUtils.getAnimBundle(MainFrameActivity.this, false));
            break;
        default:
            int forumId = (int) iDrawerItem.getIdentifier();
            FragmentUtils.showForum(getSupportFragmentManager(), forumId);
            break;
    }

    return false;
}