本文整理汇总了Java中com.mikepenz.materialdrawer.model.interfaces.IDrawerItem类的典型用法代码示例。如果您正苦于以下问题:Java IDrawerItem类的具体用法?Java IDrawerItem怎么用?Java IDrawerItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDrawerItem类属于com.mikepenz.materialdrawer.model.interfaces包,在下文中一共展示了IDrawerItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDrawerItemClickListener
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
private boolean onDrawerItemClickListener(View view, int position, IDrawerItem drawerItem) {
int id = (int) drawerItem.getIdentifier();
switch (id) {
case 1:
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragmentContainer, ItemsFragment.newInstance())
.commit();
drawer.closeDrawer();
break;
case 2:
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragmentContainer, BottomSheetFragment.newInstance())
.commit();
drawer.closeDrawer();
break;
}
return true;
}
示例2: onItemClick
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
int currentDrawerItemResource = drawerHelper.getDrawerItemResourceInPosition(position);
switch (currentDrawerItemResource) {
case DrawerContent.ITEM_SEND: {
goToSendActivity(false, "");
break;
}
case DrawerContent.ITEM_RECEIVE: {
goToReceiveActivity(false);
break;
}
case DrawerContent.ITEM_SETTINGS: {
goToSettingsActivity(false);
break;
}
}
if (drawerHelper.isDrawerOpen()) {
drawerHelper.closeDrawer();
}
return true;
}
示例3: addDepartamento
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
/**
* Adicionar os departamentos
* @param department
* @param news
*/
private void addDepartamento( Department department, boolean news ) {
if( news && this.departamentsWorks.contains( department ) ) return;
else if( news ) this.departamentsWorks.add( department );
this.departamentoContainer.withSubItems(
new SecondaryDrawerItem().withName( department.getNome() )
.withIdentifier( department.getIdentifier() )
.withIcon( R.drawable.ic_home_teal_500_24dp )
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
onChangeDepartmentTo( drawerItem.getIdentifier() );
return false;
}
})
);
}
示例4: populateProfile
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
/**
* Populate profile
* @param department
*/
public void populateProfile( Department department){
this.accountHeader.clear();
for ( User user : department.getColaborators() ){
addProfile( user );
}
this.currentDepartment = department;
if( currentMenu != null && ((Fragment)currentMenu.getMainFrag()).isResumed() )
this.currentMenu.getMainFrag().onDepartmentChange(department);
else if(currentMenu != null ) {
( (Fragment)this.currentMenu.getMainFrag()).getArguments()
.putString( Department.INSTANCE, currentDepartment.getKey() );
}
for( IDrawerItem item : this.departamentoContainer.getSubItems() ){
if( item.getIdentifier() == department.getIdentifier() ){
item.withSetSelected( true );
this.departamentoContainer.withSetSelected( true );
}
}
}
示例5: addProfile
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
/**
* Add new profile
* @param user
*/
private void addProfile(User user) {
this.accountHeader.addProfiles(
new ProfileDrawerItem().withName( user.getName() )
.withEmail( user.getKey() )
.withIcon( user.createBitMap( this.main ) )
.withIdentifier( user.getIdentifier() )
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
onProfileChange( view, position, drawerItem );
return false;
}
})
);
}
示例6: reloadDrawerItems
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
@Override
protected List<IDrawerItem> reloadDrawerItems(Realm realm, boolean showOnlyUnread) {
List<Feed> feeds = state.getStartDrawerItem().getFeeds(realm, showOnlyUnread);
List<IDrawerItem> drawerItems = new ArrayList<>((feeds != null ? feeds.size() : 0) + 1);
if (state.isFeedSelected())
return drawerItems;
drawerItems.add(new SectionDrawerItem()
.withDivider(false)
.withName(state.getStartDrawerItem().getName()));
if (feeds != null) {
for (Feed feed : feeds) {
PrimaryDrawerItem drawerItem = new TreeItemDrawerItem(feed);
drawerItem.withIdentifier(feed.getId());
drawerItem.withBadge(feed.getUnreadCount());
drawerItem.withSetSelected(state.getEndDrawerItem() != null && state.getEndDrawerItem().getId() == feed.getId());
drawerItems.add(drawerItem);
}
}
return drawerItems;
}
示例7: onCheckedChanged
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
@Override
public void onCheckedChanged(IDrawerItem drawerItem, CompoundButton buttonView, boolean isChecked) {
PreferenceManager.getDefaultSharedPreferences(ListActivity.this)
.edit()
.putBoolean(Preferences.SHOW_ONLY_UNREAD.getKey(), isChecked)
.apply();
if(drawerItem instanceof Nameable && drawerItem.getTag() instanceof AllUnreadFolder) {
final AllUnreadFolder unreadFolder = (AllUnreadFolder) drawerItem.getTag();
unreadFolder.updateName(ListActivity.this, isShowOnlyUnread());
((Nameable) drawerItem).withName(unreadFolder.getName());
}
drawerManager.reloadAdapters(getRealm(), isShowOnlyUnread());
reloadListFragment();
}
示例8: onItemClick
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
int id = (int) drawerItem.getIdentifier();
switch (id) {
case ID_LIVE:
playLive();
break;
case ID_HISTORY:
break;
case ID_SETTING:
launchSetting();
break;
default:
History history = (History) drawerItem.getTag();
switch (history.getType()) {
case DIRECTORY:
break;
case FILE:
playHistory(history);
break;
}
break;
}
return false;
}
示例9: setRecyclerViewSelection
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
/**
* helper method to set the selection in the list
*
* @param drawer
* @param position
* @param fireOnClick
* @param drawerItem
* @return
*/
public static boolean setRecyclerViewSelection(DrawerBuilder drawer, int position, boolean fireOnClick, IDrawerItem drawerItem) {
if (position >= -1) {
//predefine selection (should be the first element
if (drawer.mAdapter != null) {
drawer.resetStickyFooterSelection();
drawer.mAdapter.handleSelection(null, position);
drawer.mCurrentSelection = position;
drawer.mCurrentStickyFooterSelection = -1;
}
if (fireOnClick && drawer.mOnDrawerItemClickListener != null) {
return drawer.mOnDrawerItemClickListener.onItemClick(null, position, drawerItem);
}
}
return false;
}
示例10: onProfileClick
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
/**
* call this method to trigger the onProfileClick on the MiniDrawer
*/
public void onProfileClick() {
//crossfade if we are cross faded
if (mCrossFader != null) {
if (mCrossFader.isCrossfaded()) {
mCrossFader.crossfade();
}
}
//update the current profile
if (mAccountHeader != null) {
IProfile profile = mAccountHeader.getActiveProfile();
if (profile instanceof IDrawerItem) {
mDrawerAdapter.setDrawerItem(0, generateMiniDrawerItem((IDrawerItem) profile));
}
}
}
示例11: goToActivityListener
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
private Drawer.OnDrawerItemClickListener goToActivityListener(
@NonNull final Class<? extends Activity> activityClass) {
return new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
// Don't open a new activity if we're already in the activity the user clicked on
if (BaseActivity.this.getClass().equals(activityClass)) {
return true;
}
startActivity(new Intent(BaseActivity.this, activityClass)
.putExtra(INTENT_EXTRA_DRAWER_POSITION, position)
);
return true;
}
};
}
示例12: onCreate
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的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();
}
示例13: switchDrawerContent
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
/**
* method to switch the drawer content to new elements
*
* @param onDrawerItemClickListener
* @param drawerItems
* @param drawerSelection
*/
public void switchDrawerContent(@NonNull OnDrawerItemClickListener onDrawerItemClickListener, OnDrawerItemLongClickListener onDrawerItemLongClickListener, @NonNull List<IDrawerItem> drawerItems, int drawerSelection) {
//just allow a single switched drawer
if (!switchedDrawerContent()) {
//save out previous values
originalOnDrawerItemClickListener = getOnDrawerItemClickListener();
originalOnDrawerItemLongClickListener = getOnDrawerItemLongClickListener();
originalDrawerState = getAdapter().saveInstanceState(new Bundle());
getAdapter().collapse(false);
originalDrawerItems = getDrawerItems();
}
//set the new items
setOnDrawerItemClickListener(onDrawerItemClickListener);
setOnDrawerItemLongClickListener(onDrawerItemLongClickListener);
setItems(drawerItems, true);
setSelectionAtPosition(drawerSelection, false);
//hide stickyFooter and it's shadow
if (getStickyFooter() != null) {
getStickyFooter().setVisibility(View.GONE);
}
if (getStickyFooterShadow() != null) {
getStickyFooterShadow().setVisibility(View.GONE);
}
}
示例14: buildDrawerSelectionList
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
/**
* helper method to build and set the drawer selection list
*/
protected void buildDrawerSelectionList() {
int selectedPosition = -1;
int position = 0;
ArrayList<IDrawerItem> profileDrawerItems = new ArrayList<>();
if (mProfiles != null) {
for (IProfile profile : mProfiles) {
if (profile == mCurrentProfile) {
if (mCurrentHiddenInList) {
continue;
} else {
selectedPosition = mDrawer.mDrawerBuilder.getItemAdapter().getGlobalPosition(position);
}
}
if (profile instanceof IDrawerItem) {
((IDrawerItem) profile).withSetSelected(false);
profileDrawerItems.add((IDrawerItem) profile);
}
position = position + 1;
}
}
mDrawer.switchDrawerContent(onDrawerItemClickListener, onDrawerItemLongClickListener, profileDrawerItems, selectedPosition);
}
示例15: fillStickyDrawerItemFooter
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入依赖的package包/类
/**
* helper method to fill the sticky footer with it's elements
*
* @param drawer
* @param container
* @param onClickListener
*/
public static void fillStickyDrawerItemFooter(DrawerBuilder drawer, ViewGroup container, View.OnClickListener onClickListener) {
//add all drawer items
for (IDrawerItem drawerItem : drawer.mStickyDrawerItems) {
View view = drawerItem.generateView(container.getContext(), container);
view.setTag(drawerItem);
if (drawerItem.isEnabled()) {
//UIUtils.setBackground(view, UIUtils.getSelectableBackground(container.getContext(), selected_color, true));
view.setOnClickListener(onClickListener);
}
container.addView(view);
//for android API 17 --> Padding not applied via xml
DrawerUIUtils.setDrawerVerticalPadding(view);
}
//and really. don't ask about this. it won't set the padding if i don't set the padding for the container
container.setPadding(0, 0, 0, 0);
}