Java Code Examples for android.widget.ExpandableListView#ExpandableListContextMenuInfo

The following examples show how to use android.widget.ExpandableListView#ExpandableListContextMenuInfo . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: delion   File: RecentTabsPage.java    License: Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 2
Source Project: AndroidChromium   File: RecentTabsPage.java    License: Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 3
Source Project: 365browser   File: RecentTabsPage.java    License: Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 4
@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;
}
 
Example 5
@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;
}
 
Example 6
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;
}
 
Example 7
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;
}
 
Example 8
@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;
}
 
Example 9
@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);
	}
}
 
Example 10
@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);
	}
}
 
Example 11
private boolean isGroup(ContextMenu.ContextMenuInfo menuInfo) {
	ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
	int childPosition = ExpandableListView.getPackedPositionChild(listItem.packedPosition);
	return childPosition == -1;
}
 
Example 12
@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);
    }
}