Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2da6e4ae authored by Kyle Horimoto's avatar Kyle Horimoto
Browse files

Band selection: Add handling for layout changes.

Previously, the app would crash druing band selection after the layout had changed.

Change-Id: I51ed2908d30e16f4d77769c798dfcef5f1ee1602
parent 1b2b38e7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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);
    }
+16 −0
Original line number Diff line number Diff line
@@ -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