List of usage examples for android.widget ExpandableListView getPackedPositionChild
public static int getPackedPositionChild(long packedPosition)
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/*w w w. j ava2 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 ww . j av a2s . c o 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:com.kaproduction.malibilgiler.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); coordinatorLayoutMainActivity = (CoordinatorLayout) findViewById(R.id.coordinatorLayoutMainActivity); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// w w w . ja v a 2 s . co m getSupportActionBar().setIcon(R.mipmap.ic_launcher1); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); //Deneme Yourum Yazildi...... NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); expandableListView = (ExpandableListView) findViewById(R.id.exp_list); mCategory = ExpandableListViewData.getInfo(); mlist = new ArrayList<String>(mCategory.keySet()); adapter = new ExpandableListViewAdapter(this, mCategory, mlist); expandableListView.setAdapter(adapter); expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView expandableListView, View view, int parent, int child, long l) { String heading = (String) adapter.getGroup(parent); String message = (String) adapter.getChild(parent, child); alertDialog(heading, message); // Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show(); return true; } }); expandableListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) { if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { int groupPosition = ExpandableListView.getPackedPositionGroup(id); int childPosition = ExpandableListView.getPackedPositionChild(id); String text = (String) adapter.getChild(groupPosition, childPosition); String heading = (String) adapter.getGroup(groupPosition); alertDialogForClipboard(heading, text); } return true; } }); }
From source file:org.openmidaas.app.activities.AttributeListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mFragmentActiviy = (FragmentActivity) super.getActivity(); mRelativeLayout = (RelativeLayout) inflater.inflate(R.layout.attribute_list_view, container, false); mAttributeListView = (ExpandableListView) mRelativeLayout.findViewById(R.id.listViewAttributes); mAttributeListView.setClickable(true); mAttributeListView.setItemsCanFocus(true); mAttributeListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mAdapter = new AttributeExpandableListAdapter(mFragmentActiviy); mAttributeListView.setAdapter(mAdapter); mAttributeListView.setOnChildClickListener(new OnChildClickListener() { @Override// w w w . j a va 2 s . c o m public boolean onChildClick(ExpandableListView arg0, View arg1, int groupPosition, int childPosition, long id) { OnListElementTouch element = (OnListElementTouch) mAdapter.getChild(groupPosition, childPosition); if (element != null) { element.onTouch(mFragmentActiviy); } return false; } }); mAttributeListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { OnListElementLongTouch element = (OnListElementLongTouch) mAdapter.getChild( ExpandableListView.getPackedPositionGroup(id), ExpandableListView.getPackedPositionChild(id)); if (element != null) { element.onLongTouch(mFragmentActiviy); } return true; } return false; } }); return mRelativeLayout; }
From source file:com.aboveware.actionbar.honeycomb.ExpandableListFragment.java
@Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long packedPosition) { int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition); int childPosition = ExpandableListView.getPackedPositionChild(packedPosition); return mAdapter.onItemLongClick(groupPosition, childPosition); }
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 o m // 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:org.peercast.core.PeerCastFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { PeerCastServiceController controller = getActivity2().getPeerCastServiceController(); ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item .getMenuInfo();/*from ww w . j av a 2s.co m*/ 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: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 ww w. ja v 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.robandjen.comicsapp.FullscreenActivity.java
void showCurrentComic(String url) { if (url == null || url.isEmpty()) { url = mComicList.get(mCurComic).getURL(); }/*from w w w. j a v a2s .c o 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: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 w w .j a v a 2 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)); }