List of usage examples for android.widget ExpandableListView getPackedPositionGroup
public static int getPackedPositionGroup(long packedPosition)
From source file:com.jbirdvegas.mgerrit.PatchSetViewerFragment.java
private void init() { View currentFragment = this.getView(); ExpandableListView mListView = (ExpandableListView) currentFragment.findViewById(R.id.commit_cards); disconnectedView = currentFragment.findViewById(R.id.disconnected_view); sIsLegacyVersion = !Config.isDiffSupported(mParent); mAdapter = new CommitDetailsAdapter(mParent); mListView.setAdapter(mAdapter);/*from ww w . j a va 2 s . c om*/ // Child click listeners (relevant for the changes cards) mListView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mFilesCAB = new FilesCAB(mParent, !sIsLegacyVersion); mAdapter.setContextualActionBar(mFilesCAB); mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { ExpandableListView listView = (ExpandableListView) parent; long pos = listView.getExpandableListPosition(position); int groupPos = ExpandableListView.getPackedPositionGroup(pos); int childPos = ExpandableListView.getPackedPositionChild(pos); if (!mAdapter.isLongClickSupported(groupPos, childPos)) { return false; } // In case this is a group view and does not have the change number tagged view.setTag(R.id.changeID, mSelectedChange); FilesCAB.TagHolder holder = new FilesCAB.TagHolder(view, mContext, groupPos, childPos >= 0); // Set the title to be shown in the action bar if (holder.filePath != null) { mFilesCAB.setTitle(holder.filePath); } else { String s = mParent.getResources().getString(R.string.change_detail_heading); mFilesCAB.setTitle(String.format(s, holder.changeNumber.intValue())); } mFilesCAB.setActionMode(getActivity().startActionMode(mFilesCAB)); ActionMode actionMode = mFilesCAB.getActionMode(); // Call requires API 14 (ICS) actionMode.setTag(holder); view.setSelected(true); return true; } }); mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { // This is only valid for the changed files group int childItemType = mAdapter.getChildType(groupPosition, childPosition); if (childItemType != CommitDetailsAdapter.Cards.CHANGED_FILES.ordinal()) { return false; } // View the diff and close the CAB if a change diff could be viewed boolean diffLaunched = PatchSetChangesCard.onViewClicked(mParent, v); if (diffLaunched) { ActionMode mode = mFilesCAB.getActionMode(); if (mode != null) mode.finish(); } return diffLaunched; } }); mUrl = new GerritURL(); Button retryButton = (Button) currentFragment.findViewById(R.id.btn_retry); retryButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (sIsLegacyVersion) sendRequest(GerritService.DataType.Commit); else sendRequest(GerritService.DataType.LegacyCommitDetails); } }); if (getArguments() == null) { /** This should be the default value of {@link ChangeListFragment.mSelectedStatus } */ setStatus(JSONCommit.Status.NEW.toString()); loadChange(true); } else { Bundle args = getArguments(); setStatus(args.getString(STATUS)); String changeid = args.getString(CHANGE_ID); mChangeNumber = args.getInt(CHANGE_NO); if (changeid != null && !changeid.isEmpty()) { loadChange(changeid); } } mEventBus = EventBus.getDefault(); }
From source file:dev.drsoran.moloko.fragments.TaskListsFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { final ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.ctx_menu_expand: getExpandableListView().expandGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition)); return true; case R.id.ctx_menu_collapse: getExpandableListView().collapseGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition)); return true; case R.id.ctx_menu_delete_list: if (listener != null) listener.deleteList(ExpandableListView.getPackedPositionGroup(info.packedPosition)); return true; case R.id.ctx_menu_rename_list: if (listener != null) listener.renameList(ExpandableListView.getPackedPositionGroup(info.packedPosition)); return true; case R.id.ctx_menu_set_default_list: setAsDefaultList(ExpandableListView.getPackedPositionGroup(info.packedPosition)); return true; case R.id.ctx_menu_unset_default_list: resetDefaultList();//from ww w.j a v a 2 s . c om return true; default: return super.onContextItemSelected(item); } }
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;//from w ww.j a va 2s . 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.peercast.core.PeerCastFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { PeerCastServiceController controller = getActivity2().getPeerCastServiceController(); ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item .getMenuInfo();//from w w w . java 2 s.com int type = ExpandableListView.getPackedPositionType(info.packedPosition); int gPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); int cPos = ExpandableListView.getPackedPositionChild(info.packedPosition); Channel ch = (Channel) mListAdapter.getGroup(gPos); switch (item.getItemId()) { case R.id.menu_ch_disconnect: Log.i(TAG, "Disconnect channel: " + ch); controller.disconnectChannel(ch.getChannel_ID()); return true; case R.id.menu_ch_keep: Log.i(TAG, "Keep channel: " + ch); controller.setChannelKeep(ch.getChannel_ID(), !item.isChecked()); return true; case R.id.menu_ch_play: Uri u = getStreamUri(ch); Intent intent = new Intent(Intent.ACTION_VIEW, u); try { showToast(u.toString()); startActivity(intent); } catch (ActivityNotFoundException e) { getActivity2().showAlertDialog(R.string.t_error, e.getLocalizedMessage(), false); } return true; case R.id.menu_ch_bump: Log.i(TAG, "Bump channel: " + ch); controller.bumpChannel(ch.getChannel_ID()); return true; case R.id.menu_svt_disconnect: // Servent svt = (Servent) mListAdapter.getChild(gPos, cPos); Log.i(TAG, "Disconnect servent: " + svt); controller.disconnectServent(svt.getServent_ID()); return true; default: return super.onContextItemSelected(item); } }
From source file:com.robandjen.comicsapp.FullscreenActivity.java
void showCurrentComic(String url) { if (url == null || url.isEmpty()) { url = mComicList.get(mCurComic).getURL(); }// w w w .ja va2 s . co m final WebView contentView = (WebView) findViewById(R.id.fullscreen_content); contentView.stopLoading(); //Load about:blank to clear any extra data and have a well defined URL in history contentView.loadUrl("about:blank"); contentView.loadUrl(url); contentView.clearHistory(); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setTitle(mComicList.get(mCurComic).getName()); } updateShare(url); ExpandableListView elv = (ExpandableListView) findViewById(R.id.comic_drawer); long packedPos = mAdapter.comicsPosToPackedPos(mCurComic); //Selection doesn't work if expandGroup isn't called or group already expanded. ????? elv.expandGroup(ExpandableListView.getPackedPositionGroup(packedPos)); elv.setSelectedChild(ExpandableListView.getPackedPositionGroup(packedPos), ExpandableListView.getPackedPositionChild(packedPos), true); elv.setItemChecked(elv.getFlatListPosition(packedPos), true); }
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 w w w. java2 s .com*/ 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:org.envirocar.app.activity.ListTracksFragment.java
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); setHasOptionsMenu(true);//from w ww. j av a 2 s .c o m View v = inflater.inflate(R.layout.list_tracks_layout, null); trackListView = (ExpandableListView) v.findViewById(R.id.list); statusProgressBar = v.findViewById(R.id.list_tracks_status_progress); statusText = (TextView) v.findViewById(R.id.list_tracks_status_text); setProgressStatusText(R.string.fetching_tracks); trackListView.setEmptyView(v.findViewById(R.id.empty)); registerForContextMenu(trackListView); trackListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { itemSelect = ExpandableListView.getPackedPositionGroup(id); logger.info(String.valueOf("Selected item: " + itemSelect)); return false; } }); return v; }
From source file:dev.drsoran.moloko.fragments.TaskListsFragment.java
@Override public void onGroupIndicatorClicked(View groupView) { final ExpandableListView listView = getExpandableListView(); final int pos = ExpandableListView .getPackedPositionGroup(listView.getExpandableListPosition(listView.getPositionForView(groupView))); if (listView.isGroupExpanded(pos)) listView.collapseGroup(pos);/*from w ww . j a v a 2 s . c o m*/ else listView.expandGroup(pos); }
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(// ww w . j a va2 s . c o 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:com.login.home.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; String title = ((TextView) info.targetView).getText().toString(); menu.setHeaderTitle(title);//from w w w. ja v a 2 s. co m int type = ExpandableListView.getPackedPositionType(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { super.onCreateContextMenu(menu, v, menuInfo); int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); if (groupPos == 1 || groupPos == 0) { menu.add(1, 0, 0, "ACCEPT"); menu.add(1, 1, 0, "DECLINE"); menu.add(1, 2, 0, "SHOW INFO"); } else if (groupPos == 2) { menu.add(1, 0, 0, "SHOW INFO"); menu.add(1, 1, 0, "SHOW ON A MAP"); menu.add(1, 2, 0, "WILL NOT ATTEND"); } } }