當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。