com.mikepenz.materialdrawer.Drawer Java Examples

The following examples show how to use com.mikepenz.materialdrawer.Drawer. 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: SecondarySwitchDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
@Override
public void bindView(RecyclerView.ViewHolder holder) {
    //get our viewHolder
    final ViewHolder viewHolder = (ViewHolder) holder;

    //bind the basic view parts
    bindViewHelper((BaseViewHolder) holder);

    //handle the switch
    viewHolder.switchView.setOnCheckedChangeListener(null);
    viewHolder.switchView.setChecked(checked);
    viewHolder.switchView.setOnCheckedChangeListener(checkedChangeListener);
    viewHolder.switchView.setEnabled(switchEnabled);

    //add a onDrawerItemClickListener here to be able to check / uncheck if the drawerItem can't be selected
    withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            if (!isSelectable()) {
                checked = !checked;
                viewHolder.switchView.setChecked(checked);
            }

            return false;
        }
    });

    //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
    onPostBindView(this, holder.itemView);
}
 
Example #2
Source File: HomeActivity.java    From wmn-safety with MIT License 5 votes vote down vote up
private void createNavDrawer(Toolbar toolbar) {
    result = new DrawerBuilder()
            .withActivity(this)
            .withAccountHeader(headerResult)
            .withToolbar(toolbar)
            .withSelectedItem(-1)
            .withHasStableIds(true)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName("Trusted Contacts")
                            .withIdentifier(1).withIcon(R.drawable.ic_contact_phone_black_24dp),
                    new PrimaryDrawerItem().withName("Explore")
                            .withIdentifier(2).withIcon(R.drawable.ic_explore_black_24dp),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName("Settings")
                            .withIdentifier(3).withIcon(R.drawable.ic_settings_black_24dp),
                    new PrimaryDrawerItem().withName("Help & Feedback")
                            .withIcon(R.drawable.ic_feedback_black_24dp)
                            .withIdentifier(5),
                    new PrimaryDrawerItem().withName("About")
                            .withIcon(R.drawable.ic_info_outline_black_24dp)
                            .withIdentifier(6),
                    new PrimaryDrawerItem().withName("Rate Us")
                            .withIcon(R.drawable.ic_star_black_24dp)
                            .withIdentifier(7)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    // add click listeners for nav drawer items
                    switch ((int) drawerItem.getIdentifier()) {
                        case 1:
                            startActivity(new Intent(mContext, TrustedContactsActivity.class));
                            break;
                        case 2:
                            startActivity(new Intent(mContext,ExploreActivity.class));
                            break;
                        case 3:
                            startActivity(new Intent(mContext, SettingsActivity.class));
                            break;
                        case 6:
                            startActivity(new Intent(mContext, AboutActivity.class));
                            break;
                        case 7:
                            Toast.makeText(mContext,"Coming soon on Play Store",Toast.LENGTH_SHORT).show();
                    }
                    return false;
                }
            })
            .build();
}
 
Example #3
Source File: ToggleDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
@Override
public void bindView(RecyclerView.ViewHolder holder) {
    //get our viewHolder
    final ViewHolder viewHolder = (ViewHolder) holder;

    //bind the basic view parts
    bindViewHelper((BaseViewHolder) holder);

    //handle the toggle
    viewHolder.toggle.setOnCheckedChangeListener(null);
    viewHolder.toggle.setChecked(checked);
    viewHolder.toggle.setOnCheckedChangeListener(checkedChangeListener);
    viewHolder.toggle.setEnabled(toggleEnabled);

    //add a onDrawerItemClickListener here to be able to check / uncheck if the drawerItem can't be selected
    withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            if (!isSelectable()) {
                checked = !checked;
                viewHolder.toggle.setChecked(checked);
            }

            return false;
        }
    });

    //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
    onPostBindView(this, holder.itemView);
}
 
Example #4
Source File: SecondaryToggleDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
@Override
public void bindView(RecyclerView.ViewHolder holder) {
    //get our viewHolder
    final ViewHolder viewHolder = (ViewHolder) holder;

    //bind the basic view parts
    bindViewHelper((BaseViewHolder) holder);

    //handle the toggle
    viewHolder.toggle.setOnCheckedChangeListener(null);
    viewHolder.toggle.setChecked(checked);
    viewHolder.toggle.setOnCheckedChangeListener(checkedChangeListener);
    viewHolder.toggle.setEnabled(toggleEnabled);

    //add a onDrawerItemClickListener here to be able to check / uncheck if the drawerItem can't be selected
    withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            if (!isSelectable()) {
                checked = !checked;
                viewHolder.toggle.setChecked(checked);
            }

            return false;
        }
    });

    //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
    onPostBindView(this, holder.itemView);
}
 
Example #5
Source File: SwitchDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
@Override
public void bindView(RecyclerView.ViewHolder holder) {
    //get our viewHolder
    final ViewHolder viewHolder = (ViewHolder) holder;

    //bind the basic view parts
    bindViewHelper((BaseViewHolder) holder);

    //handle the switch
    viewHolder.switchView.setOnCheckedChangeListener(null);
    viewHolder.switchView.setChecked(checked);
    viewHolder.switchView.setOnCheckedChangeListener(checkedChangeListener);
    viewHolder.switchView.setEnabled(switchEnabled);

    //add a onDrawerItemClickListener here to be able to check / uncheck if the drawerItem can't be selected
    withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            if (!isSelectable()) {
                checked = !checked;
                viewHolder.switchView.setChecked(checked);
            }

            return false;
        }
    });

    //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
    onPostBindView(this, holder.itemView);
}
 
Example #6
Source File: MainActivity.java    From minx with MIT License 5 votes vote down vote up
private void setUpDrawer() {

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

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

    }
 
Example #7
Source File: MainActivity.java    From ShoppingList with Apache License 2.0 5 votes vote down vote up
private void buildDrawer() {
    result = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withHeader(R.layout.drawer_header)
            .withTranslucentStatusBar(false)
            .withActionBarDrawerToggle(true)
            .withActionBarDrawerToggleAnimated(false)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.nav_item_home).withTag(CONSTS.TAG_LIST).withIcon(R.drawable.ic_toc_black_),
                    new PrimaryDrawerItem().withName(R.string.nav_item_cached).withTag(CONSTS.TAG_CACHED).withIcon(R.drawable.ic_toc_black_),
                    new PrimaryDrawerItem().withName(R.string.nav_item_favorites).withTag(CONSTS.TAG_FAVORITES).withIcon(R.drawable.ic_star_rate_black)
            )
            .addStickyDrawerItems(
                    new SecondaryDrawerItem().withName(R.string.nav_item_about).withTag(CONSTS.TAG_ABOUT).withIcon(R.drawable.ic_action_about),
                    new SecondaryDrawerItem().withName(R.string.nav_item_settings).withTag(CONSTS.TAG_SETTINGS).withIcon(R.drawable.ic_action_settings)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    fragmentSelector(Integer.parseInt(drawerItem.getTag().toString()));
                    return false;
                }
            })
            .withSelectedItem(0)
            .build();
}
 
Example #8
Source File: UtilsUI.java    From Moticons with GNU General Public License v3.0 4 votes vote down vote up
public static Drawer showNavigationDrawer(final Context context, Toolbar toolbar, final MoticonAdapter moticonAdapter, final MoticonAdapter moticonPositiveAdapter, final MoticonAdapter moticonNegativeAdapter, final MoticonAdapter moticonFunnyAdapter, final MoticonAdapter moticonAnimalsAdapter, final MoticonAdapter moticonSpecialAdapter, final RecyclerView recyclerView) {
    Activity activity = (Activity) context;

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

                    return false;
                }
            }).build();
}
 
Example #9
Source File: MainActivity.java    From Local-GSM-Backend with Apache License 2.0 4 votes vote down vote up
@AfterViews
protected void init() {
    toolbar.setTitle(R.string.app_name);

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

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

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

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

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

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

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

}
 
Example #10
Source File: MainActivity.java    From wifi_backend with GNU General Public License v3.0 4 votes vote down vote up
@AfterViews
protected void init() {
    toolbar.setTitle(R.string.app_title);

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

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

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

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

                    return false;
                }
            })
            .build();

    updateTitle();

    if(action == Action.request_permission) {
        drawer.setSelection(SETTINGS);
    }
}
 
Example #11
Source File: RecyclerViewCacheUtil.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
/**
 * init the cache with an initialized drawer
 *
 * @param drawer
 */
public void init(Drawer drawer) {
    if (drawer.getDrawerItems() != null) {
        init(drawer.getRecyclerView(), drawer.getDrawerItems().toArray(new IDrawerItem[drawer.getDrawerItems().size()]));
    }
}
 
Example #12
Source File: AbstractDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public Drawer.OnDrawerItemClickListener getOnDrawerItemClickListener() {
    return mOnDrawerItemClickListener;
}
 
Example #13
Source File: MainActivity.java    From Faker with Apache License 2.0 4 votes vote down vote up
private void configureDrawer(Bundle savedInstanceState) {

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

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

                        return false;
                    }
                })
                .withSelectedItem(0)
                .withSavedInstance(savedInstanceState)
                .build();
    }
 
Example #14
Source File: MainActivity.java    From PowerSwitch_Android with GNU General Public License v3.0 4 votes vote down vote up
private void initHistoryDrawer(Drawer navigationDrawer) {
    // parent HAS to be null, so it can be attached to navigationDrawer later on
    View historyView = LayoutInflater.from(this).inflate(R.layout.drawer_history, null, false);

    IconicsImageView clearHistory = (IconicsImageView) historyView.findViewById(R.id.buttonClear);
    clearHistory.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new AsyncTask<Void, Void, Exception>() {

                @Override
                protected Exception doInBackground(Void... params) {
                    try {
                        DatabaseHandler.clearHistory();
                    } catch (Exception e) {
                        return e;
                    }

                    return null;
                }

                @Override
                protected void onPostExecute(Exception exception) {
                    updateHistory();

                    if (exception != null) {
                        StatusMessageHandler.showErrorMessage(getActivity(), exception);
                    }

                }
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
    });

    layoutLoadingHistory = (LinearLayout) historyView.findViewById(R.id.layoutLoading);

    recyclerViewHistory = (RecyclerView) historyView.findViewById(R.id.recyclerview_history);
    historyItemArrayAdapter = new HistoryItemRecyclerViewAdapter(this, historyItems);
    historyItemArrayAdapter.setOnItemClickListener(new HistoryItemRecyclerViewAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View itemView, int position) {
            HistoryItem historyItem = historyItems.get(position);

            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy - HH:mm:ss");
            new AlertDialog.Builder(getActivity())
                    .setTitle(R.string.details)
                    .setMessage(simpleDateFormat.format(historyItem.getTime().getTime()) + "\n\n" +
                            historyItem.getShortDescription() + "\n\n" +
                            historyItem.getLongDescription())
                    .setNeutralButton(R.string.close, null)
                    .show();
        }
    });
    recyclerViewHistory.setAdapter(historyItemArrayAdapter);
    StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL);
    recyclerViewHistory.setLayoutManager(layoutManager);

    historyDrawer = new DrawerBuilder()
            .withActivity(this)
            .withCustomView(historyView)
            .withHeaderPadding(true)
            .withDrawerGravity(Gravity.END)
            .append(navigationDrawer);
}
 
Example #15
Source File: MyExpandableBadgeDrawerItem.java    From Focus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public MyExpandableBadgeDrawerItem withOnDrawerItemClickListener(Drawer.OnDrawerItemClickListener onDrawerItemClickListener) {
    mOnDrawerItemClickListener = onDrawerItemClickListener;
    return this;
}
 
Example #16
Source File: DrawerActivity.java    From outlay with Apache License 2.0 4 votes vote down vote up
public Drawer getMainDrawer() {
    return mainDrawer;
}
 
Example #17
Source File: SearchActivity.java    From GithubApp with Apache License 2.0 4 votes vote down vote up
private void initViews() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    setTitle(R.string.search);

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

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

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

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

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

    mRepoListView.setAdapter(mAdapter);

    // default is null
    mCurrentLang = "";
}
 
Example #18
Source File: DrawerManager.java    From FragmentNavigationPatternDemo with Apache License 2.0 4 votes vote down vote up
public Drawer getDrawer() {
    return mDrawer;
}
 
Example #19
Source File: MainActivity.java    From openapk with GNU General Public License v3.0 4 votes vote down vote up
public static Drawer setNavigationDrawer(final Context context, final Toolbar toolbar, final RecyclerView recyclerView, boolean badge, final AppAdapter appInstalledAdapter, final AppAdapter appSystemAdapter, final AppAdapter appDisabledAdapter, final AppAdapter appHiddenAdapter, final AppAdapter appFavoriteAdapter) {
    AppPreferences appPreferences = App.getAppPreferences();
    final Activity activity = (Activity) context;
    int header;

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

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

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

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

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

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

    mSectionsPagerAdapter = new SectionsPagerAdapterCurrencyList(getSupportFragmentManager());
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(2);
    mViewPager.addOnPageChangeListener(this);
    tabLayout.setupWithViewPager(mViewPager);
    tabLayout.setSelectedTabIndicatorColor(Color.WHITE);
}
 
Example #21
Source File: LeftDrawerManager.java    From timecat with Apache License 2.0 4 votes vote down vote up
public Drawer getDrawer() {
    return drawer;
}
 
Example #22
Source File: MidiPlayer.java    From MidiSheetMusic-Android with GNU General Public License v3.0 4 votes vote down vote up
public void setDrawer(Drawer drawer) {
    this.drawer = drawer;
}
 
Example #23
Source File: MyExpandableBadgeDrawerItem.java    From Focus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Drawer.OnDrawerItemClickListener getOnDrawerItemClickListener() {
    return mOnDrawerItemClickListener;
}
 
Example #24
Source File: MyExpandableBadgeDrawerItem.java    From Focus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public MyExpandableBadgeDrawerItem withOnDrawerItemClickListener(Drawer.OnDrawerItemClickListener onDrawerItemClickListener) {
    mOnDrawerItemClickListener = onDrawerItemClickListener;
    return this;
}
 
Example #25
Source File: MyExpandableBadgeDrawerItem.java    From Focus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Drawer.OnDrawerItemClickListener getOnDrawerItemClickListener() {
    return mOnDrawerItemClickListener;
}
 
Example #26
Source File: AbstractDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 2 votes vote down vote up
/**
 * this listener is called when an item is clicked in the drawer.
 * WARNING: don't overwrite this in the Switch / Toggle drawerItems if you want the toggle / switch to be selected
 * if the item is clicked and the item is not selectable.
 *
 * @param onDrawerItemClickListener
 * @return
 */
public T withOnDrawerItemClickListener(Drawer.OnDrawerItemClickListener onDrawerItemClickListener) {
    this.mOnDrawerItemClickListener = onDrawerItemClickListener;
    return (T) this;
}