Band selection: Add handling for layout changes.
Previously, the app would crash druing band selection after the layout had changed. Change-Id: I51ed2908d30e16f4d77769c798dfcef5f1ee1602
This commit is contained in:
@@ -573,6 +573,9 @@ public class DirectoryFragment extends Fragment {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -250,6 +250,10 @@ public final class MultiSelectManager {
|
||||
notifySelectionChanged();
|
||||
}
|
||||
|
||||
public void handleLayoutChanged() {
|
||||
mBandSelectManager.handleLayoutChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the selection, without notifying anyone.
|
||||
*/
|
||||
@@ -1191,6 +1195,18 @@ public final class MultiSelectManager {
|
||||
mModel.addOnSelectionChangedListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
Reference in New Issue
Block a user