android.widget.ExpandableListView#PACKED_POSITION_TYPE_GROUP源码实例Demo

下面列出了android.widget.ExpandableListView#PACKED_POSITION_TYPE_GROUP 实例代码,或者点击链接到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);
    }
}
 
源代码4 项目: ActivityLauncher   文件: AllTasksListFragment.java
@Override
public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v,
                                ContextMenuInfo menuInfo) {
    menu.add(Menu.NONE, 0, Menu.NONE, R.string.context_action_shortcut);
    menu.add(Menu.NONE, 1, Menu.NONE, R.string.context_action_launch);

    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    ExpandableListView list = getView().findViewById(R.id.expandableListView1);

    switch (ExpandableListView.getPackedPositionType(info.packedPosition)) {
        case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
            MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));
            menu.setHeaderIcon(activity.icon);
            menu.setHeaderTitle(activity.name);
            menu.add(Menu.NONE, 2, Menu.NONE, R.string.context_action_edit);
            break;
        case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
            MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
            menu.setHeaderIcon(pack.icon);
            menu.setHeaderTitle(pack.name);
            break;
    }

    super.onCreateContextMenu(menu, v, menuInfo);
}
 
源代码5 项目: FireFiles   文件: RootsFragment.java
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    int itemType = ExpandableListView.getPackedPositionType(id);
    int childPosition;
    int groupPosition;

    if ( itemType == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        childPosition = ExpandableListView.getPackedPositionChild(id);
        groupPosition = ExpandableListView.getPackedPositionGroup(id);
        final Item item = (Item) mAdapter.getChild(groupPosition, childPosition);
        if (item instanceof AppItem) {
            showAppDetails(((AppItem) item).info);
            return true;
        } else if (item instanceof BookmarkItem) {
            removeBookark((BookmarkItem)item);
            return true;
        }  else {
            return false;
        }

    } else if(itemType == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        groupPosition = ExpandableListView.getPackedPositionGroup(id);
        return false;

    } else {
        return false;
    }
}
 
源代码6 项目: FireFiles   文件: RootsFragment.java
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    int itemType = ExpandableListView.getPackedPositionType(id);
    int childPosition;
    int groupPosition;

    if ( itemType == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        childPosition = ExpandableListView.getPackedPositionChild(id);
        groupPosition = ExpandableListView.getPackedPositionGroup(id);
        final Item item = (Item) mAdapter.getChild(groupPosition, childPosition);
        if (item instanceof AppItem) {
            showAppDetails(((AppItem) item).info);
            return true;
        } else if (item instanceof BookmarkItem) {
            removeBookark((BookmarkItem)item);
            return true;
        }  else {
            return false;
        }

    } else if(itemType == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        groupPosition = ExpandableListView.getPackedPositionGroup(id);
        return false;

    } else {
        return false;
    }
}
 
源代码7 项目: FireFiles   文件: RootsFragment.java
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    int itemType = ExpandableListView.getPackedPositionType(id);
    int childPosition;
    int groupPosition;

    if ( itemType == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        childPosition = ExpandableListView.getPackedPositionChild(id);
        groupPosition = ExpandableListView.getPackedPositionGroup(id);
        final Item item = (Item) mAdapter.getChild(groupPosition, childPosition);
        if (item instanceof AppItem) {
            showAppDetails(((AppItem) item).info);
            return true;
        } else if (item instanceof BookmarkItem) {
            removeBookark((BookmarkItem)item);
            return true;
        }  else {
            return false;
        }

    } else if(itemType == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        groupPosition = ExpandableListView.getPackedPositionGroup(id);
        return false;

    } else {
        return false;
    }
}
 
@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);
	}
}
 
源代码10 项目: document-viewer   文件: OPDSActivity.java
/**
 * {@inheritDoc}
 *
 * @see android.app.Activity#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)
 */
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    if (menuInfo instanceof ExpandableListContextMenuInfo) {
        final ExpandableListContextMenuInfo cmi = (ExpandableListContextMenuInfo) menuInfo;
        final int type = ExpandableListView.getPackedPositionType(cmi.packedPosition);
        final int groupPosition = ExpandableListView.getPackedPositionGroup(cmi.packedPosition);
        final int childPosition = ExpandableListView.getPackedPositionChild(cmi.packedPosition);
        // System.out.println("OPDSActivity.onCreateContextMenu(): " + type + ", " + groupPosition + ", "
        // + childPosition);
        switch (type) {
            case ExpandableListView.PACKED_POSITION_TYPE_NULL:
                onCreateContextMenu(menu);
                return;
            case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
                final Entry entry = getController().adapter.getGroup(groupPosition);
                if (entry instanceof Feed) {
                    onCreateFeedContextMenu(menu, (Feed) entry);
                } else if (entry instanceof Book) {
                    onCreateBookContextMenu(menu, (Book) entry);
                }
                return;
            case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
                final Entry group = getController().adapter.getGroup(groupPosition);
                final Object child = getController().adapter.getChild(groupPosition, childPosition);
                if (child instanceof Link) {
                    onCreateLinkContextMenu(menu, (Book) group, (Link) child);
                } else if (child instanceof Feed) {
                    onCreateFacetContextMenu(menu, (Feed) group, (Feed) child);
                }
                return;
        }
    }
    onCreateContextMenu(menu);
}
 
源代码11 项目: ActivityLauncher   文件: AllTasksListFragment.java
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    ExpandableListView list = getView().findViewById(R.id.expandableListView1);

    switch (ExpandableListView.getPackedPositionType(info.packedPosition)) {
        case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
            MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));
            switch (item.getItemId()) {
                case 0:
                    LauncherIconCreator.createLauncherIcon(getActivity(), activity);
                    break;
                case 1:
                    LauncherIconCreator.launchActivity(getActivity(), activity.component_name);
                    break;
                case 2:
                    DialogFragment dialog = new ShortcutEditDialogFragment();
                    Bundle args = new Bundle();
                    args.putParcelable("activity", activity.component_name);
                    dialog.setArguments(args);
                    dialog.show(getFragmentManager(), "ShortcutEditor");
                    break;
            }
            break;

        case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
            MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
            switch (item.getItemId()) {
                case 0:
                    boolean success = LauncherIconCreator.createLauncherIcon(getActivity(), pack);
                    Toast.makeText(getActivity(), getString(R.string.error_no_default_activity), Toast.LENGTH_LONG).show();
                    break;
                case 1:
                    PackageManager pm = getActivity().getPackageManager();
                    Intent intent = pm.getLaunchIntentForPackage(pack.package_name);
                    if (intent != null) {
                        Toast.makeText(getActivity(), String.format(getText(R.string.starting_application).toString(), pack.name), Toast.LENGTH_LONG).show();
                        getActivity().startActivity(intent);
                    } else {
                        Toast.makeText(getActivity(), getString(R.string.error_no_default_activity), Toast.LENGTH_LONG).show();
                    }
                    break;
            }
    }
    return super.onContextItemSelected(item);
}