Java Code Examples for android.widget.ExpandableListView#getPackedPositionChild()
The following examples show how to use
android.widget.ExpandableListView#getPackedPositionChild() .
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 |
@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 |
@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: BigApp_Discuz_Android File: IphoneTreeView.java License: Apache License 2.0 | 6 votes |
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); final long flatPostion = getExpandableListPosition(getFirstVisiblePosition()); final int groupPos = ExpandableListView .getPackedPositionGroup(flatPostion); final int childPos = ExpandableListView .getPackedPositionChild(flatPostion); int state = mAdapter.getTreeHeaderState(groupPos, childPos); if (mHeaderView != null && mAdapter != null && state != mOldState) { mOldState = state; mHeaderView.layout(0, 0, mHeaderViewWidth, mHeaderViewHeight); } configureHeaderView(groupPos, childPos); }
Example 4
Source Project: expandable-recycler-view File: ExpandableListPosition.java License: MIT License | 6 votes |
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; }
Example 5
Source Project: 365browser File: RecentTabsPage.java License: Apache License 2.0 | 6 votes |
@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 6
Source Project: bither-android File: PinnedHeaderExpandableListView.java License: Apache License 2.0 | 6 votes |
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); final long flatPostion = getExpandableListPosition(getFirstVisiblePosition()); final int groupPos = ExpandableListView .getPackedPositionGroup(flatPostion); final int childPos = ExpandableListView .getPackedPositionChild(flatPostion); int state = mAdapter.getPinnedHeaderState(groupPos, childPos); if (mHeaderView != null && mAdapter != null && state != mOldState) { mOldState = state; mHeaderView.layout(0, 0, mHeaderViewWidth, mHeaderViewHeight); } configureHeaderView(groupPos, childPos); }
Example 7
Source Project: TreeView File: TreeView.java License: Apache License 2.0 | 6 votes |
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); final long listPosition = getExpandableListPosition(getFirstVisiblePosition()); final int groupPos = ExpandableListView.getPackedPositionGroup(listPosition); final int childPos = ExpandableListView.getPackedPositionChild(listPosition); int state = mUpdater.getHeaderState(groupPos, childPos); if (mHeaderView != null && mUpdater != null && state != mOldState) { mOldState = state; mHeaderView.layout(0, 0, mHeaderWidth, mHeaderHeight); } updateHeaderView(groupPos, childPos); }
Example 8
Source Project: zom-android-matrix File: VectorUtils.java License: Apache License 2.0 | 5 votes |
/** * Provides the visible child views. * The map key is the group position. * The map values are the visible child views. * * @param expandableListView the listview * @param adapter the linked adapter * @return visible views map */ public static Map<Integer, List<Integer>> getVisibleChildViews(ExpandableListView expandableListView, BaseExpandableListAdapter adapter) { Map<Integer, List<Integer>> map = new HashMap<>(); long firstPackedPosition = expandableListView.getExpandableListPosition(expandableListView.getFirstVisiblePosition()); int firstGroupPosition = ExpandableListView.getPackedPositionGroup(firstPackedPosition); int firstChildPosition = ExpandableListView.getPackedPositionChild(firstPackedPosition); long lastPackedPosition = expandableListView.getExpandableListPosition(expandableListView.getLastVisiblePosition()); int lastGroupPosition = ExpandableListView.getPackedPositionGroup(lastPackedPosition); int lastChildPosition = ExpandableListView.getPackedPositionChild(lastPackedPosition); for (int groupPos = firstGroupPosition; groupPos <= lastGroupPosition; groupPos++) { List<Integer> list = new ArrayList<>(); int startChildPos = (groupPos == firstGroupPosition) ? firstChildPosition : 0; int endChildPos = (groupPos == lastGroupPosition) ? lastChildPosition : adapter.getChildrenCount(groupPos) - 1; for (int index = startChildPos; index <= endChildPos; index++) { list.add(index); } map.put(groupPos, list); } return map; }
Example 9
Source Project: FireFiles File: RootsFragment.java License: Apache License 2.0 | 5 votes |
@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; } }
Example 10
Source Project: FireFiles File: RootsFragment.java License: Apache License 2.0 | 5 votes |
@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; } }
Example 11
Source Project: FireFiles File: RootsFragment.java License: Apache License 2.0 | 5 votes |
@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; } }
Example 12
Source Project: BigApp_Discuz_Android File: IphoneTreeView.java License: Apache License 2.0 | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { final long flatPos = getExpandableListPosition(firstVisibleItem); int groupPosition = ExpandableListView.getPackedPositionGroup(flatPos); int childPosition = ExpandableListView.getPackedPositionChild(flatPos); configureHeaderView(groupPosition, childPosition); }
Example 13
Source Project: PADListener File: ChooseSyncGroupedContextMenuHelper.java License: GNU General Public License v2.0 | 5 votes |
@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 14
Source Project: bither-android File: HotAddressFragment.java License: Apache License 2.0 | 5 votes |
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { PinnedHeaderAddressExpandableListView v = (PinnedHeaderAddressExpandableListView) view; final long flatPos = v.getExpandableListPosition(firstVisibleItem); int groupPosition = ExpandableListView.getPackedPositionGroup(flatPos); int childPosition = ExpandableListView.getPackedPositionChild(flatPos); v.configureHeaderView(groupPosition, childPosition); }
Example 15
Source Project: TreeView File: TreeView.java License: Apache License 2.0 | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { final long listPosition = getExpandableListPosition(firstVisibleItem); int groupPos = ExpandableListView.getPackedPositionGroup(listPosition); int childPos = ExpandableListView.getPackedPositionChild(listPosition); updateHeaderView(groupPos, childPos); }
Example 16
Source Project: document-viewer File: OPDSActivity.java License: GNU General Public License v3.0 | 5 votes |
/** * {@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); }
Example 17
Source Project: ListView-Swipe-to-Delete File: ItemExpListGestureDetector.java License: Apache License 2.0 | 5 votes |
@Override public boolean onSingleTapUp(MotionEvent e) { int pos = itemListHandler.getListView().pointToPosition((int) e.getX(), (int) e.getY()); if (pos < 0) { return true; } long expPos = itemListHandler.getListView().getExpandableListPosition(pos); int groupPos = ExpandableListView.getPackedPositionGroup(expPos); int childPos = ExpandableListView.getPackedPositionChild(expPos); if (childPos >= 0) { itemListHandler.onItemClicked(groupPos, childPos); } else { itemListHandler.onGroupClicked(groupPos); } return true; }
Example 18
Source Project: sa-sdk-android File: ViewUtil.java License: Apache License 2.0 | 4 votes |
public static ViewNode getViewNode(View view, int viewIndex) { int viewPosition = getViewPosition(view, viewIndex); ViewParent parentObject = view.getParent(); if (parentObject == null) { return null; } if (!WindowHelper.isDecorView(view.getClass()) || (parentObject instanceof View)) { if (parentObject instanceof View) { View parentView = (View) parentObject; StringBuilder opx = new StringBuilder(); StringBuilder px = new StringBuilder(); String viewName = ViewUtil.getCanonicalName(view.getClass()); Object fragment = null; String listPos = null; // 处理嵌套场景,如果父 View 是列表类型控件,将父 View 的列表位置传递给非列表类型子控件; 列表类型子控件则直接用自身位置。 ViewParent parent = parentView.getParent(); if (parent instanceof View) { View listParentView = (View) parent; if (sViewCache == null) { sViewCache = new SparseArray<String>(); } String parentPos = (String) sViewCache.get(listParentView.hashCode()); if (!TextUtils.isEmpty(parentPos)) { listPos = parentPos; } } if (parentView instanceof ExpandableListView) { ExpandableListView listParent = (ExpandableListView) parentView; long elp = listParent.getExpandableListPosition(viewPosition); if (ExpandableListView.getPackedPositionType(elp) != 2) { int groupIdx = ExpandableListView.getPackedPositionGroup(elp); int childIdx = ExpandableListView.getPackedPositionChild(elp); if (childIdx != -1) { listPos = String.format(Locale.CHINA, "%d:%d", groupIdx, childIdx); px.append(opx).append("/ELVG[").append(groupIdx).append("]/ELVC[-]/").append(viewName).append("[0]"); opx.append("/ELVG[").append(groupIdx).append("]/ELVC[").append(childIdx).append("]/").append(viewName).append("[0]"); } else { listPos = String.format(Locale.CHINA, "%d", groupIdx); px.append(opx).append("/ELVG[-]/").append(viewName).append("[0]"); opx.append("/ELVG[").append(groupIdx).append("]/").append(viewName).append("[0]"); } } else if (viewPosition < listParent.getHeaderViewsCount()) { opx.append("/ELH[").append(viewPosition).append("]/").append(viewName).append("[0]"); px.append("/ELH[").append(viewPosition).append("]/").append(viewName).append("[0]"); } else { int footerIndex = viewPosition - (listParent.getCount() - listParent.getFooterViewsCount()); opx.append("/ELF[").append(footerIndex).append("]/").append(viewName).append("[0]"); px.append("/ELF[").append(footerIndex).append("]/").append(viewName).append("[0]"); } } else if (ViewUtil.isListView(parentView)) { listPos = String.format(Locale.CHINA, "%d", viewPosition); px.append(opx).append("/").append(viewName).append("[-]"); opx.append("/").append(viewName).append("[").append(listPos).append("]"); } else if (ViewUtil.instanceOfSupportSwipeRefreshLayout(parentView)) { opx.append("/").append(viewName).append("[0]"); px.append("/").append(viewName).append("[0]"); } else if ((fragment = ViewUtil.instanceOfFragmentRootView(parentView, view)) != null) { viewName = ViewUtil.getCanonicalName(fragment.getClass()); opx.append("/").append(viewName).append("[0]"); px.append("/").append(viewName).append("[0]"); } else { viewPosition = VisualUtil.getChildIndex(parentObject, view); opx.append("/").append(viewName).append("[").append(viewPosition).append("]"); px.append("/").append(viewName).append("[").append(viewPosition).append("]"); } if (WindowHelper.isDecorView(parentView.getClass())) { if (opx.length() > 0) { opx.deleteCharAt(0); } if (px.length() > 0) { px.deleteCharAt(0); } } if (!TextUtils.isEmpty(listPos)) { if (sViewCache == null) { sViewCache = new SparseArray<String>(); } sViewCache.put(parentView.hashCode(), listPos); } ViewNode viewNode = getViewContentAndType(view); return new ViewNode(listPos, opx.toString(), px.toString(), viewNode.getViewContent(), viewNode.getViewType()); } } return null; }
Example 19
Source Project: PADListener File: ChooseSyncGroupedContextMenuHelper.java License: GNU General Public License v2.0 | 4 votes |
private boolean isGroup(ContextMenu.ContextMenuInfo menuInfo) { ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int childPosition = ExpandableListView.getPackedPositionChild(listItem.packedPosition); return childPosition == -1; }
Example 20
Source Project: 4pdaClient-plus File: LeadersListFragment.java License: Apache License 2.0 | 4 votes |
@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); } }