com.zhihu.matisse.filter.Filter Java Examples
The following examples show how to use
com.zhihu.matisse.filter.Filter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PhotoMetadataUtils.java From Matisse with Apache License 2.0 | 5 votes |
public static IncapableCause isAcceptable(Context context, Item item) { if (!isSelectableType(context, item)) { return new IncapableCause(context.getString(R.string.error_file_type)); } if (SelectionSpec.getInstance().filters != null) { for (Filter filter : SelectionSpec.getInstance().filters) { IncapableCause incapableCause = filter.filter(context, item); if (incapableCause != null) { return incapableCause; } } } return null; }
Example #2
Source File: SelectionCreator.java From Matisse with Apache License 2.0 | 5 votes |
/** * Add filter to filter each selecting item. * * @param filter {@link Filter} * @return {@link SelectionCreator} for fluent API. */ public SelectionCreator addFilter(@NonNull Filter filter) { if (mSelectionSpec.filters == null) { mSelectionSpec.filters = new ArrayList<>(); } if (filter == null) throw new IllegalArgumentException("filter cannot be null"); mSelectionSpec.filters.add(filter); return this; }
Example #3
Source File: PhotoMetadataUtils.java From Matisse with Apache License 2.0 | 5 votes |
public static IncapableCause isAcceptable(Context context, Item item) { if (!isSelectableType(context, item)) { return new IncapableCause(context.getString(R.string.error_file_type)); } if (SelectionSpec.getInstance().filters != null) { for (Filter filter : SelectionSpec.getInstance().filters) { IncapableCause incapableCause = filter.filter(context, item); if (incapableCause != null) { return incapableCause; } } } return null; }
Example #4
Source File: SelectionCreator.java From Matisse with Apache License 2.0 | 5 votes |
/** * Add filter to filter each selecting item. * * @param filter {@link Filter} * @return {@link SelectionCreator} for fluent API. */ public SelectionCreator addFilter(@NonNull Filter filter) { if (mSelectionSpec.filters == null) { mSelectionSpec.filters = new ArrayList<>(); } if (filter == null) throw new IllegalArgumentException("filter cannot be null"); mSelectionSpec.filters.add(filter); return this; }
Example #5
Source File: SampleActivity.java From Matisse with Apache License 2.0 | 4 votes |
@Override public void onClick(final View v) { RxPermissions rxPermissions = new RxPermissions(this); rxPermissions.request(Manifest.permission.WRITE_EXTERNAL_STORAGE) .subscribe(new Observer<Boolean>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(Boolean aBoolean) { if (aBoolean) { switch (v.getId()) { case R.id.zhihu: Matisse.from(SampleActivity.this) .choose(MimeType.ofAll(), false) .showSingleMediaType(true) .countable(true) .capture(true) .captureStrategy( new CaptureStrategy(true, "com.zhihu.matisse.sample.fileprovider")) .maxSelectable(9) .isCrop(true) .cropStyle(CropImageView.Style.CIRCLE) .isCropSaveRectangle(false) .addFilter(new GifSizeFilter(320, 320, 3 * Filter.K * Filter.K)) .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size)) .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) .originalEnable(true) .maxOriginalSize(1) .thumbnailScale(0.85f) .imageEngine(new GlideEngine()) .setOnSelectedListener(new OnSelectedListener() { @Override public void onSelected(@NonNull List<Uri> uriList, @NonNull List<String> pathList) { if (uriList != null && uriList.size() > 0 && pathList != null && pathList.size() > 0) { Log.d("Leo", uriList.size() + " " + uriList.get(0) + " " + pathList.size() + " " + pathList.get(0)); } } }) .forResult(REQUEST_CODE_CHOOSE); break; case R.id.dracula: Matisse.from(SampleActivity.this) .choose(MimeType.ofVideo(), false) .countable(true) .showSingleMediaType(true) .capture(true) .captureStrategy(new CaptureStrategy(true, "com.zhihu.matisse.sample.fileprovider")) .maxSelectable(1) .isCrop(true) .cropStyle(CropImageView.Style.RECTANGLE) .isCropSaveRectangle(false) .imageEngine(new GlideEngine()) .forResult(REQUEST_CODE_CHOOSE); break; } mAdapter.setData(null, null); } else { Toast.makeText(SampleActivity.this, R.string.permission_request_denied, Toast.LENGTH_LONG) .show(); } } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); }
Example #6
Source File: SampleActivity.java From Matisse with Apache License 2.0 | 4 votes |
private void startAction(View v) { switch (v.getId()) { case R.id.zhihu: Matisse.from(SampleActivity.this) .choose(MimeType.ofImage(), false) .countable(true) .capture(true) .captureStrategy( new CaptureStrategy(true, "com.zhihu.matisse.sample.fileprovider", "test")) .maxSelectable(9) .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K)) .gridExpectedSize( getResources().getDimensionPixelSize(R.dimen.grid_expected_size)) .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) .thumbnailScale(0.85f) .imageEngine(new GlideEngine()) .setOnSelectedListener((uriList, pathList) -> { Log.e("onSelected", "onSelected: pathList=" + pathList); }) .showSingleMediaType(true) .originalEnable(true) .maxOriginalSize(10) .autoHideToolbarOnSingleTap(true) .setOnCheckedListener(isChecked -> { Log.e("isChecked", "onCheck: isChecked=" + isChecked); }) .forResult(REQUEST_CODE_CHOOSE); break; case R.id.dracula: Matisse.from(SampleActivity.this) .choose(MimeType.ofImage()) .theme(R.style.Matisse_Dracula) .countable(false) .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K)) .maxSelectable(9) .originalEnable(true) .maxOriginalSize(10) .imageEngine(new PicassoEngine()) .forResult(REQUEST_CODE_CHOOSE); break; case R.id.only_gif: Matisse.from(SampleActivity.this) .choose(MimeType.of(MimeType.GIF), false) .countable(true) .maxSelectable(9) .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K)) .gridExpectedSize( getResources().getDimensionPixelSize(R.dimen.grid_expected_size)) .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) .thumbnailScale(0.85f) .imageEngine(new GlideEngine()) .showSingleMediaType(true) .originalEnable(true) .maxOriginalSize(10) .autoHideToolbarOnSingleTap(true) .forResult(REQUEST_CODE_CHOOSE); break; default: break; } mAdapter.setData(null, null); }
Example #7
Source File: MatisseDemoActivity.java From AndroidAnimationExercise with Apache License 2.0 | 4 votes |
@Override public void onClick(final View v) { RxPermissions rxPermissions = new RxPermissions(this); rxPermissions.request(Manifest.permission.WRITE_EXTERNAL_STORAGE) .subscribe(new Observer<Boolean>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(Boolean aBoolean) { if (aBoolean) { switch (v.getId()) { case R.id.zhihu: Matisse.from(MatisseDemoActivity.this) .choose(MimeType.ofAll(), false) .countable(true) .capture(true) .captureStrategy( new CaptureStrategy(true, getPackageName() + ".fileprovider")) .maxSelectable(9) .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K)) .gridExpectedSize( getResources().getDimensionPixelSize(R.dimen.grid_expected_size)) .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) .thumbnailScale(0.85f) .imageEngine(new Glide4Engine()) .forResult(REQUEST_CODE_CHOOSE); break; case R.id.dracula: Matisse.from(MatisseDemoActivity.this) .choose(MimeType.of(MimeType.JPEG,MimeType.PNG)) .theme(R.style.Matisse_Dracula) .countable(false) .maxSelectable(1) .imageEngine(new PicassoEngine()) .forResult(REQUEST_CODE_CHOOSE); break; case R.id.custom: Matisse.from(MatisseDemoActivity.this) .choose(MimeType.ofImage()) .forResult(REQUEST_CODE_CHOOSE); break; default: break; } } else { Toast.makeText(MatisseDemoActivity.this, R.string.permission_request_denied, Toast.LENGTH_LONG) .show(); } } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); }