List of usage examples for android.widget AbsListView CHOICE_MODE_MULTIPLE_MODAL
int CHOICE_MODE_MULTIPLE_MODAL
To view the source code for android.widget AbsListView CHOICE_MODE_MULTIPLE_MODAL.
Click Source Link
From source file:com.shafiq.mytwittle.view.TweetFeedFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); mProfileImageLoader = getApp().getProfileImageLoader(); mPreviewImageLoader = getApp().getPreviewImageLoader(); mContentHandle = TwitterManager.get().getContentHandle(getContentHandleBase(), getScreenName(), getLaneIdentifier(), getApp().getCurrentAccountKey()); View resultView = inflater.inflate(R.layout.lane, null); configureLaneWidth(resultView);/*from www . j a v a 2s. c om*/ mViewSwitcher = (ViewSwitcher) resultView.findViewById(R.id.profileSwitcher); mListHeadingTextView = (TextView) resultView.findViewById(R.id.list_heading); mListHeadingHideImage = (ImageView) resultView.findViewById(R.id.list_hide); mListHeadingHideImage.setOnClickListener(mListHeadingHideImageOnClickListener); mMultipleTweetSelectionCallback = new MultipleTweetSelectionCallback(); mTweetFeedListAdapter = new TweetFeedListAdapter(inflater); mTweetFeedListView = (PullToRefreshListView) resultView.findViewById(R.id.pull_to_refresh_listview); mTweetFeedListView.getRefreshableView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); mTweetFeedListView.getRefreshableView().setMultiChoiceModeListener(mMultipleTweetSelectionCallback); mTweetFeedListView.getRefreshableView().setOnScrollListener(mTweetFeedOnScrollListener); mTweetFeedListView.getRefreshableView().setAdapter(mTweetFeedListAdapter); mTweetFeedListView.setOnRefreshListener(mTweetFeedOnRefreshListener); mTweetFeedListView.setOnLastItemVisibleListener(mTweetFeedOnLastItemVisibleListener); configureInitialStatuses(); mRefreshTimestampsHandler.removeCallbacks(mRefreshTimestampsTask); mRefreshTimestampsHandler.postDelayed(mRefreshTimestampsTask, REFRESH_TIMESTAMPS_INTERVAL); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mVolumeUpKeyDownReceiver, new IntentFilter("" + SystemEvent.VOLUME_UP_KEY_DOWN)); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mVolumeDownKeyDownReceiver, new IntentFilter("" + SystemEvent.VOLUME_DOWN_KEY_DOWN)); return resultView; }
From source file:net.lp.actionbarpoirot.helpers.FragmentHelperHoneycomb.java
protected void configureViewGroupContextMenu(AbsListView viewGroup, boolean multiChoiceMode) { mAdapter = viewGroup;//from w ww.ja va 2 s.com viewGroup.setOnItemLongClickListener(this); if (multiChoiceMode) { ensureMultiChoiceModeUser(); viewGroup.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); viewGroup.setMultiChoiceModeListener(this); } else { viewGroup.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); } }
From source file:com.audiokernel.euphonyrmt.fragments.QueueFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); mRootView = container;/* w w w .ja v a 2 s . c o m*/ final View view = inflater.inflate(R.layout.playlist_activity, container, false); mSearchView = (SearchView) view.findViewById(R.id.search); mSearchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextChange(final String newText) { mFilter = newText; if (newText != null && newText.isEmpty()) { mFilter = null; } if (mFilter != null) { mFilter = mFilter.toLowerCase(); } mList.setDragEnabled(mFilter == null); update(false); return false; } @Override public boolean onQueryTextSubmit(final String query) { // Hide the keyboard and give focus to the list final InputMethodManager imm = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0); mList.requestFocus(); return true; } }); mList = (DragSortListView) view.findViewById(android.R.id.list); mList.requestFocus(); mList.setDropListener(mDropListener); mController = new DragSortController(mList); mController.setDragHandleId(R.id.cover); mController.setRemoveEnabled(false); mController.setSortEnabled(true); mController.setDragInitMode(1); mList.setFloatViewManager(mController); mList.setOnTouchListener(mController); mList.setDragEnabled(true); refreshListColorCacheHint(); mList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); mList.setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { final SparseBooleanArray checkedItems = mList.getCheckedItemPositions(); final int count = mList.getCount(); final ListAdapter adapter = mList.getAdapter(); final int itemId = item.getItemId(); int j = 0; int[] positions = null; boolean result = true; if (itemId == R.id.menu_delete) { positions = new int[mList.getCheckedItemCount()]; for (int i = 0; i < count && j < positions.length; i++) { if (checkedItems.get(i)) { positions[j] = ((Music) adapter.getItem(i)).getSongId(); j++; } } } else if (itemId == R.id.menu_crop) { positions = new int[mList.getCount() - mList.getCheckedItemCount()]; for (int i = 0; i < count && j < positions.length; i++) { if (!checkedItems.get(i)) { positions[j] = ((Music) adapter.getItem(i)).getSongId(); j++; } } } else { result = false; } if (j > 0) { QueueControl.run(QueueControl.REMOVE_BY_ID, positions); mode.finish(); } return result; } @Override public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.mpd_queuemenu, menu); return true; } @Override public void onDestroyActionMode(final ActionMode mode) { mActionMode = null; mController.setSortEnabled(true); } @Override public void onItemCheckedStateChanged(final ActionMode mode, final int position, final long id, final boolean checked) { final int selectCount = mList.getCheckedItemCount(); if (selectCount == 0) { mode.finish(); } if (selectCount == 1) { mode.setTitle(R.string.actionSongSelected); } else { mode.setTitle(getString(R.string.actionSongsSelected, selectCount)); } } @Override public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { mActionMode = mode; mController.setSortEnabled(false); return false; } }); return view; }
From source file:bbct.android.common.activity.BaseballCardList.java
private void applyFilter(Bundle filterParams) { LiveData<List<BaseballCard>> cards; BaseballCardDatabase database = BaseballCardDatabase.getInstance(getActivity()); BaseballCardDao dao = database.getBaseballCardDao(); if (filterParams == null) { cards = dao.getBaseballCards();// w ww . j a v a 2 s . co m } else { String format = "%%%s%%"; String brand = filterParams.getString(FilterCards.BRAND_EXTRA, ""); String year = filterParams.getString(FilterCards.YEAR_EXTRA, "-1"); String number = filterParams.getString(FilterCards.NUMBER_EXTRA, ""); String playerName = filterParams.getString(FilterCards.PLAYER_NAME_EXTRA, ""); String team = filterParams.getString(FilterCards.TEAM_EXTRA, ""); cards = dao.getBaseballCards(String.format(format, brand), Integer.valueOf(year), String.format(format, number), String.format(format, playerName), String.format(format, team)); } cards.observe(this, new Observer<List<BaseballCard>>() { @Override public void onChanged(@Nullable List<BaseballCard> cards) { Activity activity = getActivity(); adapter = new BaseballCardAdapter(activity, R.layout.baseball_card, cards); setListAdapter(adapter); adapter.setListFragment(BaseballCardList.this); mCallbacks = new BaseballCardMultiChoiceModeListener(BaseballCardList.this); listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(mCallbacks); adapter.setActionModeCallback(mCallbacks); } }); }
From source file:org.akop.crosswords.fragment.SubscriptionDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.fragment_subscription_detail, container, false); mListView = (ListView) layout.findViewById(R.id.list_view); mProgress = layout.findViewById(R.id.progress_bar); mEmpty = layout.findViewById(R.id.empty_view); mListView.setEmptyView(layout.findViewById(R.id.empty_view)); mListView.setMultiChoiceModeListener(mMultiChoiceListener); mListView.setOnItemClickListener(mItemClickListener); mListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); mListView.setAdapter(mAdapter);/*from w w w .ja v a2 s . co m*/ updateEmptyView(); return layout; }
From source file:com.github.jvanhie.discogsscrobbler.NowPlayingFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setSelection(final ListView list) { list.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); list.setSelector(R.drawable.track_selector); list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/* w w w . ja va2s . c o m*/ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (mBound) { //fully stop previous playlist since we start again from the beginning of the selected track ArrayList<Track> trackList = new ArrayList<Track>(mService.trackList); mService.stop(); mService.trackList = trackList; mService.currentTrack = i; mService.resume(); } } }); list.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override public void onItemCheckedStateChanged(ActionMode actionMode, int i, long l, boolean b) { } @Override public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.now_playing_cab, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { SparseBooleanArray checkedItems = list.getCheckedItemPositions(); final List<Integer> positions = new ArrayList<Integer>(); if (checkedItems != null) { for (int i = 0; i < checkedItems.size(); i++) { if (checkedItems.valueAt(i)) { positions.add(checkedItems.keyAt(i)); } } } switch (menuItem.getItemId()) { case R.id.play_selection: if (mBound) { //change tracklist and start over again ArrayList<Track> newTrackList = new ArrayList<Track>(); for (Integer i : positions) { newTrackList.add(mService.trackList.get(i)); } //fully stop previous playlist since we start again from the beginning mService.stop(); mService.trackList = newTrackList; mService.currentTrack = 0; mService.resume(); } actionMode.finish(); break; case R.id.remove_selection: int currPlaying = mService.currentTrack; int newPlaying = -1; //change tracklist and start over again ArrayList<Track> newTrackList = new ArrayList<Track>(); for (int i = 0; i < mService.trackList.size(); i++) { if (!positions.contains(i)) { newTrackList.add(mService.trackList.get(i)); } //calculate new currently playing counter if (i == currPlaying) { if (positions.contains(i)) { currPlaying++; } else { newPlaying = newTrackList.size() - 1; } } } //the currently playing track was removed, start fresh from the next available if (currPlaying != mService.currentTrack) { mService.stop(); if (newPlaying != -1) { mService.trackList = newTrackList; mService.currentTrack = newPlaying; mService.resume(); } } else { //pause the playlist and resume with the new tracklist mService.pause(); mService.trackList = newTrackList; mService.currentTrack = newPlaying; mService.resume(); } actionMode.finish(); break; } return false; } @Override public void onDestroyActionMode(ActionMode actionMode) { } }); }
From source file:com.concentricsky.android.khanacademy.app.ManageDownloadsActivity.java
@Override protected void onStart() { super.onStart(); gridView = (GridView) findViewById(R.id.grid); gridView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); gridView.setMultiChoiceModeListener(multiChoiceModeListener); gridView.setOnItemClickListener(itemClickListener); View emptyView = getLayoutInflater().inflate(R.layout.listview_empty, null, false); ((TextView) emptyView.findViewById(R.id.text_list_empty)).setText(R.string.msg_no_downloaded_videos); ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); addContentView(emptyView, p);//w w w . ja v a2s. c o m gridView.setEmptyView(emptyView); requestDataService(new ObjectCallback<KADataService>() { @Override public void call(final KADataService dataService) { ManageDownloadsActivity.this.dataService = dataService; CursorAdapter adapter = new Adapter(ManageDownloadsActivity.this, null, 0, dataService.getThumbnailManager()); gridView.setAdapter(adapter); new AsyncTask<Void, Void, Cursor>() { @Override protected Cursor doInBackground(Void... arg) { return getCursor(); } @Override protected void onPostExecute(Cursor cursor) { ((CursorAdapter) gridView.getAdapter()).changeCursor(cursor); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); final ActionBar ab = getActionBar(); ab.setDisplayHomeAsUpEnabled(true); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ab.setTitle(""); setupListNavigation(); // The receiver performs actions that require a dataService, so register it here. IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_LIBRARY_UPDATE); filter.addAction(ACTION_BADGE_EARNED); filter.addAction(ACTION_OFFLINE_VIDEO_SET_CHANGED); filter.addAction(ACTION_DOWNLOAD_PROGRESS_UPDATE); filter.addAction(ACTION_TOAST); broadcastManager.registerReceiver(receiver, filter); } }); }
From source file:com.github.jvanhie.discogsscrobbler.ReleaseListFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setSelection() { mList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); mList.setSelector(R.drawable.track_selector); mList.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override//from w w w . j a va2 s .c om public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.list_cab, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onActionItemClicked(final ActionMode mode, MenuItem item) { SparseBooleanArray checkedItems = mList.getCheckedItemPositions(); final List<Release> releases = new ArrayList<Release>(); if (checkedItems != null) { for (int i = 0; i < checkedItems.size(); i++) { if (checkedItems.valueAt(i)) { releases.add((Release) mList.getAdapter().getItem(checkedItems.keyAt(i))); } } } switch (item.getItemId()) { case R.id.reload_release: mCallbacks.setRefreshVisible(true); mDiscogs.refreshReleases(releases, new Discogs.DiscogsWaiter() { @Override public void onResult(boolean success) { if (success) { Toast.makeText(getActivity(), "reloaded releases", Toast.LENGTH_SHORT).show(); loadList(); } else { Toast.makeText(getActivity(), "Failed to reload requested releases!", Toast.LENGTH_SHORT).show(); } mCallbacks.setRefreshVisible(false); } }); mode.finish(); break; case R.id.delete_release: AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Add the buttons builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked OK button mCallbacks.setRefreshVisible(true); mDiscogs.removeReleases(releases, new Discogs.DiscogsWaiter() { @Override public void onResult(boolean success) { if (success) { Toast.makeText(getActivity(), "Removed selected releases", Toast.LENGTH_SHORT).show(); loadList(); } else { Toast.makeText(getActivity(), "Failed to remove selected releases!", Toast.LENGTH_SHORT).show(); } mCallbacks.setRefreshVisible(false); } }); mode.finish(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { mode.finish(); } }); builder.setTitle(R.string.delete_releases_title).setMessage(R.string.delete_releases_message); AlertDialog dialog = builder.create(); dialog.show(); break; case R.id.cancel_selection: mode.finish(); } return false; } @Override public void onDestroyActionMode(ActionMode actionMode) { } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { mode.setTitle(mList.getCheckedItemCount() + " releases selected"); } }); }
From source file:org.akop.crosswords.fragment.SelectorFragment.java
@Nullable @Override/*ww w . j a va 2 s .c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.fragment_selector, container, false); mListView = (ListView) layout.findViewById(R.id.list_view); mSwiper = (SwipeRefreshLayout) layout.findViewById(R.id.swiper); mUnsubscribed = layout.findViewById(R.id.unsubscribed); mEmptyContainer = layout.findViewById(R.id.empty_container); mEmptyMessage = (TextView) layout.findViewById(R.id.empty_message); View selectSubs = mUnsubscribed.findViewById(R.id.select_subscriptions); selectSubs.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SubscriptionActivity.launch(getActivity()); } }); mRefresh = mEmptyContainer.findViewById(R.id.refresh); mRefresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { updateSubscriptions(DateTime.now()); } }); mSwiper.setOnRefreshListener(mRefreshListener); mListView.setEmptyView(mEmptyContainer); mListView.setMultiChoiceModeListener(mMultiChoiceListener); mListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { CrosswordActivity.launch(getActivity(), id); } }); updateEmptyView(); return layout; }
From source file:pl.bcichecki.rms.client.android.fragments.DevicesListFragment.java
private void setUpActionModeOnListItems() { getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override//from w w w .j a v a 2s .c o m public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return performAction(mode, item); } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.fragment_devices_list_context, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { if (checked) { for (int i = 0; i < getListView().getCheckedItemPositions().size(); i++) { if (i != position) { getListView().setItemChecked(i, false); } } } } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } }); }