RxGallery alternatives and similar packages
Based on the "Utility" category.
Alternatively, view RxGallery alternatives based on common mentions on social networks and blogs.
-
timber
A logger with a small, extensible API which provides utility on top of Android's normal Log class. -
ExpirableDiskLruCache
DISCONTINUED. Java implementation of a Disk-based LRU cache which specifically targets Android compatibility. -
Android-Templates-And-Utilities
Collection of source codes, utilities, templates and snippets for Android development. -
secure-preferences
DISCONTINUED. Android Shared preference wrapper than encrypts the values of Shared Preferences. It's not bullet proof security but rather a quick win for incrementally making your android app more secure. -
greenrobot-common
General purpose utilities and hash functions for Android and Java (aka java-common) -
Androl4b
A Virtual Machine For Assessing Android applications, Reverse Engineering and Malware Analysis -
vector-compat
A support library for VectorDrawable and AnimatedVectorDrawable classes introduced in Lollipop -
CastCompanionLibrary-android
DISCONTINUED. CastCompanionLibrary-android is a library project to enable developers integrate Cast capabilities into their applications faster and easier. -
motion
An Android library allowing images to exhibit a parallax effect that reacts to the device's tilt -
Colours
A beautiful set of predefined colors and a set of color methods to make your Android development life easier. -
Reservoir
DISCONTINUED. Android library to easily serialize and cache your objects to disk using key/value pairs.
InfluxDB - Power Real-Time Data Analytics at Scale
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of RxGallery or a related project?
README
RxGallery
Android gallery & photo/video functionality simplified with RxJava2
Setup
To use this library your minSdkVersion
must be >= 9.
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
compile 'com.github.marchinram:RxGallery:0.6.6'
}
Usage
Picking items from the gallery
Maybe<List<Uri>> RxGallery.gallery(@NonNull Activity activity)
Maybe<List<Uri>> RxGallery.gallery(@NonNull Activity activity, boolean multiSelectEnabled)
Maybe<List<Uri>> RxGallery.gallery(@NonNull Activity activity, boolean multiSelectEnabled, @Nullable MimeType... mimeTypes)
Example - Picking multiple images/videos from the gallery:
RxGallery.gallery(this, true, RxGallery.MimeType.IMAGE, RxGallery.MimeType.VIDEO).subscribe(new Consumer<List<Uri>>() {
@Override
public void accept(List<Uri> uris) throws Exception {
doStuffWithUris(uris);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Toast.makeText(SomeActivity.this, throwable.getMessage(), Toast.LENGTH_LONG).show();
}
});
Taking photos with camera
Maybe<Uri> RxGallery.photoCapture(@NonNull Activity activity)
Maybe<Uri> RxGallery.photoCapture(@NonNull Activity activity, @Nullable Uri outputUri)
Example - Taking a photo with the camera and saving it to gallery:
RxGallery.photoCapture(this).subscribe(new Consumer<Uri>() {
@Override
public void accept(Uri uri) throws Exception {
doStuffWithUri(uri);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Toast.makeText(SomeActivity.this, throwable.getMessage(), Toast.LENGTH_LONG).show();
}
});
In 6.0+ you need to ask for WRITE_EXTERNAL_STORAGE permission to save to gallery, below is an example doing this with RxPermissions and flatMap
:
Observable<Boolean> permissionObservable = Observable.just(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
permissionObservable = new RxPermissions(this).request(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
permissionObservable.flatMap(new Function<Boolean, ObservableSource<Uri>>() {
@Override
public ObservableSource<Uri> apply(@NonNull Boolean granted) throws Exception {
if (!granted) {
return Observable.empty();
}
return RxGallery.photoCapture(SomeActivity.this).toObservable();
}
}).subscribe(new Consumer<Uri>() {
@Override
public void accept(Uri uri) throws Exception {
doStuffWithUri(uri);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Toast.makeText(SomeActivity.this, throwable.getMessage(), Toast.LENGTH_LONG).show();
}
});
Taking videos with camera
Maybe<Uri> RxGallery.videoCapture(@NonNull Activity activity)
Example - Taking a video with the camera and saving it to gallery:
RxGallery.videoCapture(this).subscribe(new Consumer<Uri>() {
@Override
public void accept(Uri uri) throws Exception {
doStuffWithUri(uri);
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Toast.makeText(MainActivity.this, throwable.getMessage(), Toast.LENGTH_LONG).show();
}
});
Important
If you want the started Activity (gallery/photo/video) to be destroyed when the Activity which started it is destroyed you must keep a reference to the Disposable
and call dispose
as shown below:
public final class SomeActivity extends Activity {
private Disposable disposable;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
disposable = RxGallery.gallery(this).subscribe(new Consumer<List<Uri>>() {
@Override
public void accept(List<Uri> uris) throws Exception {
doStuffWithUris(uris);
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
disposable.dispose();
}
...
}
Alternatively you can use RxLifecycle
public final class SomeActivity extends RxActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
RxGallery.gallery(this)
.compose(this.<List<Uri>>bindUntilEvent(ActivityEvent.DESTROY))
.subscribe(new Consumer<List<Uri>>() {
@Override
public void accept(List<Uri> uris) throws Exception {
doStuffWithUris(uris);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
}
});
}
...
}