List of usage examples for android.widget ExpandableListView getPackedPositionGroup
public static int getPackedPositionGroup(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/*from www .j a va 2s. 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:id.nci.stm_9.KeyListSecretFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { ExpandableListContextMenuInfo expInfo = (ExpandableListContextMenuInfo) item.getMenuInfo(); // expInfo.id would also return row id of childs, but we always want to get the row id of // the group item, thus we are using the following way int groupPosition = ExpandableListView.getPackedPositionGroup(expInfo.packedPosition); long keyRingRowId = getExpandableListAdapter().getGroupId(groupPosition); // get master key id using row id long masterKeyId = ProviderHelper.getSecretMasterKeyId(mKeyListSecretActivity, keyRingRowId); boolean masterCanSign = ProviderHelper.getSecretMasterKeyCanSign(mKeyListSecretActivity, keyRingRowId); switch (item.getItemId()) { case 0x21070003: mKeyListSecretActivity.editKey(masterKeyId, masterCanSign); return true; default://from w w w .j a v a 2 s .c o m return super.onContextItemSelected(item); } }
From source file:org.sufficientlysecure.keychain.ui.KeyListSecretFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { ExpandableListContextMenuInfo expInfo = (ExpandableListContextMenuInfo) item.getMenuInfo(); // expInfo.id would also return row id of childs, but we always want to get the row id of // the group item, thus we are using the following way int groupPosition = ExpandableListView.getPackedPositionGroup(expInfo.packedPosition); long keyRingRowId = getExpandableListAdapter().getGroupId(groupPosition); // get master key id using row id long masterKeyId = ProviderHelper.getSecretMasterKeyId(mKeyListSecretActivity, keyRingRowId); boolean masterCanSign = ProviderHelper.getSecretMasterKeyCanSign(mKeyListSecretActivity, keyRingRowId); switch (item.getItemId()) { case Id.menu.edit: mKeyListSecretActivity.checkPassPhraseAndEdit(masterKeyId, masterCanSign); return true; default://from w ww .ja v a2 s .c om return super.onContextItemSelected(item); } }
From source file:dev.drsoran.moloko.fragments.TaskListsFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); final ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo; final RtmListWithTaskCount list = getRtmList( ExpandableListView.getPackedPositionGroup(info.packedPosition)); final String listName = list.getName(); final boolean listIsLocked = list.getLocked() != 0; if (isWritableAccess() && !listIsLocked) { getSherlockActivity().getMenuInflater().inflate(R.menu.tasklists_group_context_rwd, menu); menu.findItem(R.id.ctx_menu_delete_list).setTitle(getString(R.string.phr_delete_with_name, listName)); menu.findItem(R.id.ctx_menu_rename_list) .setTitle(getString(R.string.tasklists_menu_ctx_rename_list, listName)); } else {/*from w w w. j ava2 s . c o m*/ getSherlockActivity().getMenuInflater().inflate(R.menu.tasklists_group_context, menu); } if (getExpandableListView() .isGroupExpanded(ExpandableListView.getPackedPositionGroup(info.packedPosition))) { menu.findItem(R.id.ctx_menu_collapse).setVisible(true) .setTitle(getString(R.string.tasklists_menu_ctx_collapse, listName)); menu.findItem(R.id.ctx_menu_expand).setVisible(false); } else { menu.findItem(R.id.ctx_menu_expand).setVisible(true) .setTitle(getString(R.string.tasklists_menu_ctx_expand, listName)); menu.findItem(R.id.ctx_menu_collapse).setVisible(false); } final boolean isDefaultList = list.getId() .equals(MolokoApp.getSettings(getSherlockActivity()).getDefaultListId()); menu.findItem(R.id.ctx_menu_set_default_list).setVisible(!isDefaultList); menu.findItem(R.id.ctx_menu_unset_default_list).setVisible(isDefaultList); }
From source file:org.sufficientlysecure.keychain.ui.KeyListPublicFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { ExpandableListContextMenuInfo expInfo = (ExpandableListContextMenuInfo) item.getMenuInfo(); // expInfo.id would also return row id of childs, but we always want to get the row id of // the group item, thus we are using the following way int groupPosition = ExpandableListView.getPackedPositionGroup(expInfo.packedPosition); long keyRingRowId = getExpandableListAdapter().getGroupId(groupPosition); switch (item.getItemId()) { case Id.menu.update: long updateKeyId = 0; PGPPublicKeyRing updateKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(mKeyListActivity, keyRingRowId);/*from w w w . j a va2s .co m*/ if (updateKeyRing != null) { updateKeyId = PgpHelper.getMasterKey(updateKeyRing).getKeyID(); } if (updateKeyId == 0) { // this shouldn't happen return true; } Intent queryIntent = new Intent(mKeyListActivity, KeyServerQueryActivity.class); queryIntent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID_AND_RETURN); queryIntent.putExtra(KeyServerQueryActivity.EXTRA_KEY_ID, updateKeyId); // TODO: lookup?? startActivityForResult(queryIntent, Id.request.look_up_key_id); return true; case Id.menu.exportToServer: Intent uploadIntent = new Intent(mKeyListActivity, KeyServerUploadActivity.class); uploadIntent.setAction(KeyServerUploadActivity.ACTION_EXPORT_KEY_TO_SERVER); uploadIntent.putExtra(KeyServerUploadActivity.EXTRA_KEYRING_ROW_ID, keyRingRowId); startActivityForResult(uploadIntent, Id.request.export_to_server); return true; case Id.menu.signKey: long keyId = 0; PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(mKeyListActivity, keyRingRowId); if (signKeyRing != null) { keyId = PgpHelper.getMasterKey(signKeyRing).getKeyID(); } if (keyId == 0) { // this shouldn't happen return true; } Intent signIntent = new Intent(mKeyListActivity, SignKeyActivity.class); signIntent.putExtra(SignKeyActivity.EXTRA_KEY_ID, keyId); startActivity(signIntent); return true; case Id.menu.share_qr_code: // get master key id using row id long masterKeyId = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId); Intent qrCodeIntent = new Intent(mKeyListActivity, ShareActivity.class); qrCodeIntent.setAction(ShareActivity.ACTION_SHARE_KEYRING_WITH_QR_CODE); qrCodeIntent.putExtra(ShareActivity.EXTRA_MASTER_KEY_ID, masterKeyId); startActivityForResult(qrCodeIntent, 0); return true; case Id.menu.share_nfc: // get master key id using row id long masterKeyId2 = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId); Intent nfcIntent = new Intent(mKeyListActivity, ShareNfcBeamActivity.class); nfcIntent.setAction(ShareNfcBeamActivity.ACTION_SHARE_KEYRING_WITH_NFC); nfcIntent.putExtra(ShareNfcBeamActivity.EXTRA_MASTER_KEY_ID, masterKeyId2); startActivityForResult(nfcIntent, 0); return true; case Id.menu.share: // get master key id using row id long masterKeyId3 = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId); Intent shareIntent = new Intent(mKeyListActivity, ShareActivity.class); shareIntent.setAction(ShareActivity.ACTION_SHARE_KEYRING); shareIntent.putExtra(ShareActivity.EXTRA_MASTER_KEY_ID, masterKeyId3); startActivityForResult(shareIntent, 0); return true; default: return super.onContextItemSelected(item); } }
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. java 2s. 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);//from w w w.j a v a2 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:id.nci.stm_9.KeyListPublicFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { ExpandableListContextMenuInfo expInfo = (ExpandableListContextMenuInfo) item.getMenuInfo(); // expInfo.id would also return row id of childs, but we always want to get the row id of // the group item, thus we are using the following way int groupPosition = ExpandableListView.getPackedPositionGroup(expInfo.packedPosition); long keyRingRowId = getExpandableListAdapter().getGroupId(groupPosition); switch (item.getItemId()) { // case Id.menu.update: case 0x21070004: long updateKeyId = 0; PGPPublicKeyRing updateKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(mKeyListActivity, keyRingRowId);/*from ww w .j av a 2 s. c om*/ if (updateKeyRing != null) { updateKeyId = PgpKeyHelper.getMasterKey(updateKeyRing).getKeyID(); } if (updateKeyId == 0) { // this shouldn't happen return true; } Intent queryIntent = new Intent(mKeyListActivity, KeyServerQueryActivity.class); queryIntent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID_AND_RETURN); queryIntent.putExtra(KeyServerQueryActivity.EXTRA_KEY_ID, updateKeyId); // TODO: lookup?? // startActivityForResult(queryIntent, Id.request.look_up_key_id); startActivityForResult(queryIntent, 0x00007006); return true; // case Id.menu.exportToServer: case 0x21070005: Intent uploadIntent = new Intent(mKeyListActivity, KeyServerUploadActivity.class); uploadIntent.setAction(KeyServerUploadActivity.ACTION_EXPORT_KEY_TO_SERVER); uploadIntent.putExtra(KeyServerUploadActivity.EXTRA_KEYRING_ROW_ID, (int) keyRingRowId); // startActivityForResult(uploadIntent, Id.request.export_to_server); startActivityForResult(uploadIntent, 0x00007007); return true; // case Id.menu.signKey: // long keyId = 0; // PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId( // mKeyListActivity, keyRingRowId); // if (signKeyRing != null) { // keyId = PgpKeyHelper.getMasterKey(signKeyRing).getKeyID(); // } // if (keyId == 0) { // // this shouldn't happen // return true; // } // // Intent signIntent = new Intent(mKeyListActivity, SignKeyActivity.class); // signIntent.putExtra(SignKeyActivity.EXTRA_KEY_ID, keyId); // startActivity(signIntent); // // return true; // // case Id.menu.share_qr_code: // // get master key id using row id // long masterKeyId = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId); // // Intent qrCodeIntent = new Intent(mKeyListActivity, ShareActivity.class); // qrCodeIntent.setAction(ShareActivity.ACTION_SHARE_KEYRING_WITH_QR_CODE); // qrCodeIntent.putExtra(ShareActivity.EXTRA_MASTER_KEY_ID, masterKeyId); // startActivityForResult(qrCodeIntent, 0); // // return true; // // case Id.menu.share_nfc: // // get master key id using row id // long masterKeyId2 = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId); // // Intent nfcIntent = new Intent(mKeyListActivity, ShareNfcBeamActivity.class); // nfcIntent.setAction(ShareNfcBeamActivity.ACTION_SHARE_KEYRING_WITH_NFC); // nfcIntent.putExtra(ShareNfcBeamActivity.EXTRA_MASTER_KEY_ID, masterKeyId2); // startActivityForResult(nfcIntent, 0); // // return true; // // case Id.menu.share: // // get master key id using row id // long masterKeyId3 = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId); // // Intent shareIntent = new Intent(mKeyListActivity, ShareActivity.class); // shareIntent.setAction(ShareActivity.ACTION_SHARE_KEYRING); // shareIntent.putExtra(ShareActivity.EXTRA_MASTER_KEY_ID, masterKeyId3); // startActivityForResult(shareIntent, 0); // // return true; default: return super.onContextItemSelected(item); } }
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 ww.j a v a 2s. co 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); }