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


Java Selectable类代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:47,代码来源:DrawerUtils.java

示例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();
        }
    }
}
 
开发者ID:FreedomZZQ,项目名称:YouJoin-Android,代码行数:50,代码来源:DrawerUtils.java


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