当前位置: 首页>>代码示例>>Java>>正文


Java DrawerBuilder类代码示例

本文整理汇总了Java中com.mikepenz.materialdrawer.DrawerBuilder的典型用法代码示例。如果您正苦于以下问题:Java DrawerBuilder类的具体用法?Java DrawerBuilder怎么用?Java DrawerBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DrawerBuilder类属于com.mikepenz.materialdrawer包,在下文中一共展示了DrawerBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initDrawer

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
@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();
}
 
开发者ID:Pierry,项目名称:cartolapp,代码行数:24,代码来源:ToolbarBase.java

示例2: onCreateView

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
@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;
}
 
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:27,代码来源:SecondDrawerFragment.java

示例3: onCreate

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_dark_toolbar);

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

    //Create the drawer
    result = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .inflateMenu(R.menu.example_menu)
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    if (drawerItem instanceof Nameable) {
                        Toast.makeText(MenuDrawerActivity.this, ((Nameable) drawerItem).getName().getText(MenuDrawerActivity.this), Toast.LENGTH_SHORT).show();
                    }

                    return false;
                }
            }).build();
}
 
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:27,代码来源:MenuDrawerActivity.java

示例4: initializeDrawer

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
public void initializeDrawer(Activity activity) {


        this.response = new DrawerBuilder().withActivity(activity)
                .addDrawerItems(
                        audioActivity,
                        fileActivity,
                        new DividerDrawerItem(),
                        about
                ).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                        updatedSelection();
                        return true;
                    }
                })
                .build();
    }
 
开发者ID:TeamRegalad,项目名称:Rega-Play,代码行数:19,代码来源:DrawerUtils.java

示例5: DrawerHelper

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
@Inject
public DrawerHelper(final AppCompatActivity activity) {

  View view = LayoutInflater.from(activity).inflate(R.layout.view_menu_header, null);
  TextView textTitle = view.findViewById(R.id.menu_title);
  FontsUtils.toOctarineBold(activity, textTitle);

  drawer = new DrawerBuilder()
      .withActivity(activity)
      .withSliderBackgroundDrawableRes(R.drawable.fon_gradient)
      .withHeader(R.layout.view_menu_header)
      .withHeader(view)
      .withActionBarDrawerToggle(true)
      .withStickyFooter(R.layout.view_menu_footer)
      .withStickyFooterDivider(false)
      .build();

  if (activity instanceof Drawer.OnDrawerItemClickListener) {
    drawer.setOnDrawerItemClickListener((Drawer.OnDrawerItemClickListener) activity);
  }
}
 
开发者ID:AtlantPlatform,项目名称:atlant-android,代码行数:22,代码来源:DrawerHelper.java

示例6: buildDrawer

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
/**
 * Creates a new drawer for this application with predefined items
 *
 * @param activity
 * @param toolbar
 * @return
 */
public void buildDrawer(Activity activity, Toolbar toolbar) {

    //@formatter:off
    mDrawer = new DrawerBuilder()
                    .withActivity(activity)
                    .withToolbar(toolbar)
                    .withDrawerItems(getDrawerItems())
                    .withSelectedItemByPosition(getLastSelectedItemPosition())
                    .withAccountHeader(getAccountHeader(activity))
                    .addDrawerItems()
                    .build();
    //@formatter:on
}
 
开发者ID:beczesz,项目名称:FragmentNavigationPatternDemo,代码行数:21,代码来源:DrawerManager.java

示例7: setUpDrawer

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
protected void setUpDrawer(Toolbar ssToolbar){
    this.ssNavigationDrawer = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(ssToolbar)
            .withAccountHeader(getAccountHeader())
            .addDrawerItems(getDrawerItems())
            .withOnDrawerItemClickListener(this)
            .withSelectedItem(1)
            .build();
}
 
开发者ID:Adventech,项目名称:sabbath-school-android,代码行数:11,代码来源:SSBaseActivity.java

示例8: setDrawer

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
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();
        }
}
 
开发者ID:thawatchai,项目名称:duedo,代码行数:35,代码来源:BaseActivity.java

示例9: setupNavigationDrawer

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
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();
}
 
开发者ID:akexorcist,项目名称:Droid2JoyStick,代码行数:28,代码来源:MainActivity.java

示例10: onCreate

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
@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();
}
 
开发者ID:xdtianyu,项目名称:LanCamera,代码行数:38,代码来源:MainActivity.java

示例11: setupDrawer

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
@Override
public void setupDrawer(Me me, Optional<LuckyNumber> luckyNumber) {

    TextDrawable icon = getIcon(me);
    ProfileDrawerItem profile = getProfileDrawerItem(me, icon);

    DrawerBuilder drawerBuilder = new DrawerBuilder()
            .withActivity(this)
            .addStickyDrawerItems(settingsPresenter.convertToDrawerItem(this::displayFragment))
            .withDelayOnDrawerClose(50)
            .withOnDrawerNavigationListener(clickedView -> {
                onBackPressed();
                return true;
            })
            .withActionBarDrawerToggle(true)
            .withActionBarDrawerToggleAnimated(true)
            .withToolbar(toolbar)
            .withAccountHeader(getDrawerHeader(profile));


    StreamSupport.stream(fragmentPresenters)
            .sorted(Ordering.natural().onResultOf(MainFragmentPresenter::getOrder))
            .map(presenter -> presenter.convertToDrawerItem(p -> displayFragment(presenter)))
            .forEach(drawerBuilder::addDrawerItems);

    if (luckyNumber.isPresent()) {
        drawerBuilder.addDrawerItems(
                new DividerDrawerItem(),
                getLuckyNumberDrawerItem(luckyNumber.get()));
    }

    this.drawer = drawerBuilder.build();
}
 
开发者ID:shymmq,项目名称:librus-client,代码行数:34,代码来源:MainActivity.java

示例12: onCreate

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Timber.v("onCreate() Called");

    // Redirect to Launch activity if we can't inject the Team Component.
    TeamComponent teamComponent = ((App) getApplication()).getTeamComponent();
    if (teamComponent == null) {
        LaunchActivity.launch(this);
        finish();
        return;
    }
    teamComponent.inject(this);

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

    setSupportActionBar(toolbar);

    // Set up the drawer.
    drawer = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(final View view, final int position, final IDrawerItem drawerItem) {
                    return presenter.drawerItemClicked(drawer, position, drawerItem);
                }
            })
            .build();

    // Disable pull to refresh.
    postsRefreshView.setEnabled(false);

    // Connect to the presenter.
    presenter.takeView(this, savedInstanceState);
}
 
开发者ID:grundleborg,项目名称:matterdroid,代码行数:38,代码来源:MainActivity.java

示例13: setNavigationDrawer

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
/**
 * Method to set Navigation Drawer
 * Uses library https://github.com/mikepenz/MaterialDrawer
 */
private void setNavigationDrawer() {

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            ProfileDrawerItem profileDrawerItem;

            profileDrawerItem = new ProfileDrawerItem()
                    .withName("John Davis")
                    .withEmail("[email protected]")
                    .withIcon(getResources()
                            .getDrawable(R.drawable.ic_person_pink_600_48dp));
            // Create the AccountHeader
            AccountHeader headerResult = new AccountHeaderBuilder()
                    .withActivity(LibraryActivity.this)
                    .addProfiles(profileDrawerItem)
                    .withHeaderBackground(R.drawable.header)
                    .withAlternativeProfileHeaderSwitching(false)
                    .withCurrentProfileHiddenInList(true)
                    .withResetDrawerOnProfileListClick(false)
                    .withSelectionFirstLineShown(false)
                    .withSelectionListEnabledForSingleProfile(true)
                    .build();

            navigationDrawer = new DrawerBuilder()
                    .withActivity(LibraryActivity.this)
                    .withAccountHeader(headerResult)
                    .build();
        }
    }, 0);
}
 
开发者ID:iem-devs,项目名称:apna-library,代码行数:36,代码来源:LibraryActivity.java

示例14: onCreateView

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
@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;
}
 
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:32,代码来源:DrawerFragment.java

示例15: onCreate

import com.mikepenz.materialdrawer.DrawerBuilder; //导入依赖的package包/类
@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();
}
 
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:40,代码来源:CollapsingToolbarActivity.java


注:本文中的com.mikepenz.materialdrawer.DrawerBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。