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

下面列出了android.widget.ExpandableListView#PACKED_POSITION_TYPE_CHILD 实例代码,或者点击链接到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);
    }
}
 
static ExpandableListPosition obtainPosition(long packedPosition) {
  if (packedPosition == ExpandableListView.PACKED_POSITION_VALUE_NULL) {
    return null;
  }

  ExpandableListPosition elp = getRecycledOrCreate();
  elp.groupPos = ExpandableListView.getPackedPositionGroup(packedPosition);
  if (ExpandableListView.getPackedPositionType(packedPosition) ==
      ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
    elp.type = CHILD;
    elp.childPos = ExpandableListView.getPackedPositionChild(packedPosition);
  } else {
    elp.type = GROUP;
  }
  return elp;
}
 
源代码4 项目: 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);
    }
}
 
源代码5 项目: 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);
}
 
源代码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;
    }
}
 
源代码8 项目: 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);
	}
}
 
源代码11 项目: 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);
}
 
源代码12 项目: opentasks   文件: TaskListFragment.java
@Override
public int canFling(ListView v, int pos)
{
    long packedPos = mExpandableListView.getExpandableListPosition(pos);
    if (packedPos != ExpandableListView.PACKED_POSITION_VALUE_NULL
            && ExpandableListView.getPackedPositionType(packedPos) == ExpandableListView.PACKED_POSITION_TYPE_CHILD)
    {
        return FlingDetector.RIGHT_FLING | FlingDetector.LEFT_FLING;
    }
    else
    {
        return 0;
    }
}
 
源代码13 项目: 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);
    }
}
 
源代码14 项目: 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);
}
 
源代码15 项目: opentasks   文件: TaskListFragment.java
@Override
public boolean onFlingEnd(ListView v, View listElement, int pos, int direction)
{
    long packedPos = mExpandableListView.getExpandableListPosition(pos);
    if (ExpandableListView.getPackedPositionType(packedPos) == ExpandableListView.PACKED_POSITION_TYPE_CHILD)
    {
        ExpandableListAdapter listAdapter = mExpandableListView.getExpandableListAdapter();
        Cursor cursor = (Cursor) listAdapter.getChild(ExpandableListView.getPackedPositionGroup(packedPos),
                ExpandableListView.getPackedPositionChild(packedPos));

        if (cursor != null)
        {
            long instanceId = cursor.getLong(cursor.getColumnIndex(Instances._ID));

            boolean closed = cursor.getLong(cursor.getColumnIndex(Instances.IS_CLOSED)) > 0;
            String title = cursor.getString(cursor.getColumnIndex(Instances.TITLE));
            // TODO: use the instance URI once we support recurrence
            Uri taskUri = ContentUris.withAppendedId(Instances.getContentUri(mAuthority), instanceId);

            if (direction == FlingDetector.RIGHT_FLING)
            {
                if (closed)
                {
                    removeTask(taskUri, title);
                    // we do not know for sure if the task has been removed since the user is asked for confirmation first, so return false

                    return false;

                }
                else
                {
                    return setCompleteTask(taskUri, title, true);
                }
            }
            else if (direction == FlingDetector.LEFT_FLING)
            {
                if (closed)
                {
                    return setCompleteTask(taskUri, title, false);
                }
                else
                {
                    openTaskEditor(taskUri, cursor.getString(cursor.getColumnIndex(Instances.ACCOUNT_TYPE)));
                    return false;
                }
            }
        }
    }

    return false;
}