android.widget.ExpandableListView#ExpandableListContextMenuInfo ( )源码实例Demo

下面列出了android.widget.ExpandableListView#ExpandableListContextMenuInfo ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: delion   文件: RecentTabsPage.java
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // Would prefer to have this context menu view managed internal to RecentTabsGroupView
    // Unfortunately, setting either onCreateContextMenuListener or onLongClickListener
    // disables the native onClick (expand/collapse) behaviour of the group view.
    ExpandableListView.ExpandableListContextMenuInfo info =
            (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        mAdapter.getGroup(groupPosition).onCreateContextMenuForGroup(menu, mActivity);
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
        mAdapter.getGroup(groupPosition).onCreateContextMenuForChild(childPosition, menu,
                mActivity);
    }
}
 
源代码2 项目: AndroidChromium   文件: RecentTabsPage.java
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // Would prefer to have this context menu view managed internal to RecentTabsGroupView
    // Unfortunately, setting either onCreateContextMenuListener or onLongClickListener
    // disables the native onClick (expand/collapse) behaviour of the group view.
    ExpandableListView.ExpandableListContextMenuInfo info =
            (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        mAdapter.getGroup(groupPosition).onCreateContextMenuForGroup(menu, mActivity);
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
        mAdapter.getGroup(groupPosition).onCreateContextMenuForChild(childPosition, menu,
                mActivity);
    }
}
 
源代码3 项目: 365browser   文件: RecentTabsPage.java
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // Would prefer to have this context menu view managed internal to RecentTabsGroupView
    // Unfortunately, setting either onCreateContextMenuListener or onLongClickListener
    // disables the native onClick (expand/collapse) behaviour of the group view.
    ExpandableListView.ExpandableListContextMenuInfo info =
            (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        mAdapter.getGroup(groupPosition).onCreateContextMenuForGroup(menu, mActivity);
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
        mAdapter.getGroup(groupPosition).onCreateContextMenuForChild(childPosition, menu,
                mActivity);
    }
}
 
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
	MyLog.entry("menuItem = " + menuItem);

	final ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuItem.getMenuInfo();
	final int groupPosition = ExpandableListView.getPackedPositionGroup(listItem.packedPosition);

	//final MonsterInfoModel monsterInfo = getGroupMonsterItem(menuItem.getMenuInfo());

	switch (menuItem.getItemId()) {
		case MENU_ID_SELECT_ALL:
			mAdapter.flagAllChildren(groupPosition, true);
			break;
		case MENU_ID_DESELECT_ALL:
			mAdapter.flagAllChildren(groupPosition, false);
			break;
		default:
	}

	MyLog.exit();
	return true;
}
 
@SuppressWarnings("unchecked")
private List<ChooseModelContainer<SyncedMonsterModel>> getGroupChildMonsterItems(ContextMenu.ContextMenuInfo menuInfo) {
	MyLog.entry("menuInfo = " + menuInfo);

	final ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
	final int groupPosition = ExpandableListView.getPackedPositionGroup(listItem.packedPosition);

	final List<ChooseModelContainer<SyncedMonsterModel>> monsterItems = new ArrayList<ChooseModelContainer<SyncedMonsterModel>>();
	final int childCount = adapter.getChildrenCount(groupPosition);

	for (int i = 0; i < childCount; i++) {
		final ChooseModelContainer<SyncedMonsterModel> monsterItem = adapter.getChild(groupPosition, i);
		monsterItems.add(monsterItem);
	}

	MyLog.exit();
	return monsterItems;
}
 
private MonsterInfoModel getGroupMonsterItem(ContextMenu.ContextMenuInfo menuInfo) {
	MyLog.entry("menuInfo = " + menuInfo);

	final ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
	final int groupPosition = ExpandableListView.getPackedPositionGroup(listItem.packedPosition);
	final MonsterInfoModel result = mAdapter.getGroup(groupPosition);

	MyLog.exit();
	return result;
}
 
private MonsterInfoModel getGroupMonsterItem(ContextMenu.ContextMenuInfo menuInfo) {
	MyLog.entry("menuInfo = " + menuInfo);

	final ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
	final int groupPosition = ExpandableListView.getPackedPositionGroup(listItem.packedPosition);
	final MonsterInfoModel result = adapter.getGroup(groupPosition);

	MyLog.exit();
	return result;
}
 
@SuppressWarnings("unchecked")
private ChooseModelContainer<SyncedMonsterModel> getChildMonsterItem(ContextMenu.ContextMenuInfo menuInfo) {
	MyLog.entry("menuInfo = " + menuInfo);

	final ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
	int groupPosition = ExpandableListView.getPackedPositionGroup(listItem.packedPosition);
	int childPosition = ExpandableListView.getPackedPositionChild(listItem.packedPosition);
	final ChooseModelContainer result = adapter.getChild(groupPosition, childPosition);

	MyLog.exit();
	return result;
}
 
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
	super.onCreateContextMenu(menu, v, menuInfo);
	ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

	MenuInflater inflater = getSherlockActivity().getMenuInflater();
	int type = ExpandableListView.getPackedPositionType(info.packedPosition);
	if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
		inflater.inflate(R.menu.novel_details_volume_context_menu, menu);
	} else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
		inflater.inflate(R.menu.novel_details_chapter_context_menu, menu);
	}
}
 
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
	super.onCreateContextMenu(menu, v, menuInfo);
	ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

	MenuInflater inflater = getMenuInflater();
	int type = ExpandableListView.getPackedPositionType(info.packedPosition);
	if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
		inflater.inflate(R.menu.novel_details_volume_context_menu, menu);
	} else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
		inflater.inflate(R.menu.novel_details_chapter_context_menu, menu);
	}
}
 
private boolean isGroup(ContextMenu.ContextMenuInfo menuInfo) {
	ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
	int childPosition = ExpandableListView.getPackedPositionChild(listItem.packedPosition);
	return childPosition == -1;
}
 
源代码12 项目: 4pdaClient-plus   文件: LeadersListFragment.java
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    ExpandableListView.ExpandableListContextMenuInfo info =
            (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        Object o = getAdapter().getChild(groupPosition, childPosition);
        if (o == null) return;
        final LeadUser leadUser = ((LeadUser) o);

        final List<MenuListDialog> list = new ArrayList<>();
        list.add(new MenuListDialog(App.getInstance().getString(R.string.list_forums), () -> {
            if (leadUser.isAllForumsOwner()) {
                MainActivity.showListFragment(new ForumBrickInfo().getName(), null);
            } else {
                CharSequence[] forumTitles = new CharSequence[leadUser.getForums().size()];
                int i = 0;
                for (Forum f : leadUser.getForums()) {
                    forumTitles[i++] = f.getTitle();
                }
                Context context = getContext();
                if (context != null)
                    new MaterialDialog.Builder(context)
                            .title(R.string.forums)
                            .items(forumTitles)
                            .itemsCallbackSingleChoice(-1, (dialog, view, i1, forumTitles1) -> {
                                ForumTopicsListFragment.showForumTopicsList(
                                        leadUser.getForums().get(i1).getId(), leadUser.getForums().get(i1).getTitle());
                                return true; // allow selection
                            })
                            .show();
            }
        }));
        ForumUser.onCreateContextMenu(getContext(), list, leadUser.getId().toString(), leadUser.getNick().toString());
        ExtUrl.showContextDialog(getContext(), null, list);
    }
}