Merge "Band selection: Add handling for layout changes."
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
index e15e6e0..462ffd2 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
@@ -573,6 +573,9 @@
}
mRecView.setLayoutManager(layout);
+ // TODO: Once b/23691541 is resolved, use a listener within MultiSelectManager instead of
+ // imperatively calling this function.
+ mSelectionManager.handleLayoutChanged();
// setting layout manager automatically invalidates existing ViewHolders.
mThumbSize = new Point(thumbSize, thumbSize);
}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/MultiSelectManager.java b/packages/DocumentsUI/src/com/android/documentsui/MultiSelectManager.java
index c27cad3..4284f6f 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/MultiSelectManager.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/MultiSelectManager.java
@@ -250,6 +250,10 @@
notifySelectionChanged();
}
+ public void handleLayoutChanged() {
+ mBandSelectManager.handleLayoutChanged();
+ }
+
/**
* Clears the selection, without notifying anyone.
*/
@@ -1192,6 +1196,18 @@
}
/**
+ * Handle a change in layout by cleaning up and getting rid of the old model and creating
+ * a new model which will track the new layout.
+ */
+ public void handleLayoutChanged() {
+ mModel.removeOnSelectionChangedListener(this);
+ mModel.stopListening();
+
+ mModel = new BandSelectModel((RuntimeRecyclerViewHelper) mHelper);
+ mModel.addOnSelectionChangedListener(this);
+ }
+
+ /**
* Processes a MotionEvent by starting, ending, or resizing the band select overlay.
* @param e
*/