Example usage for android.widget ListView clearChoices

List of usage examples for android.widget ListView clearChoices

Introduction

In this page you can find the example usage for android.widget ListView clearChoices.

Prototype

public void clearChoices() 

Source Link

Document

Clear any choices previously set

Usage

From source file:com.btmura.android.reddit.app.MessageThreadListController.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu, ListView listView) {
    if (adapter.getCursor() == null) {
        listView.clearChoices();
        return false;
    }//  w  w w  .  jav a 2  s . c om

    actionMode = mode;
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.message_thread_action_menu, menu);
    return true;
}

From source file:com.btmura.android.reddit.app.SubredditActionModeController.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu, ListView lv) {
    if (adapter.getCursor() == null) {
        lv.clearChoices();
        return false;
    }//from  w w  w  .  j  a  va2  s  .  com
    actionMode = mode;

    MenuInflater menuInflater = mode.getMenuInflater();
    menuInflater.inflate(R.menu.subreddit_action_menu, menu);
    return true;
}

From source file:com.jefftharris.passwdsafe.PasswdSafeListFragment.java

@Override
public void onLoadFinished(Loader<List<PasswdRecordListData>> loader, List<PasswdRecordListData> data) {
    int selPos = itsAdapter.setData(data, itsIsContents ? itsSelectedRecord : itsLocation.getRecord());
    if (isResumed()) {
        ListView list = getListView();
        if (selPos != -1) {
            list.setItemChecked(selPos, true);
            list.smoothScrollToPosition(selPos);
        } else {//from w  ww.  java 2 s.  c o m
            list.clearChoices();
        }

        if (itsEmptyText.getText().length() == 0) {
            itsEmptyText.setText(itsIsContents ? R.string.no_records : R.string.no_groups);
        }
    }
}

From source file:net.tjado.passwdsafe.PasswdSafeListFragmentTree.java

@Override
public void onLoadFinished(Loader<List<PasswdRecordListData>> loader, List<PasswdRecordListData> data) {
    int selPos = itsAdapter.setData(data, itsIsContents ? itsSelectedRecord : itsLocation.getRecord());

    if (isResumed()) {
        ListView list = getListView();
        if (selPos != -1) {
            list.setItemChecked(selPos, true);
            list.smoothScrollToPosition(selPos);
        } else {//from   w  w w. ja  v  a2  s . c  o  m
            list.clearChoices();
        }

        if (itsEmptyText.getText().length() == 0) {
            itsEmptyText.setText(itsIsContents ? R.string.no_records : R.string.no_groups);
        }
    }
}

From source file:com.android.deskclock.RingtonePickerDialogFragment.java

@Override
public void onLoadFinished(Loader<RingtoneManager> loader, RingtoneManager ringtoneManager) {
    // Swap in the new ringtone manager.
    mRingtoneAdapter.setRingtoneManager(ringtoneManager);

    // Preserve the selected ringtone.
    final ListView listView = mDialog.getListView();
    final int checkedPosition = mRingtoneAdapter.getRingtonePosition(mSelectedRingtoneUri);
    if (checkedPosition != ListView.INVALID_POSITION) {
        listView.setItemChecked(checkedPosition, true);

        // Also scroll the list to the selected ringtone (this method is poorly named).
        listView.setSelection(checkedPosition);
    } else {/*from  w w  w  .  jav a 2s  . c o  m*/
        // Can't find the selected ringtone, clear the current selection.
        mSelectedRingtoneUri = null;
        listView.clearChoices();
    }

    // Enable the positive button if we have a valid selection (Note: the positive button may
    // be null if this callback returns before onStart).
    final View positiveButton = mDialog.getButton(DialogInterface.BUTTON_POSITIVE);
    if (positiveButton != null) {
        positiveButton.setEnabled(mSelectedRingtoneUri != null);
    }

    // On M devices the checked view's drawable state isn't updated properly when it is first
    // bound, so we must use a blunt approach to force it to refresh correctly.
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
        listView.post(new Runnable() {
            @Override
            public void run() {
                for (int i = listView.getChildCount() - 1; i >= 0; --i) {
                    listView.getChildAt(i).refreshDrawableState();
                }
            }
        });
    }
}

From source file:nl.spellenclubeindhoven.dominionshuffle.SelectActivity.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    if (DIALOG_MINIMUM <= id && id <= DIALOG_MINIMUM + dialogMimimumCount) {
        AlertDialog alertDialog = (AlertDialog) dialog;
        ListView list = alertDialog.getListView();

        int pos;/*w  w w.j  av a2 s  .  c  o  m*/
        if (cardSelector.getCondition(selectedGroup) == null) {
            pos = cardSelector.getLimitMinimum(selectedGroup);
            if (pos >= 1)
                pos++;
        } else {
            pos = 1;
        }

        list.clearChoices();
        list.setItemChecked(pos, true);
        list.setSelectionFromTop(pos, list.getHeight() / 2);
    } else if (DIALOG_MAXIMUM <= id && id <= DIALOG_MAXIMUM + dialogMaximumCount) {
        AlertDialog alertDialog = (AlertDialog) dialog;
        ListView list = alertDialog.getListView();
        int pos = cardSelector.getLimitMaximum(selectedGroup);
        list.clearChoices();
        list.setItemChecked(pos, true);
        list.setSelectionFromTop(pos, list.getHeight() / 2);
    }

    switch (id) {
    case DIALOG_SOLVE_ERROR: {
        AlertDialog alertDialog = (AlertDialog) dialog;
        alertDialog.setMessage(dialogMessage);
        break;
    }
    default:
        break;
    }

    super.onPrepareDialog(id, dialog);
}

From source file:org.flerda.android.honeypad.NoteListFragment.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.checkbox:
        Integer position = (Integer) v.getTag(R.id.list);
        if (null != position) {
            ListView lv = getListView();
            int pos = position;
            boolean isChecked = !lv.isItemChecked(pos);
            lv.setItemChecked(pos, isChecked);
            if (!mIsV11) {
                showMultiPanel();//  w  ww  .  j  a  va  2  s. c  o  m
            }
        }
        break;
    case R.id.btn_multi_delete: {
        Activity a = getActivity();
        ContentResolver cr = a.getContentResolver();
        ListView lv = mLV;
        int deletedCount = 0;
        /** Badness. Don't loop a delete operation on the UI thread **/
        /** We also assume that the ID's and positions are constant **/
        for (long id : lv.getCheckItemIds()) {
            deletedCount += cr.delete(ContentUris.withAppendedId(NotesProvider.CONTENT_URI, id), null, null);
        }
        // clear any selections
        lv.clearChoices();

        // update container
        mContainerCallback.onNoteDeleted();

        // show a toast to confirm delete
        Toast.makeText(a,
                String.format(getString(R.string.num_deleted), deletedCount, (deletedCount == 1 ? "" : "s")),
                Toast.LENGTH_SHORT).show();
        showMultiPanel();
        break;
    }
    }
}

From source file:com.ushahidi.android.app.ui.phone.AddReportActivity.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    switch (id) {
    case TIME_DIALOG_ID:
        ((TimePickerDialog) dialog).updateTime(mCalendar.get(Calendar.HOUR_OF_DAY),
                mCalendar.get(Calendar.MINUTE));
        break;/*from w  ww.  j a  va2s. c om*/
    case DATE_DIALOG_ID:
        ((DatePickerDialog) dialog).updateDate(mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH),
                mCalendar.get(Calendar.DAY_OF_MONTH));
        break;

    case DIALOG_MULTIPLE_CATEGORY:
        final AlertDialog alert = (AlertDialog) dialog;
        final ListView list = alert.getListView();
        // been
        // selected, then uncheck
        // selected categories
        if (mVectorCategories.size() > 0) {
            for (String s : mVectorCategories) {
                try {
                    // @inoran fix
                    if (list != null) {
                        list.setItemChecked(mCategoryLength - Integer.parseInt(s), true);
                    }
                } catch (NumberFormatException e) {
                    log("NumberFormatException", e);
                }
            }
        } else {
            if (list != null) {
                list.clearChoices();
            }
        }

        break;

    }
}