本文整理汇总了Java中com.mikepenz.materialdrawer.model.interfaces.Nameable类的典型用法代码示例。如果您正苦于以下问题:Java Nameable类的具体用法?Java Nameable怎么用?Java Nameable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Nameable类属于com.mikepenz.materialdrawer.model.interfaces包,在下文中一共展示了Nameable类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCheckedChanged
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的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();
}
示例2: onCreate
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的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();
}
示例3: showDefaultProduct
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
private void showDefaultProduct() {
SeachemProduct defaultProduct = DoserApplication.getDoserPreferences().getDefaultProduct();
if (defaultProduct != null) {
SeachemProductCategory category = SeachemManager.getProductCategory(defaultProduct);
ExpandableDrawerItem parent = mProductCategoryItems.get(category);
// first open parent item
parent.withIsExpanded(true);
mDrawer.updateItem(parent);
// now select + click child item
for (IDrawerItem item : parent.getSubItems()) {
String title = ((Nameable) item).getName().getText();
if (title != null && title.equals(defaultProduct.getName())) {
mDrawer.setSelection(item, true);
break;
}
}
} else {
setCurrentFragment(getString(R.string.app_name), new DefaultFragment());
}
}
示例4: getDrawerItemResourceInPosition
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
public int getDrawerItemResourceInPosition(int position) {
if (drawer.getHeader() == null) {
return ((Nameable) drawer.getDrawerItems().get(position)).getName().getTextRes();
} else {
return ((Nameable) drawer.getDrawerItems().get(position - 1)).getName().getTextRes();
}
}
示例5: onCheckedChanged
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
@Override
public void onCheckedChanged(IDrawerItem drawerItem, CompoundButton buttonView, boolean isChecked) {
if (drawerItem instanceof Nameable) {
Log.i("material-drawer", "DrawerItem: " + ((Nameable) drawerItem).getName() + " - toggleChecked: " + isChecked);
} else {
Log.i("material-drawer", "toggleChecked: " + isChecked);
}
}
示例6: onCreate
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
//supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_actionbar);
setTitle(R.string.drawer_item_action_bar_drawer);
// Handle Toolbar
result = new DrawerBuilder()
.withActivity(this)
.withSavedInstance(savedInstanceState)
.withDisplayBelowStatusBar(false)
.withTranslucentStatusBar(false)
.withDrawerLayout(R.layout.material_drawer_fits_not)
.addDrawerItems(
new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home),
new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem instanceof Nameable) {
Toast.makeText(ActionBarActivity.this, ((Nameable) drawerItem).getName().getText(ActionBarActivity.this), Toast.LENGTH_SHORT).show();
}
return false;
}
}).build();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}
示例7: updateName
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
/**
* update the name for a specific drawerItem
* identified by its id
*
* @param identifier
* @param name
*/
public void updateName(long identifier, StringHolder name) {
IDrawerItem drawerItem = getDrawerItem(identifier);
if (drawerItem instanceof Nameable) {
Nameable pdi = (Nameable) drawerItem;
pdi.withName(name);
updateItem((IDrawerItem) pdi);
}
}
示例8: updateName
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
/**
* update the name for a specific drawerItem
* identified by its id
*
* @param identifier
* @param name
*/
public void updateName(int identifier, StringHolder name) {
IDrawerItem drawerItem = getDrawerItem(identifier);
if (drawerItem instanceof Nameable) {
Nameable pdi = (Nameable) drawerItem;
pdi.withName(name);
updateItem((IDrawerItem) pdi);
}
}
示例9: onClickDrawerItem
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
private boolean onClickDrawerItem(IDrawerItem drawerItem) {
switch (drawerItem.getIdentifier()) {
case ID_SETTINGS:
// show settings
return true;
default:
setTitle(((Nameable)drawerItem).getNameRes());
return true;
}
}
示例10: initViews
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
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.distance_180dp)
.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.mipmap.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) {
Logger.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.setOnItemClickListener(mItemtClickListener);
mAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
mRepoList.setAdapter(mAdapter);
// default is null
mCurrentLang = "";
}
示例11: initViews
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
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 = "";
}
示例12: onCreate
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
//supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_nontranslucent);
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.drawer_item_non_translucent_status_drawer);
// Create a few sample profile
result = new DrawerBuilder()
.withActivity(this)
.withTranslucentStatusBar(false)
.addDrawerItems(
new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home),
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)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem instanceof Nameable) {
Toast.makeText(NonTranslucentDrawerActivity.this, ((Nameable) drawerItem).getName().getText(NonTranslucentDrawerActivity.this), Toast.LENGTH_SHORT).show();
}
return false;
}
})
.withSelectedItemByPosition(2)
.withSavedInstance(savedInstanceState)
.build();
//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}
示例13: onCreate
import com.mikepenz.materialdrawer.model.interfaces.Nameable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
// Handle Toolbar
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.drawer_item_compact_header);
// Create a few sample profile
final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("[email protected]").withIcon(R.drawable.profile);
final IProfile profile2 = new ProfileDrawerItem().withName("Max Muster").withEmail("[email protected]").withIcon(R.drawable.profile2);
final IProfile profile3 = new ProfileDrawerItem().withName("Felix House").withEmail("[email protected]").withIcon(R.drawable.profile3);
final IProfile profile4 = new ProfileDrawerItem().withName("Mr. X").withEmail("[email protected]").withIcon(R.drawable.profile4);
final IProfile profile5 = new ProfileDrawerItem().withName("Batman").withEmail("[email protected]").withIcon(R.drawable.profile5);
// Create the AccountHeader
headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withCompactStyle(true)
.withHeaderBackground(R.drawable.header)
.addProfiles(
profile,
profile2,
profile3,
profile4,
profile5,
//don't ask but google uses 14dp for the add account icon in gmail but 20dp for the normal icons (like manage account)
new ProfileSettingDrawerItem().withName("Add Account").withDescription("Add new GitHub Account").withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_plus).actionBar().paddingDp(5).colorRes(R.color.material_drawer_dark_primary_text)).withIdentifier(PROFILE_SETTING),
new ProfileSettingDrawerItem().withName("Manage Account").withIcon(GoogleMaterial.Icon.gmd_settings)
)
.withSavedInstance(savedInstanceState)
.build();
//Create the drawer
result = new DrawerBuilder()
.withActivity(this)
.withAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
.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).withIdentifier(5),
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)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem != null && drawerItem.getIdentifier() == 1) {
startSupportActionMode(new ActionBarCallBack());
findViewById(R.id.action_mode_bar).setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(CompactHeaderDrawerActivity.this, R.attr.colorPrimary, R.color.material_drawer_primary));
}
if (drawerItem instanceof Nameable) {
toolbar.setTitle(((Nameable) drawerItem).getName().getText(CompactHeaderDrawerActivity.this));
}
return false;
}
})
.withSavedInstance(savedInstanceState)
.build();
// set the selection to the item with the identifier 5
if (savedInstanceState == null) {
result.setSelection(5, false);
}
//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}