下面列出了android.view.ActionMode#invalidate ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
if (checked) {
// Directories and footer items cannot be checked
boolean valid = false;
final Cursor cursor = mAdapter.getItem(position);
if (cursor != null) {
final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
// if (!Document.MIME_TYPE_DIR.equals(docMimeType)) {
valid = isDocumentEnabled(docMimeType, docFlags);
// }
}
if (!valid) {
mCurrentView.setItemChecked(position, false);
}
}
int count = mCurrentView.getCheckedItemCount();
mode.setTitle(getResources().getString(R.string.mode_selected_count, count));
if (count == 1 || count == 2) {
mode.invalidate();
}
}
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
if (checked) {
// Directories and footer items cannot be checked
boolean valid = false;
final Cursor cursor = mAdapter.getItem(position);
if (cursor != null) {
final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
// if (!Document.MIME_TYPE_DIR.equals(docMimeType)) {
valid = isDocumentEnabled(docMimeType, docFlags);
// }
}
if (!valid) {
mCurrentView.setItemChecked(position, false);
}
}
int count = mCurrentView.getCheckedItemCount();
mode.setTitle(getResources().getString(R.string.mode_selected_count, count));
if (count == 1 || count == 2) {
mode.invalidate();
}
}
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
if (checked) {
// Directories and footer items cannot be checked
boolean valid = false;
final Cursor cursor = mAdapter.getItem(position);
if (cursor != null) {
final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
// if (!Document.MIME_TYPE_DIR.equals(docMimeType)) {
valid = isDocumentEnabled(docMimeType, docFlags);
// }
}
if (!valid) {
mCurrentView.setItemChecked(position, false);
}
}
int count = mCurrentView.getCheckedItemCount();
mode.setTitle(getResources().getString(R.string.mode_selected_count, count));
if (count == 1 || count == 2) {
mode.invalidate();
}
}
private void invalidateActionMode(@Nullable SelectionResult result) {
cancelSmartSelectAnimation();
mTextClassification = result != null ? result.mClassification : null;
final ActionMode actionMode = mEditor.getTextActionMode();
if (actionMode != null) {
actionMode.invalidate();
}
mSelectionTracker.onSelectionUpdated(
mTextView.getSelectionStart(), mTextView.getSelectionEnd(), mTextClassification);
mTextClassificationAsyncTask = null;
}