Merge "Do not crash when trying to select unselectable items with keyboard." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
566c595d4d
@@ -1410,7 +1410,7 @@ public class DirectoryFragment extends Fragment
|
|||||||
// Handle range selection adjustments. Extending the selection will adjust the
|
// Handle range selection adjustments. Extending the selection will adjust the
|
||||||
// bounds of the in-progress range selection. Each time an unshifted navigation
|
// bounds of the in-progress range selection. Each time an unshifted navigation
|
||||||
// event is received, the range selection is restarted.
|
// event is received, the range selection is restarted.
|
||||||
if (shouldExtendSelection(event)) {
|
if (shouldExtendSelection(doc, event)) {
|
||||||
if (!mSelectionManager.isRangeSelectionActive()) {
|
if (!mSelectionManager.isRangeSelectionActive()) {
|
||||||
// Start a range selection if one isn't active
|
// Start a range selection if one isn't active
|
||||||
mSelectionManager.startRangeSelection(doc.getAdapterPosition());
|
mSelectionManager.startRangeSelection(doc.getAdapterPosition());
|
||||||
@@ -1447,9 +1447,22 @@ public class DirectoryFragment extends Fragment
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldExtendSelection(KeyEvent event) {
|
private boolean shouldExtendSelection(DocumentHolder doc, KeyEvent event) {
|
||||||
return Events.isNavigationKeyCode(event.getKeyCode()) &&
|
if (!Events.isNavigationKeyCode(event.getKeyCode()) || !event.isShiftPressed()) {
|
||||||
event.isShiftPressed();
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Combine this method with onBeforeItemStateChange, as both of them are almost
|
||||||
|
// the same, and responsible for the same thing (whether to select or not).
|
||||||
|
final Cursor cursor = mModel.getItem(doc.modelId);
|
||||||
|
if (cursor == null) {
|
||||||
|
Log.w(TAG, "Couldn't obtain cursor for modelId: " + doc.modelId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
|
||||||
|
final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
|
||||||
|
return mTuner.canSelectType(docMimeType, docFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -378,8 +378,8 @@ public final class MultiSelectManager {
|
|||||||
* @param pos The anchor position for the selection range.
|
* @param pos The anchor position for the selection range.
|
||||||
*/
|
*/
|
||||||
void startRangeSelection(int pos) {
|
void startRangeSelection(int pos) {
|
||||||
attemptSelect(mAdapter.getModelId(pos));
|
attemptSelect(mAdapter.getModelId(pos));
|
||||||
setSelectionRangeBegin(pos);
|
setSelectionRangeBegin(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user