Search in sources :

Example 21 with PrimaryDrawerItem

use of com.mikepenz.materialdrawer.model.PrimaryDrawerItem in project FastAdapter by mikepenz.

the class SampleActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    //create the activity
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("");
    //Create the drawer
    mResult = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withHasStableIds(true).withSavedInstance(savedInstanceState).withShowDrawerOnFirstLaunch(true).addDrawerItems(new PrimaryDrawerItem().withName(R.string.sample_icon_grid).withDescription(R.string.sample_icon_grid_descr).withSelectable(false).withIdentifier(8).withIcon(MaterialDesignIconic.Icon.gmi_grid), new PrimaryDrawerItem().withName(R.string.sample_simple_item_list).withDescription(R.string.sample_simple_item_list_descr).withSelectable(false).withIdentifier(6).withIcon(MaterialDesignIconic.Icon.gmi_format_align_justify), new PrimaryDrawerItem().withName(R.string.sample_image_list).withDescription(R.string.sample_image_list_descr).withSelectable(false).withIdentifier(5).withIcon(MaterialDesignIconic.Icon.gmi_wallpaper), new PrimaryDrawerItem().withName(R.string.sample_multi_select).withDescription(R.string.sample_multi_select_descr).withSelectable(false).withIdentifier(1).withIcon(MaterialDesignIconic.Icon.gmi_select_all), new PrimaryDrawerItem().withName(R.string.sample_collapsible).withDescription(R.string.sample_collapsible_descr).withSelectable(false).withIdentifier(2).withIcon(MaterialDesignIconic.Icon.gmi_check_all), new PrimaryDrawerItem().withName(R.string.sample_sticky_header).withDescription(R.string.sample_sticky_header_descr).withSelectable(false).withIdentifier(3).withIcon(MaterialDesignIconic.Icon.gmi_format_align_left), new PrimaryDrawerItem().withName(R.string.sample_advanced).withDescription(R.string.sample_advanced_descr).withSelectable(false).withIdentifier(4).withIcon(MaterialDesignIconic.Icon.gmi_coffee), new PrimaryDrawerItem().withName(R.string.sample_generic_item).withDescription(R.string.sample_generic_item_descr).withSelectable(false).withIdentifier(7).withIcon(MaterialDesignIconic.Icon.gmi_font), new PrimaryDrawerItem().withName(R.string.sample_multi_generic_item).withDescription(R.string.sample_multi_generic_item_descr).withSelectable(false).withIdentifier(9).withIcon(MaterialDesignIconic.Icon.gmi_format_list_numbered), new PrimaryDrawerItem().withName(R.string.sample_checkbox_item).withDescription(R.string.sample_checkbox_item_descr).withSelectable(false).withIdentifier(10).withIcon(CommunityMaterial.Icon.cmd_checkbox_marked), new PrimaryDrawerItem().withName(R.string.sample_radiobutton_item).withDescription(R.string.sample_radiobutton_item_descr).withSelectable(false).withIdentifier(11).withIcon(CommunityMaterial.Icon.cmd_radiobox_marked), new PrimaryDrawerItem().withName(R.string.sample_swipe_list).withDescription(R.string.sample_swipe_list_descr).withSelectable(false).withIdentifier(12).withIcon(MaterialDesignIconic.Icon.gmi_format_align_left), new PrimaryDrawerItem().withName(R.string.sample_endless_scroll_list).withDescription(R.string.sample_endless_scroll_list_descr).withSelectable(false).withIdentifier(13).withIcon(MaterialDesignIconic.Icon.gmi_long_arrow_down), new PrimaryDrawerItem().withName(R.string.sample_sort).withDescription(R.string.sample_sort_descr).withSelectable(false).withIdentifier(14).withIcon(MaterialDesignIconic.Icon.gmi_sort_by_alpha), new PrimaryDrawerItem().withName(R.string.sample_mopub).withDescription(R.string.sample_mopub_descr).withSelectable(false).withIdentifier(15).withIcon(MaterialDesignIconic.Icon.gmi_accounts_list), new PrimaryDrawerItem().withName(R.string.sample_realm_list).withDescription(R.string.sample_realm_list_descr).withSelectable(false).withIdentifier(16).withIcon(MaterialDesignIconic.Icon.gmi_format_color_text), new PrimaryDrawerItem().withName(R.string.sample_collapsible_multi_select_delete).withDescription(R.string.sample_collapsible_multi_select_delete_descr).withSelectable(false).withIdentifier(17).withIcon(MaterialDesignIconic.Icon.gmi_check_all), new DividerDrawerItem(), new PrimaryDrawerItem().withName(R.string.open_source).withSelectable(false).withIdentifier(100).withIcon(MaterialDesignIconic.Icon.gmi_github)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {

        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            if (drawerItem != null) {
                Intent intent = null;
                if (drawerItem.getIdentifier() == 1) {
                    intent = new Intent(SampleActivity.this, MultiselectSampleActivity.class);
                } else if (drawerItem.getIdentifier() == 2) {
                    intent = new Intent(SampleActivity.this, ExpandableSampleActivity.class);
                } else if (drawerItem.getIdentifier() == 3) {
                    intent = new Intent(SampleActivity.this, StickyHeaderSampleActivity.class);
                } else if (drawerItem.getIdentifier() == 4) {
                    intent = new Intent(SampleActivity.this, AdvancedSampleActivity.class);
                } else if (drawerItem.getIdentifier() == 5) {
                    intent = new Intent(SampleActivity.this, ImageListActivity.class);
                } else if (drawerItem.getIdentifier() == 6) {
                    intent = new Intent(SampleActivity.this, SimpleItemListActivity.class);
                } else if (drawerItem.getIdentifier() == 7) {
                    intent = new Intent(SampleActivity.this, GenericItemActivity.class);
                } else if (drawerItem.getIdentifier() == 8) {
                    intent = new Intent(SampleActivity.this, IconGridActivity.class);
                } else if (drawerItem.getIdentifier() == 9) {
                    intent = new Intent(SampleActivity.this, MultiTypeGenericItemActivity.class);
                } else if (drawerItem.getIdentifier() == 10) {
                    intent = new Intent(SampleActivity.this, CheckBoxSampleActivity.class);
                } else if (drawerItem.getIdentifier() == 11) {
                    intent = new Intent(SampleActivity.this, RadioButtonSampleActivity.class);
                } else if (drawerItem.getIdentifier() == 12) {
                    intent = new Intent(SampleActivity.this, SwipeListActivity.class);
                } else if (drawerItem.getIdentifier() == 13) {
                    intent = new Intent(SampleActivity.this, EndlessScrollListActivity.class);
                } else if (drawerItem.getIdentifier() == 14) {
                    intent = new Intent(SampleActivity.this, SortActivity.class);
                } else if (drawerItem.getIdentifier() == 15) {
                    intent = new Intent(SampleActivity.this, MopubAdsActivity.class);
                } else if (drawerItem.getIdentifier() == 16) {
                    intent = new Intent(SampleActivity.this, RealmActivity.class);
                } else if (drawerItem.getIdentifier() == 17) {
                    intent = new Intent(SampleActivity.this, ExpandableMultiselectDeleteSampleActivity.class);
                } else if (drawerItem.getIdentifier() == 100) {
                    intent = new LibsBuilder().withFields(R.string.class.getFields()).withActivityTitle(getString(R.string.open_source)).withActivityStyle(Libs.ActivityStyle.LIGHT).withAboutIconShown(true).withVersionShown(true).withAboutVersionShown(true).intent(SampleActivity.this);
                }
                if (intent != null) {
                    SampleActivity.this.startActivity(intent);
                }
            }
            return false;
        }
    }).withSelectedItemByPosition(-1).build();
    //create our FastAdapter which will manage everything
    mFastAdapter = new FastAdapter<>();
    mFastAdapter.withSelectable(true);
    mFastAdapter.withMultiSelect(true);
    mFastAdapter.withSelectOnLongClick(false);
    //create our ItemAdapter which will host our items
    mItemAdapter = new ItemAdapter<>();
    //configure our fastAdapter
    //get our recyclerView and do basic setup
    mRecyclerView = (RecyclerView) findViewById(R.id.rv);
    //mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setAdapter(mItemAdapter.wrap(mFastAdapter));
    mRecyclerView.setItemAnimator(new SlideDownAlphaAnimator());
    mRecyclerView.getItemAnimator().setAddDuration(500);
    mRecyclerView.getItemAnimator().setRemoveDuration(500);
    //if we do this. the first added items will be animated :D
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            //add some dummy data
            mItemAdapter.add(ImageDummyData.getSimpleImageItems());
            //restore selections (this has to be done after the items were added
            mFastAdapter.withSavedInstanceState(savedInstanceState);
        }
    }, 50);
}
Also used : PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) DividerDrawerItem(com.mikepenz.materialdrawer.model.DividerDrawerItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SlideDownAlphaAnimator(com.mikepenz.itemanimators.SlideDownAlphaAnimator) LibsBuilder(com.mikepenz.aboutlibraries.LibsBuilder) Toolbar(android.support.v7.widget.Toolbar) Handler(android.os.Handler) Intent(android.content.Intent) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder)

Example 22 with PrimaryDrawerItem

use of com.mikepenz.materialdrawer.model.PrimaryDrawerItem in project Android-Iconics by mikepenz.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Handle Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    //order fonts by their name
    mFonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
    Collections.sort(mFonts, new Comparator<ITypeface>() {

        @Override
        public int compare(final ITypeface object1, final ITypeface object2) {
            return object1.getFontName().compareTo(object2.getFontName());
        }
    });
    //add all icons of all registered Fonts to the list
    ArrayList<IDrawerItem> items = new ArrayList<>(Iconics.getRegisteredFonts(this).size());
    int count = 0;
    for (ITypeface font : mFonts) {
        PrimaryDrawerItem pdi = new PrimaryDrawerItem().withName(font.getFontName()).withBadge("" + font.getIcons().size()).withDescription(TextUtils.isEmpty(font.getAuthor()) ? font.getVersion() : font.getVersion() + " - " + font.getAuthor()).withBadgeStyle(new BadgeStyle().withColorRes(R.color.md_grey_200)).withIcon(getRandomIcon(font)).withIdentifier(count);
        if (font.getMappingPrefix().equals("gmd")) {
            mIdentifierGmd = count;
        }
        items.add(pdi);
        count++;
    }
    mDrawer = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withDrawerItems(items).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {

        @Override
        public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {
            loadIcons(mFonts.get(i).getFontName());
            getSupportActionBar().setTitle(mFonts.get(i).getFontName());
            return false;
        }
    }).withOnDrawerListener(new Drawer.OnDrawerListener() {

        @Override
        public void onDrawerOpened(View drawerView) {
            KeyboardUtil.hideKeyboard(MainActivity.this);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
        }
    }).withFireOnInitialOnClick(true).withSelectedItem(mIdentifierGmd).build();
}
Also used : IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) ArrayList(java.util.ArrayList) Drawer(com.mikepenz.materialdrawer.Drawer) SearchView(android.support.v7.widget.SearchView) View(android.view.View) ITypeface(com.mikepenz.iconics.typeface.ITypeface) BadgeStyle(com.mikepenz.materialdrawer.holder.BadgeStyle) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) Toolbar(android.support.v7.widget.Toolbar)

Example 23 with PrimaryDrawerItem

use of com.mikepenz.materialdrawer.model.PrimaryDrawerItem in project ChipsLayoutManager by BelooS.

the class MainActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    toolbar.setTitle(getString(R.string.app_name_and_version, BuildConfig.VERSION_NAME));
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, ItemsFragment.newInstance()).commit();
    }
    setSupportActionBar(toolbar);
    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    drawer = new DrawerBuilder(this).withToolbar(toolbar).addDrawerItems(new PrimaryDrawerItem().withName(R.string.main).withIdentifier(1)).addDrawerItems(new PrimaryDrawerItem().withName(R.string.bottom_sheet).withIdentifier(2)).withOnDrawerItemClickListener(this::onDrawerItemClickListener).build();
}
Also used : PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder)

Example 24 with PrimaryDrawerItem

use of com.mikepenz.materialdrawer.model.PrimaryDrawerItem in project Tusky by Vavassor.

the class MainActivity method onFetchUserInfoSuccess.

private void onFetchUserInfoSuccess(Account me, String domain) {
    // Add the header image and avatar from the account, into the navigation drawer header.
    headerResult.clear();
    ImageView background = headerResult.getHeaderBackgroundView();
    int backgroundWidth = background.getWidth();
    int backgroundHeight = background.getHeight();
    if (backgroundWidth == 0 || backgroundHeight == 0) {
        /* The header ImageView may not be layed out when the verify credentials call returns so
             * measure the dimensions and use those. */
        background.measure(View.MeasureSpec.EXACTLY, View.MeasureSpec.EXACTLY);
        backgroundWidth = background.getMeasuredWidth();
        backgroundHeight = background.getMeasuredHeight();
    }
    background.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark));
    Picasso.with(MainActivity.this).load(me.header).placeholder(R.drawable.account_header_default).resize(backgroundWidth, backgroundHeight).centerCrop().into(background);
    headerResult.addProfiles(new ProfileDrawerItem().withName(me.getDisplayName()).withEmail(String.format("%s@%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(6).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();
}
Also used : PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) ImageView(android.widget.ImageView)

Aggregations

PrimaryDrawerItem (com.mikepenz.materialdrawer.model.PrimaryDrawerItem)24 DrawerBuilder (com.mikepenz.materialdrawer.DrawerBuilder)21 View (android.view.View)17 SecondaryDrawerItem (com.mikepenz.materialdrawer.model.SecondaryDrawerItem)17 Toolbar (android.support.v7.widget.Toolbar)16 IDrawerItem (com.mikepenz.materialdrawer.model.interfaces.IDrawerItem)14 SectionDrawerItem (com.mikepenz.materialdrawer.model.SectionDrawerItem)13 Drawer (com.mikepenz.materialdrawer.Drawer)10 ProfileDrawerItem (com.mikepenz.materialdrawer.model.ProfileDrawerItem)9 AccountHeaderBuilder (com.mikepenz.materialdrawer.AccountHeaderBuilder)8 Nameable (com.mikepenz.materialdrawer.model.interfaces.Nameable)8 DividerDrawerItem (com.mikepenz.materialdrawer.model.DividerDrawerItem)7 IProfile (com.mikepenz.materialdrawer.model.interfaces.IProfile)7 BadgeStyle (com.mikepenz.materialdrawer.holder.BadgeStyle)5 Intent (android.content.Intent)4 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)4 ProfileSettingDrawerItem (com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem)4 ViewGroup (android.view.ViewGroup)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3