Move BandController out of MultiSelectManager.

Improved dependency injection (elimination of propagating dependencies).
This change cleans up MultiSelectManager ahead of other improvements.
Also, cancel band select in response to touch events....else weird things happen.

Change-Id: I261d928ff7eb5d8a50791d5dd9d7202b324efc54
This commit is contained in:
Steve McKay
2016-05-26 12:04:43 -07:00
parent e04a704d7d
commit 716912e719
6 changed files with 1283 additions and 1181 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -177,6 +177,8 @@ public class DirectoryFragment extends Fragment
// Save selection found during creation so it can be restored during directory loading.
private Selection mSelection = null;
private boolean mSearchMode = false;
private @Nullable BandController mBandController;
private @Nullable ActionMode mActionMode;
private DirectoryDragListener mOnDragListener;
@@ -299,6 +301,10 @@ public class DirectoryFragment extends Fragment
: MultiSelectManager.MODE_SINGLE,
null);
if (state.allowMultiple) {
mBandController = new BandController(mRecView, mAdapter, mSelectionManager);
}
mSelectionManager.addCallback(new SelectionModeListener());
mModel = new Model();
@@ -451,7 +457,9 @@ public class DirectoryFragment extends Fragment
int pad = getDirectoryPadding(mode);
mRecView.setPadding(pad, pad, pad, pad);
mRecView.requestLayout();
mSelectionManager.handleLayoutChanged(); // RecyclerView doesn't do this for us
if (mBandController != null) {
mBandController.handleLayoutChanged();
}
mIconHelper.setViewMode(mode);
}

View File

@@ -16,7 +16,7 @@
package com.android.documentsui.dirlist;
import static com.android.documentsui.dirlist.MultiSelectManager.GridModel.NOT_SET;
import static com.android.documentsui.dirlist.BandController.GridModel.NOT_SET;
import android.graphics.Point;
import android.graphics.Rect;
@@ -24,14 +24,14 @@ import android.support.v7.widget.RecyclerView.OnScrollListener;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.documentsui.dirlist.MultiSelectManager.GridModel;
import com.android.documentsui.dirlist.BandController.GridModel;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@SmallTest
public class MultiSelectManager_GridModelTest extends AndroidTestCase {
public class BandController_GridModelTest extends AndroidTestCase {
private static final int VIEW_PADDING_PX = 5;
private static final int CHILD_VIEW_EDGE_PX = 100;
@@ -279,7 +279,7 @@ public class MultiSelectManager_GridModelTest extends AndroidTestCase {
model.onScrolled(null, 0, dy);
}
private static final class TestEnvironment implements MultiSelectManager.SelectionEnvironment {
private static final class TestEnvironment implements BandController.SelectionEnvironment {
private final int mNumColumns;
private final int mNumRows;

View File

@@ -23,6 +23,7 @@ import android.util.SparseBooleanArray;
import com.android.documentsui.TestInputEvent;
import com.android.documentsui.dirlist.MultiSelectManager.Selection;
import com.google.common.collect.Lists;
import java.util.ArrayList;
@@ -43,14 +44,12 @@ public class MultiSelectManagerTest extends AndroidTestCase {
private MultiSelectManager mManager;
private TestCallback mCallback;
private TestSelectionEnvironment mEnv;
private TestDocumentsAdapter mAdapter;
public void setUp() throws Exception {
mCallback = new TestCallback();
mEnv = new TestSelectionEnvironment(items);
mAdapter = new TestDocumentsAdapter(items);
mManager = new MultiSelectManager(mEnv, mAdapter, MultiSelectManager.MODE_MULTIPLE, null);
mManager = new MultiSelectManager(mAdapter, MultiSelectManager.MODE_MULTIPLE, null);
mManager.addCallback(mCallback);
}
@@ -174,7 +173,7 @@ public class MultiSelectManagerTest extends AndroidTestCase {
}
public void testSingleSelectMode() {
mManager = new MultiSelectManager(mEnv, mAdapter, MultiSelectManager.MODE_SINGLE, null);
mManager = new MultiSelectManager(mAdapter, MultiSelectManager.MODE_SINGLE, null);
mManager.addCallback(mCallback);
longPress(20);
tap(13);
@@ -182,7 +181,7 @@ public class MultiSelectManagerTest extends AndroidTestCase {
}
public void testSingleSelectMode_ShiftTap() {
mManager = new MultiSelectManager(mEnv, mAdapter, MultiSelectManager.MODE_SINGLE, null);
mManager = new MultiSelectManager(mAdapter, MultiSelectManager.MODE_SINGLE, null);
mManager.addCallback(mCallback);
longPress(13);
shiftTap(20);
@@ -229,7 +228,7 @@ public class MultiSelectManagerTest extends AndroidTestCase {
}
public void testRangeSelection_singleSelect() {
mManager = new MultiSelectManager(mEnv, mAdapter, MultiSelectManager.MODE_SINGLE, null);
mManager = new MultiSelectManager(mAdapter, MultiSelectManager.MODE_SINGLE, null);
mManager.addCallback(mCallback);
mManager.startRangeSelection(11);
mManager.snapRangeSelection(19);

View File

@@ -20,7 +20,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView.OnScrollListener;
import com.android.documentsui.dirlist.MultiSelectManager.SelectionEnvironment;
import com.android.documentsui.dirlist.BandController.SelectionEnvironment;
import java.util.List;