本文整理汇总了Java中com.mikepenz.materialdrawer.model.interfaces.Selectable类的典型用法代码示例。如果您正苦于以下问题:Java Selectable类的具体用法?Java Selectable怎么用?Java Selectable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Selectable类属于com.mikepenz.materialdrawer.model.interfaces包,在下文中一共展示了Selectable类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFooterDrawerItemClick
import com.mikepenz.materialdrawer.model.interfaces.Selectable; //导入依赖的package包/类
/**
* helper method to handle the onClick of the footer
*
* @param drawer
* @param drawerItem
* @param v
* @param fireOnClick true if we should call the listener, false if not, null to not call the listener and not close the drawer
*/
public static void onFooterDrawerItemClick(DrawerBuilder drawer, IDrawerItem drawerItem, View v, Boolean fireOnClick) {
boolean checkable = !(drawerItem != null && drawerItem instanceof Selectable && !((Selectable) drawerItem).isSelectable());
if (checkable) {
drawer.resetStickyFooterSelection();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
v.setActivated(true);
}
v.setSelected(true);
//remove the selection in the list
drawer.getAdapter().deselect();
//find the position of the clicked footer item
if (drawer.mStickyFooterView != null && drawer.mStickyFooterView instanceof LinearLayout) {
LinearLayout footer = (LinearLayout) drawer.mStickyFooterView;
for (int i = 0; i < footer.getChildCount(); i++) {
if (footer.getChildAt(i) == v) {
drawer.mCurrentStickyFooterSelection = i;
break;
}
}
}
}
if (fireOnClick != null) {
boolean consumed = false;
if (fireOnClick && drawer.mOnDrawerItemClickListener != null) {
consumed = drawer.mOnDrawerItemClickListener.onItemClick(v, -1, drawerItem);
}
if (!consumed) {
//close the drawer after click
drawer.closeDrawerDelayed();
}
}
}
示例2: onFooterDrawerItemClick
import com.mikepenz.materialdrawer.model.interfaces.Selectable; //导入依赖的package包/类
/**
* helper method to handle the onClick of the footer
*
* @param drawer
* @param drawerItem
* @param v
* @param fireOnClick true if we should call the listener, false if not, null to not call the listener and not close the drawer
*/
public static void onFooterDrawerItemClick(DrawerBuilder drawer, IDrawerItem drawerItem, View v, Boolean fireOnClick) {
boolean checkable = !(drawerItem != null && drawerItem instanceof Selectable && !((Selectable) drawerItem).isSelectable());
if (checkable) {
drawer.resetStickyFooterSelection();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
v.setActivated(true);
}
v.setSelected(true);
//remove the selection in the list
drawer.getAdapter().handleSelection(null, -1);
//set currentSelection to -1 because we selected a stickyFooter element
drawer.mCurrentSelection = -1;
//find the position of the clicked footer item
if (drawer.mStickyFooterView != null && drawer.mStickyFooterView instanceof LinearLayout) {
LinearLayout footer = (LinearLayout) drawer.mStickyFooterView;
for (int i = 0; i < footer.getChildCount(); i++) {
if (footer.getChildAt(i) == v) {
drawer.mCurrentStickyFooterSelection = i;
break;
}
}
}
}
if (fireOnClick != null) {
boolean consumed = false;
if (fireOnClick && drawer.mOnDrawerItemClickListener != null) {
consumed = drawer.mOnDrawerItemClickListener.onItemClick(v, -1, drawerItem);
}
if (!consumed) {
//close the drawer after click
drawer.closeDrawerDelayed();
}
}
}