List of usage examples for android.widget ExpandableListView getPackedPositionType
public static int getPackedPositionType(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 w w w . j a va 2 s .c o 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.tigase.mobile.roster.RosterFragment.java
private static long extractId(ContextMenuInfo menuInfo) { if (menuInfo instanceof ExpandableListContextMenuInfo) { int type = ExpandableListView .getPackedPositionType(((ExpandableListContextMenuInfo) menuInfo).packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { return ((ExpandableListContextMenuInfo) menuInfo).id; } else/*w ww . j a va 2 s . com*/ return -1; } else if (menuInfo instanceof AdapterContextMenuInfo) { return ((AdapterContextMenuInfo) menuInfo).id; } else { return -1; } }
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. c o 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.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) { // ??//w w w. j av a2 s. c om 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.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/*from w ww. j a v a 2s .com*/ 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: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 {//from w ww. j a v a 2s. c o 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:can.yrt.onebusaway.RouteInfoListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; if (ExpandableListView .getPackedPositionType(info.packedPosition) != ExpandableListView.PACKED_POSITION_TYPE_CHILD) { return;// w w w . j a v a2 s .c o m } final TextView text = (TextView) info.targetView.findViewById(R.id.name); menu.setHeaderTitle(text.getText()); menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.route_info_context_get_stop_info); menu.add(0, CONTEXT_MENU_SHOWONMAP, 0, R.string.route_info_context_showonmap); }
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 ww w . ja v a 2 s . com*/ 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 2s . c om 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 w ww. j av a 2 s.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; }