Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java

Issue 2894523004: Photo Picker dialog: Add a test. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.photo_picker; 5 package org.chromium.chrome.browser.photo_picker;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Context; 8 import android.content.Context;
9 import android.graphics.Bitmap; 9 import android.graphics.Bitmap;
10 import android.graphics.Rect; 10 import android.graphics.Rect;
11 import android.support.annotation.Nullable;
11 import android.support.v7.widget.GridLayoutManager; 12 import android.support.v7.widget.GridLayoutManager;
12 import android.support.v7.widget.RecyclerView; 13 import android.support.v7.widget.RecyclerView;
13 import android.util.LruCache; 14 import android.util.LruCache;
14 import android.view.LayoutInflater; 15 import android.view.LayoutInflater;
15 import android.view.View; 16 import android.view.View;
16 import android.widget.Button; 17 import android.widget.Button;
17 import android.widget.RelativeLayout; 18 import android.widget.RelativeLayout;
18 19
20 import org.chromium.base.VisibleForTesting;
19 import org.chromium.chrome.R; 21 import org.chromium.chrome.R;
20 import org.chromium.chrome.browser.widget.selection.SelectableListLayout; 22 import org.chromium.chrome.browser.widget.selection.SelectableListLayout;
21 import org.chromium.chrome.browser.widget.selection.SelectionDelegate; 23 import org.chromium.chrome.browser.widget.selection.SelectionDelegate;
22 import org.chromium.ui.PhotoPickerListener; 24 import org.chromium.ui.PhotoPickerListener;
23 25
24 import java.util.Arrays; 26 import java.util.Arrays;
25 import java.util.List; 27 import java.util.List;
26 28
27 /** 29 /**
28 * A class for keeping track of common data associated with showing photos in 30 * A class for keeping track of common data associated with showing photos in
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 85
84 // The size of the bitmaps (equal length for width and height). 86 // The size of the bitmaps (equal length for width and height).
85 private int mImageSize; 87 private int mImageSize;
86 88
87 // A worker task for asynchronously enumerating files off the main thread. 89 // A worker task for asynchronously enumerating files off the main thread.
88 private FileEnumWorkerTask mWorkerTask; 90 private FileEnumWorkerTask mWorkerTask;
89 91
90 // Whether the connection to the service has been established. 92 // Whether the connection to the service has been established.
91 private boolean mServiceReady; 93 private boolean mServiceReady;
92 94
93 public PickerCategoryView(Context context) { 95 public PickerCategoryView(Context context, @Nullable List<PickerBitmap> test Files) {
94 super(context); 96 super(context);
97
98 mPickerBitmaps = testFiles;
95 postConstruction(context); 99 postConstruction(context);
96 } 100 }
97 101
98 /** 102 /**
99 * A helper function for initializing the PickerCategoryView. 103 * A helper function for initializing the PickerCategoryView.
100 * @param context The context to use. 104 * @param context The context to use.
101 */ 105 */
102 @SuppressWarnings("unchecked") // mSelectableListLayout 106 @SuppressWarnings("unchecked") // mSelectableListLayout
103 private void postConstruction(Context context) { 107 private void postConstruction(Context context) {
104 mContext = context; 108 mContext = context;
105 109
106 mDecoderServiceHost = new DecoderServiceHost(this); 110 mDecoderServiceHost = new DecoderServiceHost(this);
107 mDecoderServiceHost.bind(mContext); 111 mDecoderServiceHost.bind(mContext);
108 112
109 enumerateBitmaps(); 113 if (mPickerBitmaps == null) {
114 enumerateBitmaps();
115 }
110 116
111 mSelectionDelegate = new SelectionDelegate<PickerBitmap>(); 117 mSelectionDelegate = new SelectionDelegate<PickerBitmap>();
112 118
113 View root = LayoutInflater.from(context).inflate(R.layout.photo_picker_d ialog, this); 119 View root = LayoutInflater.from(context).inflate(R.layout.photo_picker_d ialog, this);
114 mSelectableListLayout = 120 mSelectableListLayout =
115 (SelectableListLayout<PickerBitmap>) root.findViewById(R.id.sele ctable_list); 121 (SelectableListLayout<PickerBitmap>) root.findViewById(R.id.sele ctable_list);
116 122
117 mPickerAdapter = new PickerAdapter(this); 123 mPickerAdapter = new PickerAdapter(this);
118 mRecyclerView = mSelectableListLayout.initializeRecyclerView(mPickerAdap ter); 124 mRecyclerView = mSelectableListLayout.initializeRecyclerView(mPickerAdap ter);
119 PhotoPickerToolbar toolbar = (PhotoPickerToolbar) mSelectableListLayout. initializeToolbar( 125 PhotoPickerToolbar toolbar = (PhotoPickerToolbar) mSelectableListLayout. initializeToolbar(
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 343
338 if (position < mSpanCount) { 344 if (position < mSpanCount) {
339 top = mSpacing; 345 top = mSpacing;
340 } 346 }
341 bottom = mSpacing; 347 bottom = mSpacing;
342 } 348 }
343 349
344 outRect.set(left, top, right, bottom); 350 outRect.set(left, top, right, bottom);
345 } 351 }
346 } 352 }
353
354 @VisibleForTesting
355 public SelectionDelegate<PickerBitmap> getSelectionDelegateForTesting() {
356 return mSelectionDelegate;
357 }
347 } 358 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698