All Projects → droibit → rxactivitylauncher

droibit / rxactivitylauncher

Licence: Apache-2.0 license
Provide a way to receive the results of the Activity by RxJava.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to rxactivitylauncher

RxUploader
Uploader for Android using RxJava
Stars: ✭ 72 (+278.95%)
Mutual labels:  rxjava
RxHttp
基于RxJava2+Retrofit+OkHttp4.x封装的网络请求类库,亮点多多,完美兼容MVVM(ViewModel,LiveData),天生支持网络请求和生命周期绑定,天生支持多BaseUrl,支持文件上传下载进度监听,支持断点下载,支持Glide和网络请求公用一个OkHttpClient⭐⭐⭐
Stars: ✭ 25 (+31.58%)
Mutual labels:  rxjava
jshodan
Powerful Shodan API client using RxJava and Retrofit
Stars: ✭ 56 (+194.74%)
Mutual labels:  rxjava
Java MVVM with Swing and RxJava Examples
Explorative Java Swing GUI example code from 2016 with an implementation of MVVM (Model View ViewModel) using RxJava and RxSwing. DON'T use it in production, there are some open issues here!
Stars: ✭ 96 (+405.26%)
Mutual labels:  rxjava
android-clean-architecture
Android Sample Clean Architecture App written in Kotlin. (MVVM, dagger2, RXjava, data binding, Live data,room)
Stars: ✭ 29 (+52.63%)
Mutual labels:  rxjava
NewsReader
Android News Reader app. Kotlin Coroutines, Retrofit and Realm
Stars: ✭ 21 (+10.53%)
Mutual labels:  rxjava
Relax
☘☘Relax 基于Kotlin语言编写的一套组件化框架,不紧整体组件化、内部也高度组件化🎋你可配置MVP、MVVM的开发模式、也可以配置所需要的业务组件🍁🍁
Stars: ✭ 253 (+1231.58%)
Mutual labels:  rxjava
ReactiveConnectivity
ReactiveConnectivity - a library for Listen Connectivity Change on Android
Stars: ✭ 22 (+15.79%)
Mutual labels:  rxjava
BaseDevelop
an android project for now fashion open source framework
Stars: ✭ 24 (+26.32%)
Mutual labels:  rxjava
UseCases
This a library that offers a generic implementation of the data layers from the clean architecture by Uncle bob.
Stars: ✭ 23 (+21.05%)
Mutual labels:  rxjava
reactivejournal
ReactiveJournal a journalling facility for Reactive Streams. Intended for testing, remote connections and effective handling of back pressure
Stars: ✭ 27 (+42.11%)
Mutual labels:  rxjava
iMoney
iMoney 金融项目
Stars: ✭ 55 (+189.47%)
Mutual labels:  rxjava
ehhttp
OkHttp calls as RxJava types
Stars: ✭ 19 (+0%)
Mutual labels:  rxjava
photon
Fast and light image loading library based on kotlin
Stars: ✭ 20 (+5.26%)
Mutual labels:  rxjava
RxAnimator
An RxJava2 binding for android Animator
Stars: ✭ 80 (+321.05%)
Mutual labels:  rxjava
Kpermissions
A Kotlin library which helps to request runtime permissions in Android.
Stars: ✭ 253 (+1231.58%)
Mutual labels:  rxjava
neurosky-android-sdk
Android SDK for the NeuroSky MindWave Mobile Brainwave Sensing Headset
Stars: ✭ 39 (+105.26%)
Mutual labels:  rxjava
PokemonCards
Android Clean MVP Architecture with Dagger & Simple Package Structure
Stars: ✭ 28 (+47.37%)
Mutual labels:  rxjava
ReadnBuyAndroidApp
Android app developed at the Vanhackathon for Shopify's challenge. Coded with Kotlin, RxJava and MVP.
Stars: ✭ 13 (-31.58%)
Mutual labels:  rxjava
RxLoading
RxJava library for showing a loading (i.e. progress bar) state while waiting for async data with minimal effort and advanced options.
Stars: ✭ 49 (+157.89%)
Mutual labels:  rxjava

RxActivityLauncher

Build Status Software License jitopack.io

RxPermissions inspired me to make this library.

When you receive the result start other activity, must use Activity#onActivityResult(int, int, Bundle) or Fragment#onActivityResult(int, int, Bundle). So, it is troublesome to receive result from the other activity. Library solves this problem by using the RxJava.

Supports the following classes.

  • Activity
  • Fragment
  • SupportFragment
  • Pending Action

Download

Add the following code to build.gradle.

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

dependencies {
    compile 'com.github.droibit:rxactivitylauncher:0.6.0'
}

Usage

public class MainActivity extends AppCompatActivity {

    private RxActivityLauncher launcher = new RxActivityLauncher();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // If the screen is rotated. Use RxBinding to trigger.
        // https://github.com/JakeWharton/RxBinding
        Observable<Void> trigger = RxView.clicks(findViewById(R.id.button))
        launcher.from(this)
                .on(trigger)
                .startActivityForResult(intent, REQUEST_ANY, null)
                .subscribe(result -> {
                    // If you specify a trigger, even if an exception occurs onError it is not called.
                    // So, the error handling in onNext.
                    if (result.throwable != null) {
                        // Error handling.
                        return;
                    }
                    // Do something.
                 }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // Always you must call the following #onActivityResult.
        launcher.onActivityResult(requestCode, resultCode, data);
    }

    // In the case of explicit intent
    private void startActivityUsingExplicitIntent() {
      Intent intent = new Intent(this, AnyActivity.class);
      launcher.from(this)
               .startActivityForResult(intent, REQUEST_ANY, null)
               .subscribe(result -> {
                   if (result.isOk()) {
                       // Do in the case of RESULT_OK  
                   } else {
                       // Do in the case of RESULT_CANCELD etc.
                   }
               });
    }

    // In the case of implicit intent
    private void startActivityUsingImplicitIntent() {
      Intent intent = new Intent(ANY_ACTION);
      launcher.from(this)
               .startActivityForResult(intent, REQUEST_ANY, null)
               .subscribe(new Action1<ActivityResult>() {
                   @Override
                   public void call(ActivityResult result) {
                       // Do in the case of received any result.
                   }
               }, new Action1<Throwable>() {
                   @Override
                   public void call(Throwable throwable) {
                       // Exception might occur in implicit Intent.
                   }
               });
    }
}

License

Copyright 2016 Shinya Kumagai

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].