@@ -82,6 +82,7 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
82
82
83
83
private static final String SELECTION_BUCKET = Images .Media .BUCKET_DISPLAY_NAME + " = ?" ;
84
84
private static final String SELECTION_DATE_TAKEN = Images .Media .DATE_TAKEN + " < ?" ;
85
+ private static final String SELECTION_MEDIA_SIZE = Images .Media .SIZE + " < ?" ;
85
86
86
87
public CameraRollManager (ReactApplicationContext reactContext ) {
87
88
super (reactContext );
@@ -228,13 +229,21 @@ public void getPhotos(final ReadableMap params, final Promise promise) {
228
229
String groupName = params .hasKey ("groupName" ) ? params .getString ("groupName" ) : null ;
229
230
String assetType =
230
231
params .hasKey ("assetType" ) ? params .getString ("assetType" ) : ASSET_TYPE_PHOTOS ;
232
+ Integer maxSize = params .hasKey ("maxSize" ) ? params .getInt ("maxSize" ) : null ;
231
233
ReadableArray mimeTypes = params .hasKey ("mimeTypes" ) ? params .getArray ("mimeTypes" ) : null ;
232
234
if (params .hasKey ("groupTypes" )) {
233
235
throw new JSApplicationIllegalArgumentException ("groupTypes is not supported on Android" );
234
236
}
235
237
236
238
new GetMediaTask (
237
- getReactApplicationContext (), first , after , groupName , mimeTypes , assetType , promise )
239
+ getReactApplicationContext (),
240
+ first ,
241
+ after ,
242
+ groupName ,
243
+ mimeTypes ,
244
+ assetType ,
245
+ maxSize ,
246
+ promise )
238
247
.executeOnExecutor (AsyncTask .THREAD_POOL_EXECUTOR );
239
248
}
240
249
@@ -246,6 +255,7 @@ private static class GetMediaTask extends GuardedAsyncTask<Void, Void> {
246
255
private final @ Nullable ReadableArray mMimeTypes ;
247
256
private final Promise mPromise ;
248
257
private final String mAssetType ;
258
+ private final @ Nullable Integer mMaxSize ;
249
259
250
260
private GetMediaTask (
251
261
ReactContext context ,
@@ -254,6 +264,7 @@ private GetMediaTask(
254
264
@ Nullable String groupName ,
255
265
@ Nullable ReadableArray mimeTypes ,
256
266
String assetType ,
267
+ @ Nullable Integer maxSize ,
257
268
Promise promise ) {
258
269
super (context );
259
270
mContext = context ;
@@ -263,6 +274,7 @@ private GetMediaTask(
263
274
mMimeTypes = mimeTypes ;
264
275
mPromise = promise ;
265
276
mAssetType = assetType ;
277
+ mMaxSize = maxSize ;
266
278
}
267
279
268
280
@ Override
@@ -277,6 +289,10 @@ protected void doInBackgroundGuarded(Void... params) {
277
289
selection .append (" AND " + SELECTION_BUCKET );
278
290
selectionArgs .add (mGroupName );
279
291
}
292
+ if (mMaxSize != null ) {
293
+ selection .append (" AND " + SELECTION_MEDIA_SIZE );
294
+ selectionArgs .add (mMaxSize .toString ());
295
+ }
280
296
281
297
switch (mAssetType ) {
282
298
case ASSET_TYPE_PHOTOS :
0 commit comments