List of usage examples for android.widget ExpandableListView PACKED_POSITION_TYPE_GROUP
int PACKED_POSITION_TYPE_GROUP
To view the source code for android.widget ExpandableListView PACKED_POSITION_TYPE_GROUP.
Click Source Link
From source file:com.arcusapp.soundbox.fragment.ArtistsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_artists, container, false); ExpandableListView myExpandableList = (ExpandableListView) rootView .findViewById(R.id.expandableListArtists); myExpandableList.setGroupIndicator(null); myExpandableList.setOnItemLongClickListener(new OnItemLongClickListener() { @Override/*from ww w . j a v a 2 s .co m*/ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { int groupPosition = ExpandableListView.getPackedPositionGroup(id); myAdapter.onArtistLongClick(groupPosition); return true; } else if (ExpandableListView .getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { int groupPosition = ExpandableListView.getPackedPositionGroup(id); int childPosition = ExpandableListView.getPackedPositionChild(id); myAdapter.onAlbumLongClick(groupPosition, childPosition); return true; } return false; } }); myExpandableList.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { myAdapter.onAlbumClick(groupPosition, childPosition); return false; } }); myExpandableList.setAdapter(myAdapter); return rootView; }
From source file:org.peercast.core.PeerCastFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int type = ExpandableListView.getPackedPositionType(info.packedPosition); int gPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); int cPos = ExpandableListView.getPackedPositionChild(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { // ??//from w w w. ja v a2 s . co m getActivity().getMenuInflater().inflate(R.menu.channel_context_menu, menu); Channel ch = mListAdapter.getGroup(gPos); menu.setHeaderTitle(ch.getInfo().getName()); MenuItem mKeep = menu.findItem(R.id.menu_ch_keep); mKeep.setChecked(ch.isStayConnected()); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { // getActivity().getMenuInflater().inflate(R.menu.servent_context_menu, menu); Servent svt = mListAdapter.getChild(gPos, cPos); menu.setHeaderTitle(svt.getHost()); } }
From source file:org.totschnig.myexpenses.fragment.PlanList.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo; int type = ExpandableListView.getPackedPositionType(info.packedPosition); // Menu entries relevant only for the group if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { super.onCreateContextMenu(menu, v, menuInfo); } else {/*w ww. jav a 2s.co m*/ Long transactionId = mInstance2TransactionMap.get(info.id); if (transactionId == null) { //state open menu.add(0, R.id.CREATE_INSTANCE_SAVE_COMMAND, 0, R.string.menu_apply_template_and_save); menu.add(0, R.id.CREATE_INSTANCE_EDIT_COMMAND, 0, R.string.menu_apply_template_and_edit); menu.add(0, R.id.CANCEL_PLAN_INSTANCE_COMMAND, 0, R.string.menu_cancel_plan_instance); } else if (transactionId == 0L) { //state cancelled menu.add(0, R.id.RESET_PLAN_INSTANCE_COMMAND, 0, R.string.menu_reset_plan_instance); } else { //state applied menu.add(0, R.id.EDIT_COMMAND, 0, R.string.menu_edit); menu.add(0, R.id.CANCEL_PLAN_INSTANCE_COMMAND, 0, R.string.menu_cancel_plan_instance); menu.add(0, R.id.RESET_PLAN_INSTANCE_COMMAND, 0, R.string.menu_reset_plan_instance); } } }
From source file:org.yammp.app.ArtistFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) { ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) info; int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition); mSelectedGroupPosition = ExpandableListView.getPackedPositionGroup(mi.packedPosition); int gpos = mSelectedGroupPosition; mSelectedGroupId = mGroupCursor.getLong(mGroupArtistIdIdx); if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { mGroupSelected = true;/* w w w .java 2 s . co m*/ mChildSelected = false; getSherlockActivity().getMenuInflater().inflate(R.menu.music_browser_item, menu); if (gpos == -1) { // this shouldn't happen Log.d("Artist/Album", "no group"); return; } gpos = gpos - mListView.getHeaderViewsCount(); mGroupCursor.moveToPosition(gpos); mCurrentGroupArtistName = mGroupCursor.getString(mGroupArtistIdx); if (mCurrentGroupArtistName == null || MediaStore.UNKNOWN_STRING.equals(mCurrentGroupArtistName)) { menu.setHeaderTitle(getString(R.string.unknown_artist)); menu.findItem(R.id.search).setEnabled(false); menu.findItem(R.id.search).setVisible(false); } else { menu.setHeaderTitle(mCurrentGroupArtistName); } } }
From source file:org.totschnig.myexpenses.fragment.PlanList.java
@Override public boolean onContextItemSelected(MenuItem item) { if (!getUserVisibleHint()) return false; ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo(); if (ExpandableListView .getPackedPositionType(info.packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) return ((ManageTemplates) getActivity()).dispatchCommand(item.getItemId(), info.id); int group = ExpandableListView.getPackedPositionGroup(info.packedPosition), child = ExpandableListView.getPackedPositionChild(info.packedPosition); Cursor c = mAdapter.getChild(group, child); long date = c.getLong(c.getColumnIndex(Instances.BEGIN)); long templateId = mTemplatesCursor.getLong(columnIndexRowId); Long transactionId = mInstance2TransactionMap.get(info.id); Intent i;//from www . jav a 2s. c o m switch (item.getItemId()) { case R.id.CREATE_INSTANCE_EDIT_COMMAND: i = new Intent(getActivity(), ExpenseEdit.class); i.putExtra("template_id", templateId); i.putExtra("instance_id", info.id); i.putExtra("instance_date", date); startActivity(i); return true; case R.id.CREATE_INSTANCE_SAVE_COMMAND: getActivity().getSupportFragmentManager().beginTransaction() .add(TaskExecutionFragment.newInstance(TaskExecutionFragment.TASK_NEW_FROM_TEMPLATE, templateId, new Long[] { info.id, date }), "ASYNC_TASK") .commit(); return true; case R.id.EDIT_COMMAND: i = new Intent(getActivity(), ExpenseEdit.class); i.putExtra(KEY_ROWID, transactionId); startActivity(i); return true; case R.id.CANCEL_PLAN_INSTANCE_COMMAND: getActivity().getSupportFragmentManager().beginTransaction() .add(TaskExecutionFragment.newInstance(TaskExecutionFragment.TASK_CANCEL_PLAN_INSTANCE, info.id, new Long[] { templateId, transactionId }), "ASYNC_TASK") .commit(); return true; case R.id.RESET_PLAN_INSTANCE_COMMAND: getActivity().getSupportFragmentManager().beginTransaction() .add(TaskExecutionFragment.newInstance(TaskExecutionFragment.TASK_RESET_PLAN_INSTANCE, info.id, transactionId), "ASYNC_TASK") .commit(); mInstance2TransactionMap.remove(info.id); return true; } return false; }
From source file:com.money.manager.ex.common.CategoryListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int type = ExpandableListView.getPackedPositionType(info.packedPosition); int group = ExpandableListView.getPackedPositionGroup(info.packedPosition); int child = ExpandableListView.getPackedPositionChild(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { menu.setHeaderTitle(mCategories.get(group).getName()); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { QueryCategorySubCategory subCategory = mSubCategories.get(mCategories.get(group)).get(child); menu.setHeaderTitle(/* w ww . ja va2 s. co m*/ subCategory.getCategName().toString() + ": " + subCategory.getSubcategoryName().toString()); } // context menu from resource menu.add(Menu.NONE, ContextMenuIds.EDIT.getId(), Menu.NONE, getString(R.string.edit)); menu.add(Menu.NONE, ContextMenuIds.DELETE.getId(), Menu.NONE, getString(R.string.delete)); menu.add(Menu.NONE, ContextMenuIds.VIEW_TRANSACTIONS.getId(), Menu.NONE, getString(R.string.view_transactions)); }
From source file:co.nerdart.ourss.fragment.FeedsListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.feed_list_fragment, container, false); mListView = (DragNDropExpandableListView) rootView.findViewById(android.R.id.list); mListAdapter.setExpandableListView(mListView); mListView.setFastScrollEnabled(true); mListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override/*from w w w . j a v a 2 s .c om*/ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { String title = ((TextView) view.findViewById(android.R.id.text1)).getText().toString(); Matcher m = Pattern.compile("(.*) \\([0-9]+\\)$").matcher(title); if (m.matches()) { title = m.group(1); } long feedId = mListView.getItemIdAtPosition(position); ActionMode actionMode; if (view.findViewById(R.id.indicator).getVisibility() == View.VISIBLE) { // This is a group actionMode = getActivity().startActionMode(mGroupActionModeCallback); } else { // This is a feed actionMode = getActivity().startActionMode(mFeedActionModeCallback); } actionMode.setTag(new Pair<Long, String>(feedId, title)); mListAdapter.setSelectedFeed(feedId); return true; } }); mListView.setAdapter(mListAdapter); mListView.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { mListAdapter.startFeedActivity(id); return false; } }); mListView.setDragNDropListener(new DragNDropListener() { boolean fromHasGroupIndicator = false; @Override public void onStopDrag(View itemView) { } @Override public void onStartDrag(View itemView) { fromHasGroupIndicator = itemView.findViewById(R.id.indicator).getVisibility() == View.VISIBLE; } @Override public void onDrop(final int flatPosFrom, final int flatPosTo) { final boolean fromIsGroup = ExpandableListView.getPackedPositionType(mListView .getExpandableListPosition(flatPosFrom)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP; final boolean toIsGroup = ExpandableListView.getPackedPositionType(mListView .getExpandableListPosition(flatPosTo)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP; final boolean fromIsFeedWithoutGroup = fromIsGroup && !fromHasGroupIndicator; View toView = mListView.getChildAt(flatPosTo - mListView.getFirstVisiblePosition()); boolean toIsFeedWithoutGroup = toIsGroup && toView.findViewById(R.id.indicator).getVisibility() != View.VISIBLE; final long packedPosTo = mListView.getExpandableListPosition(flatPosTo); final int packedGroupPosTo = ExpandableListView.getPackedPositionGroup(packedPosTo); if ((fromIsFeedWithoutGroup || !fromIsGroup) && toIsGroup && !toIsFeedWithoutGroup) { new AlertDialog.Builder(getActivity()) // .setTitle(R.string.to_group_title) // .setMessage(R.string.to_group_message) // .setPositiveButton(R.string.to_group_into, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ContentValues values = new ContentValues(); values.put(FeedColumns.PRIORITY, 1); values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatPosTo)); ContentResolver cr = getActivity().getContentResolver(); cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null); cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null); } }).setNegativeButton(R.string.to_group_above, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo, flatPosFrom); } }).show(); } else { moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo, flatPosFrom); } } @Override public void onDrag(int x, int y, ListView listView) { } }); return rootView; }
From source file:org.yammp.fragment.ArtistFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) { ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) info; int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition); mSelectedGroupPosition = ExpandableListView.getPackedPositionGroup(mi.packedPosition); int gpos = mSelectedGroupPosition; if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { mGroupSelected = true;/*from w w w . j av a 2 s .c o m*/ mChildSelected = false; mGroupCursor.moveToPosition(gpos); menu.add(hashCode(), PLAY_SELECTION, 0, R.string.play_selection); menu.add(hashCode(), DELETE_ITEMS, 0, R.string.delete_music); menu.add(hashCode(), DELETE_LYRICS, 0, R.string.delete_lyrics); if (gpos == -1) { // this shouldn't happen Log.d("Artist/Album", "no group"); return; } mCurrentGroupArtistName = mGroupCursor.getString(mGroupArtistIdx); mSelectedGroupId = mGroupCursor.getLong(mGroupArtistIdIdx); if (mCurrentGroupArtistName != null && !MediaStore.UNKNOWN_STRING.equals(mCurrentGroupArtistName)) { menu.setHeaderTitle(mCurrentGroupArtistName); menu.add(hashCode(), SEARCH, 0, android.R.string.search_go); } else { menu.setHeaderTitle(getString(R.string.unknown_artist)); } } }
From source file:com.money.manager.ex.common.CategoryListFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item .getMenuInfo();// w w w . j av a 2 s. c o m int type = ExpandableListView.getPackedPositionType(info.packedPosition); int group = ExpandableListView.getPackedPositionGroup(info.packedPosition); int child = ExpandableListView.getPackedPositionChild(info.packedPosition); CategorySub categoryIds = new CategorySub(); categoryIds.categId = Constants.NOT_SET; categoryIds.categName = ""; categoryIds.subCategId = Constants.NOT_SET; categoryIds.subCategName = ""; if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { categoryIds.categId = mCategories.get(group).getId(); categoryIds.categName = mCategories.get(group).getName(); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { categoryIds.categId = mSubCategories.get(mCategories.get(group)).get(child).getCategId(); categoryIds.subCategId = mSubCategories.get(mCategories.get(group)).get(child).getSubCategId(); categoryIds.subCategName = mSubCategories.get(mCategories.get(group)).get(child).getSubcategoryName() .toString(); } // manage select menu ContextMenuIds menuId = ContextMenuIds.get(item.getItemId()); switch (menuId) { case EDIT: if (categoryIds.subCategId == ExpandableListView.INVALID_POSITION) { showDialogEditCategoryName(SQLTypeTransaction.UPDATE, categoryIds.categId, categoryIds.categName); } else { showDialogEditSubCategoryName(SQLTypeTransaction.UPDATE, categoryIds.categId, categoryIds.subCategId, categoryIds.subCategName); } break; case DELETE: showDialogDeleteCategorySub(categoryIds); break; case VIEW_TRANSACTIONS: // view transactions SearchParameters parameters = new SearchParameters(); parameters.category = categoryIds; showSearchActivityFor(parameters); } return false; }
From source file:edu.chalmers.dat255.audiobookplayer.view.BookshelfFragment.java
@SuppressWarnings("rawtypes") @Override/* ww w .j ava 2 s .c o m*/ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // check that the menuInfo is of the correct type // this method is allowed to have quite a high cyclomatic complexity as // it would otherwise cause code duplication if (menuInfo instanceof ExpandableListContextMenuInfo && adapter != null) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo; // get the provided book position int bookIndex = ExpandableListView.getPackedPositionGroup(info.packedPosition); // trackIndex will be -1 if group is clicked int trackIndex = ExpandableListView.getPackedPositionChild(info.packedPosition); // get the type of the context menu int type = ExpandableListView.getPackedPositionType(info.packedPosition); // create an empty array to prevent trying to loop over an // uninitialized variable IContextMenuItem[] menuItems = new IContextMenuItem[0]; String title = ""; // fill the context menu with the correct items if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { // get all menu items from the child context menu menuItems = ChildContextMenuItem.values(); // set the context menu's title to that of the value of the // child title = adapter.getChild(bookIndex, trackIndex); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { // get all menu items from the group context menu menuItems = GroupContextMenuItem.values(); // set the context menu's title to that of the value of the book title = adapter.getGroup(bookIndex); } // set the title menu.setHeaderTitle(title); // populate the context menu with items in the order they were // declared in the enum declaration. for (IContextMenuItem item : menuItems) { // as this only loops when menuItems is of either of type // GroupContextMenuItem[] or ChildContextMenuItem[], Enum can be // used as a raw type menu.add(Menu.NONE, ((Enum) item).ordinal(), ((Enum) item).ordinal(), item.getText()); } } }