use of com.android.documentsui.dirlist.MultiSelectManager.Selection in project android_frameworks_base by AOSPA.
the class MultiSelectManager_SelectionTest method testEqualsOther.
public void testEqualsOther() {
Selection other = new Selection();
other.add(ids[0]);
other.add(ids[1]);
other.add(ids[2]);
assertEquals(selection, other);
assertEquals(selection.hashCode(), other.hashCode());
}
use of com.android.documentsui.dirlist.MultiSelectManager.Selection in project android_frameworks_base by AOSPA.
the class MultiSelectManagerTest method testProvisionalSelection_IntersectsAppliedSelection.
public void testProvisionalSelection_IntersectsAppliedSelection() {
mManager.toggleSelection(items.get(1));
mManager.toggleSelection(items.get(2));
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(2, true);
provisional.append(3, true);
s.setProvisionalSelection(getItemIds(provisional));
assertSelection(items.get(1), items.get(2), items.get(3));
}
use of com.android.documentsui.dirlist.MultiSelectManager.Selection in project android_frameworks_base by AOSPA.
the class MultiSelectManagerTest method testProvisionalSelection_Replace.
public void testProvisionalSelection_Replace() {
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(1, true);
provisional.append(2, true);
s.setProvisionalSelection(getItemIds(provisional));
provisional.clear();
provisional.append(3, true);
provisional.append(4, true);
s.setProvisionalSelection(getItemIds(provisional));
assertSelection(items.get(3), items.get(4));
}
use of com.android.documentsui.dirlist.MultiSelectManager.Selection in project platform_frameworks_base by android.
the class DirectoryFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final Context context = getActivity();
final State state = getDisplayState();
// Read arguments when object created for the first time.
// Restore state if fragment recreated.
Bundle args = savedInstanceState == null ? getArguments() : savedInstanceState;
mRoot = args.getParcelable(Shared.EXTRA_ROOT);
mDocument = args.getParcelable(Shared.EXTRA_DOC);
mStateKey = buildStateKey(mRoot, mDocument);
mQuery = args.getString(Shared.EXTRA_QUERY);
mType = args.getInt(Shared.EXTRA_TYPE);
final Selection selection = args.getParcelable(Shared.EXTRA_SELECTION);
mSelection = selection != null ? selection : new Selection();
mSearchMode = args.getBoolean(Shared.EXTRA_SEARCH_MODE);
mIconHelper = new IconHelper(context, MODE_GRID);
mAdapter = new SectionBreakDocumentsAdapterWrapper(this, new ModelBackedDocumentsAdapter(this, mIconHelper));
mRecView.setAdapter(mAdapter);
// Switch Access Accessibility API needs an {@link AccessibilityDelegate} to know the proper
// route when user selects an UI element. It usually guesses this if the element has an
// {@link OnClickListener}, but since we do not have one for itemView, we will need to
// manually route it to the right behavior. RecyclerView has its own AccessibilityDelegate,
// and routes it to its LayoutManager; so we must override the LayoutManager's accessibility
// methods to route clicks correctly.
mLayout = new GridLayoutManager(getContext(), mColumnCount) {
@Override
public void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler, RecyclerView.State state, View host, AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfoForItem(recycler, state, host, info);
info.addAction(AccessibilityActionCompat.ACTION_CLICK);
}
@Override
public boolean performAccessibilityActionForItem(RecyclerView.Recycler recycler, RecyclerView.State state, View view, int action, Bundle args) {
// We are only handling click events; route all other to default implementation
if (action == AccessibilityNodeInfoCompat.ACTION_CLICK) {
RecyclerView.ViewHolder vh = mRecView.getChildViewHolder(view);
if (vh instanceof DocumentHolder) {
DocumentHolder dh = (DocumentHolder) vh;
if (dh.mEventListener != null) {
dh.mEventListener.onActivate(dh);
return true;
}
}
}
return super.performAccessibilityActionForItem(recycler, state, view, action, args);
}
};
SpanSizeLookup lookup = mAdapter.createSpanSizeLookup();
if (lookup != null) {
mLayout.setSpanSizeLookup(lookup);
}
mRecView.setLayoutManager(mLayout);
mGestureDetector = new ListeningGestureDetector(this.getContext(), mDragHelper, new GestureListener());
mRecView.addOnItemTouchListener(mGestureDetector);
// TODO: instead of inserting the view into the constructor, extract listener-creation code
// and set the listener on the view after the fact. Then the view doesn't need to be passed
// into the selection manager.
mSelectionManager = new MultiSelectManager(mRecView, mAdapter, state.allowMultiple ? MultiSelectManager.MODE_MULTIPLE : MultiSelectManager.MODE_SINGLE, null);
mSelectionManager.addCallback(new SelectionModeListener());
mModel = new Model();
mModel.addUpdateListener(mAdapter);
mModel.addUpdateListener(mModelUpdateListener);
// Make sure this is done after the RecyclerView is set up.
mFocusManager = new FocusManager(context, mRecView, mModel);
mTuner = FragmentTuner.pick(getContext(), state);
mClipper = new DocumentClipper(context);
final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
boolean svelte = am.isLowRamDevice() && (mType == TYPE_RECENT_OPEN);
mIconHelper.setThumbnailsEnabled(!svelte);
// Kick off loader at least once
getLoaderManager().restartLoader(LOADER_ID, null, this);
}
use of com.android.documentsui.dirlist.MultiSelectManager.Selection in project platform_frameworks_base by android.
the class MultiSelectManagerTest method testProvisionalSelection_IntersectsAppliedSelection.
public void testProvisionalSelection_IntersectsAppliedSelection() {
mManager.toggleSelection(items.get(1));
mManager.toggleSelection(items.get(2));
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(2, true);
provisional.append(3, true);
s.setProvisionalSelection(getItemIds(provisional));
assertSelection(items.get(1), items.get(2), items.get(3));
}
Aggregations