Feat: Migrating to RxJava2

Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/commit/3e921aca
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/tree/3e921aca
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/diff/3e921aca

Branch: refs/heads/master
Commit: 3e921aca92dee1f69adcd82d43484bf6255ddd7a
Parents: 573cc4a
Author: Hitesh Gautam <gautam31.hit...@gmail.com>
Authored: Sat Feb 17 19:08:26 2018 +0530
Committer: Hitesh Gautam <gautam31.hit...@gmail.com>
Committed: Mon Feb 19 14:53:27 2018 +0530

----------------------------------------------------------------------
 app/build.gradle                                |  18 +--
 .../apache/taverna/mobile/data/DataManager.java |  24 ++--
 .../taverna/mobile/data/local/DBHelper.java     |  79 +++++---------
 .../mobile/data/local/PreferencesHelper.java    |  18 ++-
 .../mobile/data/remote/BaseApiManager.java      |   6 +-
 .../data/remote/TavernaPlayerService.java       |   3 +-
 .../mobile/data/remote/TavernaService.java      |   2 +-
 .../ui/anouncements/AnnouncementPresenter.java  |  59 +++++-----
 .../FavouriteWorkflowsPresenter.java            |  48 ++++----
 .../FavouriteWorkflowDetailPresenter.java       | 109 ++++++++-----------
 .../taverna/mobile/ui/login/LoginPresenter.java |  38 +++----
 .../ui/myworkflows/MyWorkflowPresenter.java     |  58 +++++-----
 .../ui/playerlogin/PlayerLoginPresenter.java    |  37 +++----
 .../mobile/ui/workflow/WorkflowPresenter.java   |  89 +++++++--------
 .../workflowdetail/WorkflowDetailPresenter.java | 109 ++++++++-----------
 .../ui/workflowrun/WorkflowRunPresenter.java    |  60 +++++-----
 .../apache/taverna/mobile/utils/RxSearch.java   |   8 +-
 .../mobile/AnnouncementPresenterTest.java       |   2 +-
 .../mobile/FavouriteWorkflowsPresenterTest.java |   2 +-
 .../mobile/utils/RxSchedulersOverrideRule.java  |  67 ++++++------
 20 files changed, 387 insertions(+), 449 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/build.gradle
----------------------------------------------------------------------
diff --git a/app/build.gradle b/app/build.gradle
index ef7a8bf..699dccd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -43,10 +43,15 @@ android {
             debuggable true
         }
     }
+
     testOptions {
         unitTests.returnDefaultValues = true
     }
 
+    packagingOptions {
+        exclude 'META-INF/rxjava.properties'
+    }
+
     buildToolsVersion rootProject.ext.buildToolsVersion
 }
 repositories {
@@ -61,6 +66,7 @@ dependencies {
     compile 
"com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
     compile 
"com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
     compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"
+    compile 
"com.android.support:support-annotations:$rootProject.supportLibraryVersion"
 
     compile "com.android.support:design:$rootProject.supportLibraryVersion"
     compile 
"com.android.support:preference-v7:$rootProject.supportLibraryVersion"
@@ -68,7 +74,7 @@ dependencies {
 
     //Dependencies for retofit and okhhtp3
     compile 
"com.squareup.retrofit2:retrofit:$rootProject.retrofitVersionLatest"
-    compile 
"com.squareup.retrofit2:adapter-rxjava:$rootProject.retrofitVersionLatest"
+    compile 
"com.squareup.retrofit2:adapter-rxjava2:$rootProject.retrofitVersionLatest"
     compile 
"com.squareup.okhttp3:logging-interceptor:$rootProject.okHttp3Version"
     compile 
"com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersionLatest"
 
@@ -82,14 +88,8 @@ dependencies {
     compile "com.jakewharton:butterknife:$rootProject.butterKnifeVersion"
     annotationProcessor 
"com.jakewharton:butterknife-compiler:$rootProject.butterKnifeVersion"
 
-
-    compile "io.reactivex:rxandroid:1.2.0"
-// Because RxAndroid releases are few and far between, it is recommended you 
also
-// explicitly depend on RxJava's latest version for bug fixes and new features.
-    compile "io.reactivex:rxjava:1.1.5"
-
-    compile "io.reactivex.rxjava2:rxjava:2.1.9"
-    compile "io.reactivex.rxjava2:rxandroid:2.0.2"
+    compile "io.reactivex.rxjava2:rxjava:2.0.1"
+    compile "io.reactivex.rxjava2:rxandroid:2.0.1"
 
     compile("org.simpleframework:simple-xml:2.7.+") {
         exclude module: 'stax'

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/data/DataManager.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/data/DataManager.java 
b/app/src/main/java/org/apache/taverna/mobile/data/DataManager.java
index c872362..b28e06d 100644
--- a/app/src/main/java/org/apache/taverna/mobile/data/DataManager.java
+++ b/app/src/main/java/org/apache/taverna/mobile/data/DataManager.java
@@ -34,11 +34,11 @@ import org.apache.taverna.mobile.data.remote.BaseApiManager;
 import java.util.List;
 import java.util.Map;
 
+import io.reactivex.Observable;
+import io.reactivex.ObservableSource;
+import io.reactivex.functions.Function;
 import okhttp3.RequestBody;
 import okhttp3.ResponseBody;
-import rx.Observable;
-import rx.functions.Func1;
-
 
 public class DataManager {
 
@@ -81,9 +81,10 @@ public class DataManager {
      */
     public Observable<Workflows> getAllWorkflow(Map<String, String> options) {
         return mBaseApiManager.getTavernaApi().getAllWorkflows(options)
-                .concatMap(new Func1<Workflows, Observable<? extends 
Workflows>>() {
+                .concatMap(new Function<Workflows, ObservableSource<? extends 
Workflows>>() {
                     @Override
-                    public Observable<? extends Workflows> call(Workflows 
workflows) {
+                    public ObservableSource<? extends Workflows> 
apply(Workflows workflows)
+                            throws Exception {
                         return mDBHelper.syncWorkflows(workflows);
                     }
                 });
@@ -95,9 +96,10 @@ public class DataManager {
 
     public Observable<Workflow> getDetailWorkflow(String id, Map<String, 
String> options) {
         return mBaseApiManager.getTavernaApi().getDetailWorkflow(id, options)
-                .concatMap(new Func1<Workflow, Observable<? extends 
Workflow>>() {
+                .concatMap(new Function<Workflow, ObservableSource<? extends 
Workflow>>() {
                     @Override
-                    public Observable<? extends Workflow> call(Workflow 
workflow) {
+                    public ObservableSource<? extends Workflow> apply(Workflow 
workflow)
+                            throws Exception {
                         return mDBHelper.syncWorkflow(workflow);
                     }
                 });
@@ -159,13 +161,11 @@ public class DataManager {
      */
 
     public Observable<User> getLoginUserDetail(String credentials, final 
boolean flagLogin) {
-
         return mBaseApiManager.getTavernaApi().getLoginUserDetail(credentials)
-                .concatMap(new Func1<User, Observable<? extends User>>() {
+                .concatMap(new Function<User, ObservableSource<? extends 
User>>() {
                     @Override
-                    public Observable<? extends User> call(User user) {
+                    public ObservableSource<? extends User> apply(User user) 
throws Exception {
                         mPreferencesHelper.setLoggedInFlag(flagLogin);
-
                         return mPreferencesHelper.saveUserDetail(user);
                     }
                 });
@@ -205,7 +205,7 @@ public class DataManager {
     }
 
     public Observable<User> getMyWorkflows(String userID, Map<String, String> 
options) {
-        return mBaseApiManager.getTavernaApi().getUserDetail(userID , options);
+        return mBaseApiManager.getTavernaApi().getUserDetail(userID, options);
     }
 
     public Observable<Search> getSearchWorkflowResult(Map<String, String> 
options) {

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/data/local/DBHelper.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/data/local/DBHelper.java 
b/app/src/main/java/org/apache/taverna/mobile/data/local/DBHelper.java
index f50c3fa..8fc053a 100644
--- a/app/src/main/java/org/apache/taverna/mobile/data/local/DBHelper.java
+++ b/app/src/main/java/org/apache/taverna/mobile/data/local/DBHelper.java
@@ -28,10 +28,10 @@ import org.apache.taverna.mobile.data.model.Workflow_Table;
 import org.apache.taverna.mobile.data.model.Workflows;
 
 import java.util.List;
+import java.util.concurrent.Callable;
 
-import rx.Observable;
-import rx.Subscriber;
-import rx.functions.Func0;
+import io.reactivex.Observable;
+import io.reactivex.ObservableSource;
 
 
 public class DBHelper {
@@ -46,23 +46,21 @@ public class DBHelper {
 
     @Nullable
     public Observable<Workflows> syncWorkflows(final Workflows workflows) {
-        return Observable.create(new Observable.OnSubscribe<Workflows>() {
+        return Observable.defer(new Callable<ObservableSource<? extends 
Workflows>>() {
             @Override
-            public void call(Subscriber<? super Workflows> subscriber) {
-                if (subscriber.isUnsubscribed()) return;
+            public ObservableSource<? extends Workflows> call() throws 
Exception {
+
                 for (Workflow workflow : workflows.getWorkflowList()) {
                     if (!workflow.exists()) {
                         workflow.setFavourite(false);
                         workflow.save();
-
                     } else {
 
                         updateWorkflow(workflow).save();
                     }
-
                 }
-                subscriber.onNext(workflows);
-                subscriber.onCompleted();
+
+                return Observable.just(workflows);
             }
         });
     }
@@ -118,58 +116,43 @@ public class DBHelper {
         return workflow1;
     }
 
-
     public Observable<Workflow> syncWorkflow(final Workflow workflow) {
-        return Observable.create(new Observable.OnSubscribe<Workflow>() {
+        return Observable.defer(new Callable<ObservableSource<? extends 
Workflow>>() {
             @Override
-            public void call(Subscriber<? super Workflow> subscriber) {
-                if (subscriber.isUnsubscribed()) return;
+            public ObservableSource<? extends Workflow> call() throws 
Exception {
                 if (!workflow.exists()) {
                     workflow.save();
-
                 } else {
-
                     updateWorkflow(workflow).save();
                 }
-                subscriber.onNext(workflow);
-                subscriber.onCompleted();
+                return Observable.just(workflow);
             }
         });
     }
 
-
     public Observable<Boolean> setFavouriteWorkflow(final String id) {
-        return Observable.create(new Observable.OnSubscribe<Boolean>() {
+        return Observable.defer(new Callable<ObservableSource<? extends 
Boolean>>() {
             @Override
-            public void call(Subscriber<? super Boolean> subscriber) {
-                if (subscriber.isUnsubscribed()) return;
-                subscriber.onNext(updateFavouriteWorkflow(id));
-                subscriber.onCompleted();
+            public ObservableSource<? extends Boolean> call() throws Exception 
{
+                return Observable.just(updateFavouriteWorkflow(id));
             }
         });
     }
 
 
     public Observable<Boolean> getFavouriteWorkflow(final String id) {
-        return Observable.create(new Observable.OnSubscribe<Boolean>() {
+        return Observable.defer(new Callable<ObservableSource<? extends 
Boolean>>() {
             @Override
-            public void call(Subscriber<? super Boolean> subscriber) {
-                if (subscriber.isUnsubscribed()) return;
-                Workflow workflow1 = SQLite.select()
+            public ObservableSource<? extends Boolean> call() throws Exception 
{
+                Workflow workflow = SQLite.select()
                         .from(Workflow.class)
                         .where(Workflow_Table.id.eq(id))
                         .querySingle();
-
-                if (workflow1 != null) {
-
-                    subscriber.onNext(workflow1.isFavourite());
-                    subscriber.onCompleted();
+                if (workflow != null) {
+                    return Observable.just(workflow.isFavourite());
                 } else {
-
-                    subscriber.onError(null);
+                    return Observable.just(null);
                 }
-
-
             }
         });
     }
@@ -191,35 +174,27 @@ public class DBHelper {
     }
 
     public Observable<List<Workflow>> getFavouriteWorkflow() {
-        return Observable.create(new Observable.OnSubscribe<List<Workflow>>() {
+        return Observable.defer(new Callable<ObservableSource<? extends 
List<Workflow>>>() {
             @Override
-            public void call(Subscriber<? super List<Workflow>> subscriber) {
-                if (subscriber.isUnsubscribed()) return;
-                List<Workflow> workflows = SQLite.select()
+            public ObservableSource<? extends List<Workflow>> call() throws 
Exception {
+                return Observable.just(SQLite.select()
                         .from(Workflow.class)
                         .where(Workflow_Table.favourite.eq(true))
-                        .queryList();
-
-                subscriber.onNext(workflows);
-                subscriber.onCompleted();
-
+                        .queryList());
             }
         });
-
     }
 
     public Observable<Workflow> getFavouriteWorkflowDetail(final String id) {
-        return Observable.defer(new Func0<Observable<Workflow>>() {
+        return Observable.defer(new Callable<ObservableSource<? extends 
Workflow>>() {
             @Override
-            public Observable<Workflow> call() {
-                return Observable
-                        .just(SQLite.select()
+            public ObservableSource<? extends Workflow> call() throws 
Exception {
+                return Observable.just(SQLite.select()
                                 .from(Workflow.class)
                                 .where(Workflow_Table.id.eq(id))
                                 .querySingle());
             }
         });
-
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/data/local/PreferencesHelper.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/data/local/PreferencesHelper.java 
b/app/src/main/java/org/apache/taverna/mobile/data/local/PreferencesHelper.java
index c38137b..6593e0b 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/data/local/PreferencesHelper.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/data/local/PreferencesHelper.java
@@ -26,8 +26,11 @@ import android.content.Context;
 import android.content.SharedPreferences;
 import android.preference.PreferenceManager;
 
-import rx.Observable;
-import rx.functions.Func0;
+import java.util.concurrent.Callable;
+
+import io.reactivex.Observable;
+import io.reactivex.ObservableSource;
+
 
 public class PreferencesHelper {
 
@@ -155,9 +158,15 @@ public class PreferencesHelper {
     }
 
     public Observable<User> saveUserDetail(final User user) {
-        return Observable.defer(new Func0<Observable<User>>() {
+        return Observable.defer(new Callable<ObservableSource<? extends 
User>>() {
+            /**
+             * Computes a result, or throws an exception if unable to do so.
+             *
+             * @return computed result
+             * @throws Exception if unable to compute a result
+             */
             @Override
-            public Observable<User> call() {
+            public ObservableSource<? extends User> call() throws Exception {
                 if (user.getElementId() != null) {
                     setUserID(user.getElementId());
                 }
@@ -186,7 +195,6 @@ public class PreferencesHelper {
                 return Observable.just(user);
             }
         });
-
     }
 
     public boolean isUserPlayerLoggedInFlag() {

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/data/remote/BaseApiManager.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/data/remote/BaseApiManager.java 
b/app/src/main/java/org/apache/taverna/mobile/data/remote/BaseApiManager.java
index c3747e8..84d5aed 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/data/remote/BaseApiManager.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/data/remote/BaseApiManager.java
@@ -22,7 +22,7 @@ import org.apache.taverna.mobile.TavernaApplication;
 import org.apache.taverna.mobile.data.local.PreferencesHelper;
 
 import retrofit2.Retrofit;
-import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
+import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
 import retrofit2.converter.gson.GsonConverterFactory;
 import retrofit2.converter.simplexml.SimpleXmlConverterFactory;
 
@@ -42,7 +42,7 @@ public class BaseApiManager {
         Retrofit retrofit = new Retrofit.Builder()
                 .baseUrl(ENDPOINT)
                 .addConverterFactory(SimpleXmlConverterFactory.create())
-                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
+                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                 .client(new TavernaOkHttpClient().getTavernaOkHttpClient())
                 .build();
 
@@ -58,7 +58,7 @@ public class BaseApiManager {
         Retrofit retrofit = new Retrofit.Builder()
                 .baseUrl(ENDPOINT)
                 .addConverterFactory(GsonConverterFactory.create())
-                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
+                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                 .client(new TavernaOkHttpClient().getTavernaOkHttpClient())
                 .build();
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/data/remote/TavernaPlayerService.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/data/remote/TavernaPlayerService.java
 
b/app/src/main/java/org/apache/taverna/mobile/data/remote/TavernaPlayerService.java
index e71ea38..24eeee9 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/data/remote/TavernaPlayerService.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/data/remote/TavernaPlayerService.java
@@ -22,6 +22,7 @@ package org.apache.taverna.mobile.data.remote;
 import org.apache.taverna.mobile.data.model.PlayerWorkflow;
 import org.apache.taverna.mobile.data.model.PlayerWorkflowDetail;
 
+import io.reactivex.Observable;
 import okhttp3.RequestBody;
 import okhttp3.ResponseBody;
 import retrofit2.http.Body;
@@ -30,7 +31,7 @@ import retrofit2.http.Header;
 import retrofit2.http.Headers;
 import retrofit2.http.POST;
 import retrofit2.http.Query;
-import rx.Observable;
+
 
 public interface TavernaPlayerService {
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/data/remote/TavernaService.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/data/remote/TavernaService.java 
b/app/src/main/java/org/apache/taverna/mobile/data/remote/TavernaService.java
index 54c3dd5..adddb6c 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/data/remote/TavernaService.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/data/remote/TavernaService.java
@@ -28,6 +28,7 @@ import org.apache.taverna.mobile.data.model.Workflows;
 
 import java.util.Map;
 
+import io.reactivex.Observable;
 import okhttp3.ResponseBody;
 import retrofit2.http.GET;
 import retrofit2.http.Header;
@@ -35,7 +36,6 @@ import retrofit2.http.Headers;
 import retrofit2.http.Query;
 import retrofit2.http.QueryMap;
 import retrofit2.http.Url;
-import rx.Observable;
 
 
 public interface TavernaService {

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementPresenter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementPresenter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementPresenter.java
index 029a758..43a7bdb 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementPresenter.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/anouncements/AnnouncementPresenter.java
@@ -26,23 +26,21 @@ import org.apache.taverna.mobile.data.model.Announcements;
 import org.apache.taverna.mobile.data.model.DetailAnnouncement;
 import org.apache.taverna.mobile.ui.base.BasePresenter;
 
-import rx.Observer;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.schedulers.Schedulers;
-import rx.subscriptions.CompositeSubscription;
-
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.schedulers.Schedulers;
+import io.reactivex.disposables.CompositeDisposable;
 
 public class AnnouncementPresenter extends BasePresenter<AnnouncementMvpView> {
 
     public final String LOG_TAG = getClass().getSimpleName();
-    private DataManager mDataManager;
-    private CompositeSubscription mSubscriptions;
 
+    private DataManager mDataManager;
+    private CompositeDisposable compositeDisposable;
 
     public AnnouncementPresenter(DataManager dataManager) {
         mDataManager = dataManager;
-
-        mSubscriptions = new CompositeSubscription();
+        compositeDisposable = new CompositeDisposable();
     }
 
     @Override
@@ -53,18 +51,24 @@ public class AnnouncementPresenter extends 
BasePresenter<AnnouncementMvpView> {
     @Override
     public void detachView() {
         super.detachView();
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
+        compositeDisposable.clear();
     }
 
     public void loadAllAnnouncement(int pageNumber) {
-
-        mSubscriptions.add(mDataManager.getAllAnnouncement(pageNumber)
+        checkViewAttached();
+        compositeDisposable.add(mDataManager.getAllAnnouncement(pageNumber)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<Announcements>() {
+                .subscribeWith(new DisposableObserver<Announcements>() {
+
                     @Override
-                    public void onCompleted() {
-                        getMvpView().showProgressbar(false);
+                    public void onNext(Announcements announcements) {
+                        if (announcements.getAnnouncement() != null) {
+                            getMvpView().showAllAnnouncement(announcements);
+                        } else {
+                            
getMvpView().showSnackBar(R.string.no_more_announcement_available);
+                            getMvpView().removeLoadMoreProgressBar();
+                        }
                     }
 
                     @Override
@@ -74,26 +78,22 @@ public class AnnouncementPresenter extends 
BasePresenter<AnnouncementMvpView> {
                     }
 
                     @Override
-                    public void onNext(Announcements announcement) {
-                        if (announcement.getAnnouncement() != null) {
-                            getMvpView().showAllAnnouncement(announcement);
-                        } else {
-                            
getMvpView().showSnackBar(R.string.no_more_announcement_available);
-                            getMvpView().removeLoadMoreProgressBar();
-                        }
+                    public void onComplete() {
+                        getMvpView().showProgressbar(false);
                     }
                 }));
     }
 
     public void loadAnnouncementDetails(String id) {
-
-        mSubscriptions.add(mDataManager.getAnnouncementDetail(id)
+        checkViewAttached();
+        compositeDisposable.add(mDataManager.getAnnouncementDetail(id)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<DetailAnnouncement>() {
+                .subscribeWith(new DisposableObserver<DetailAnnouncement>() {
+
                     @Override
-                    public void onCompleted() {
-                        getMvpView().showWaitProgress(false);
+                    public void onNext(DetailAnnouncement detailAnnouncement) {
+                        
getMvpView().showAnnouncementDetail(detailAnnouncement);
                     }
 
                     @Override
@@ -104,9 +104,8 @@ public class AnnouncementPresenter extends 
BasePresenter<AnnouncementMvpView> {
                     }
 
                     @Override
-                    public void onNext(DetailAnnouncement detailAnnouncement) {
-                        
getMvpView().showAnnouncementDetail(detailAnnouncement);
-
+                    public void onComplete() {
+                        getMvpView().showWaitProgress(false);
                     }
                 }));
     }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflow/FavouriteWorkflowsPresenter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflow/FavouriteWorkflowsPresenter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflow/FavouriteWorkflowsPresenter.java
index 1a5c062..886d84b 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflow/FavouriteWorkflowsPresenter.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflow/FavouriteWorkflowsPresenter.java
@@ -18,31 +18,32 @@
  */
 package org.apache.taverna.mobile.ui.favouriteworkflow;
 
+import android.support.v7.widget.SearchView;
+
 import org.apache.taverna.mobile.data.DataManager;
 import org.apache.taverna.mobile.data.model.Workflow;
 import org.apache.taverna.mobile.ui.base.BasePresenter;
 import org.apache.taverna.mobile.utils.RxSearch;
 
-import android.support.v7.widget.SearchView;
-
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
-import rx.Observer;
-import rx.Subscriber;
-import rx.Subscription;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.schedulers.Schedulers;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.CompositeDisposable;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.schedulers.Schedulers;
+
 
 public class FavouriteWorkflowsPresenter extends 
BasePresenter<FavouriteWorkflowsMvpView> {
 
     public final String LOG_TAG = getClass().getSimpleName();
-    private DataManager mDataManager;
-    private Subscription mSubscriptions;
 
+    private DataManager mDataManager;
+    private CompositeDisposable compositeDisposable;
 
     public FavouriteWorkflowsPresenter(DataManager dataManager) {
         mDataManager = dataManager;
+        compositeDisposable = new CompositeDisposable();
     }
 
     @Override
@@ -53,20 +54,19 @@ public class FavouriteWorkflowsPresenter extends 
BasePresenter<FavouriteWorkflow
     @Override
     public void detachView() {
         super.detachView();
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
+        compositeDisposable.clear();
     }
 
     public void loadAllWorkflow() {
-
+        checkViewAttached();
         getMvpView().showProgressbar(true);
-
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
-        mSubscriptions = mDataManager.getFavoriteWorkflowList()
+        compositeDisposable.add(mDataManager.getFavoriteWorkflowList()
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<List<Workflow>>() {
+                .subscribeWith(new DisposableObserver<List<Workflow>>() {
+
                     @Override
-                    public void onCompleted() {
+                    public void onComplete() {
                         getMvpView().showProgressbar(false);
                     }
 
@@ -84,19 +84,18 @@ public class FavouriteWorkflowsPresenter extends 
BasePresenter<FavouriteWorkflow
                             getMvpView().showEmptyWorkflow();
                         }
                     }
-                });
-
+                }));
     }
 
-
     public void attachSearchHandler(SearchView searchView) {
+        checkViewAttached();
         RxSearch.fromSearchView(searchView)
                 .debounce(300, TimeUnit.MILLISECONDS)
                 .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new Subscriber<String>() {
+                .subscribeWith(new DisposableObserver<String>() {
                     @Override
-                    public void onCompleted() {
-
+                    public void onNext(String s) {
+                        getMvpView().performSearch(s);
                     }
 
                     @Override
@@ -105,11 +104,10 @@ public class FavouriteWorkflowsPresenter extends 
BasePresenter<FavouriteWorkflow
                     }
 
                     @Override
-                    public void onNext(String s) {
-                        getMvpView().performSearch(s);
+                    public void onComplete() {
+
                     }
                 });
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflowdetail/FavouriteWorkflowDetailPresenter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflowdetail/FavouriteWorkflowDetailPresenter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflowdetail/FavouriteWorkflowDetailPresenter.java
index 91905d1..ca747e9 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflowdetail/FavouriteWorkflowDetailPresenter.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflowdetail/FavouriteWorkflowDetailPresenter.java
@@ -27,10 +27,10 @@ import org.apache.taverna.mobile.ui.base.BasePresenter;
 import java.util.HashMap;
 import java.util.Map;
 
-import rx.Observer;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.schedulers.Schedulers;
-import rx.subscriptions.CompositeSubscription;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.schedulers.Schedulers;
+import io.reactivex.disposables.CompositeDisposable;
 
 public class FavouriteWorkflowDetailPresenter extends
         BasePresenter<FavouriteWorkflowDetailMvpView> {
@@ -39,14 +39,12 @@ public class FavouriteWorkflowDetailPresenter extends
 
     private DataManager mDataManager;
 
-    private CompositeSubscription mCompositeSubscription;
+    private CompositeDisposable compositeDisposable;
 
 
     public FavouriteWorkflowDetailPresenter(DataManager dataManager) {
-
         mDataManager = dataManager;
-
-        mCompositeSubscription = new CompositeSubscription();
+        compositeDisposable = new CompositeDisposable();
     }
 
     @Override
@@ -57,19 +55,21 @@ public class FavouriteWorkflowDetailPresenter extends
     @Override
     public void detachView() {
         super.detachView();
-        if (mCompositeSubscription != null) 
mCompositeSubscription.unsubscribe();
+        compositeDisposable.clear();
     }
 
     public void loadWorkflowDetail(String id) {
+        checkViewAttached();
         getMvpView().showProgressbar(true);
-
-        mCompositeSubscription.add(mDataManager.getFavoriteDetailWorkflow(id)
+        compositeDisposable.add(mDataManager.getFavoriteDetailWorkflow(id)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<Workflow>() {
+                .subscribeWith(new DisposableObserver<Workflow>() {
                     @Override
-                    public void onCompleted() {
-                        getMvpView().showProgressbar(false);
+                    public void onNext(Workflow workflow) {
+                        getMvpView().showWorkflowDetail(workflow);
+                        loadUserDetail(workflow.getUploader().getId());
+                        getFavourite(workflow.getId());
                     }
 
                     @Override
@@ -78,26 +78,22 @@ public class FavouriteWorkflowDetailPresenter extends
                     }
 
                     @Override
-                    public void onNext(Workflow workflow) {
-                        getMvpView().showWorkflowDetail(workflow);
-                        loadUserDetail(workflow.getUploader().getId());
-                        getFavourite(workflow.getId());
+                    public void onComplete() {
+                        getMvpView().showProgressbar(false);
                     }
                 }));
-
     }
 
     private void loadUserDetail(String id) {
-
+        checkViewAttached();
         getMvpView().showProgressbar(true);
-
-        mCompositeSubscription.add(mDataManager.getUserDetail(id, 
getUserQueryOptions())
+        compositeDisposable.add(mDataManager.getUserDetail(id, 
getUserQueryOptions())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<User>() {
+                .subscribeWith(new DisposableObserver<User>() {
                     @Override
-                    public void onCompleted() {
-                        getMvpView().showProgressbar(false);
+                    public void onNext(User user) {
+                        getMvpView().setImage(user);
                     }
 
                     @Override
@@ -108,23 +104,22 @@ public class FavouriteWorkflowDetailPresenter extends
                     }
 
                     @Override
-                    public void onNext(User user) {
-                        getMvpView().setImage(user);
+                    public void onComplete() {
+                        getMvpView().showProgressbar(false);
                     }
                 }));
     }
 
     public void loadLicenseDetail(String id) {
-
+        checkViewAttached();
         getMvpView().showLicenseProgress(true);
-
-        mCompositeSubscription.add(mDataManager.getLicenseDetail(id, 
getLicenceQueryOptions())
+        compositeDisposable.add(mDataManager.getLicenseDetail(id, 
getLicenceQueryOptions())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<License>() {
+                .subscribeWith(new DisposableObserver<License>() {
                     @Override
-                    public void onCompleted() {
-                        getMvpView().showLicenseProgress(false);
+                    public void onNext(License license) {
+                        getMvpView().showLicense(license);
                     }
 
                     @Override
@@ -135,22 +130,26 @@ public class FavouriteWorkflowDetailPresenter extends
                     }
 
                     @Override
-                    public void onNext(License license) {
-                        getMvpView().showLicense(license);
+                    public void onComplete() {
+                        getMvpView().showLicenseProgress(false);
                     }
                 }));
     }
 
     public void setFavourite(String id) {
-
-
-        mCompositeSubscription.add(mDataManager.setFavoriteWorkflow(id)
+        checkViewAttached();
+        compositeDisposable.add(mDataManager.setFavoriteWorkflow(id)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<Boolean>() {
+                .subscribeWith(new DisposableObserver<Boolean>() {
                     @Override
-                    public void onCompleted() {
-
+                    public void onNext(Boolean b) {
+                        if (b) {
+                            getMvpView().setFavouriteIcon();
+                        } else {
+                            getMvpView().showErrorSnackBar("Something went 
wrong please try after" +
+                                    "sometime");
+                        }
                     }
 
                     @Override
@@ -160,28 +159,21 @@ public class FavouriteWorkflowDetailPresenter extends
                     }
 
                     @Override
-                    public void onNext(Boolean b) {
-                        if (b) {
-                            getMvpView().setFavouriteIcon();
-                        } else {
-                            getMvpView().showErrorSnackBar("Something went 
wrong please try after" +
-                                    "sometime");
-                        }
+                    public void onComplete() {
 
                     }
                 }));
     }
 
     public void getFavourite(String id) {
-
-
-        mCompositeSubscription.add(mDataManager.getFavoriteWorkflow(id)
+        checkViewAttached();
+        compositeDisposable.add(mDataManager.getFavoriteWorkflow(id)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<Boolean>() {
+                .subscribeWith(new DisposableObserver<Boolean>() {
                     @Override
-                    public void onCompleted() {
-
+                    public void onNext(Boolean b) {
+                        getMvpView().getFavouriteIcon(b);
                     }
 
                     @Override
@@ -191,26 +183,21 @@ public class FavouriteWorkflowDetailPresenter extends
                     }
 
                     @Override
-                    public void onNext(Boolean b) {
-                        getMvpView().getFavouriteIcon(b);
+                    public void onComplete() {
+
                     }
                 }));
     }
 
-
     private Map<String, String> getUserQueryOptions() {
-
         Map<String, String> option = new HashMap<>();
         option.put("elements", "avatar");
         return option;
     }
 
     private Map<String, String> getLicenceQueryOptions() {
-
         Map<String, String> option = new HashMap<>();
         option.put("elements", "title,description,url,created-at");
         return option;
     }
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/ui/login/LoginPresenter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/login/LoginPresenter.java 
b/app/src/main/java/org/apache/taverna/mobile/ui/login/LoginPresenter.java
index 56339ac..ad47cc0 100644
--- a/app/src/main/java/org/apache/taverna/mobile/ui/login/LoginPresenter.java
+++ b/app/src/main/java/org/apache/taverna/mobile/ui/login/LoginPresenter.java
@@ -25,10 +25,11 @@ import org.apache.taverna.mobile.data.DataManager;
 import org.apache.taverna.mobile.data.model.User;
 import org.apache.taverna.mobile.ui.base.BasePresenter;
 
-import rx.Observer;
-import rx.Subscription;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.schedulers.Schedulers;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.CompositeDisposable;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.schedulers.Schedulers;
+
 
 public class LoginPresenter extends BasePresenter<LoginMvpView> {
 
@@ -36,10 +37,11 @@ public class LoginPresenter extends 
BasePresenter<LoginMvpView> {
 
     private DataManager mDataManager;
 
-    private Subscription mSubscriptions;
+    private CompositeDisposable compositeDisposable;
 
     public LoginPresenter(DataManager dataManager) {
         mDataManager = dataManager;
+        compositeDisposable = new CompositeDisposable();
     }
 
     @Override
@@ -50,23 +52,20 @@ public class LoginPresenter extends 
BasePresenter<LoginMvpView> {
     @Override
     public void detachView() {
         super.detachView();
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
+        compositeDisposable.clear();
     }
 
     public void login(String username, String password, boolean flagLogin) {
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
-
+        checkViewAttached();
         getMvpView().showProgressDialog(true);
-
-        mSubscriptions = 
mDataManager.getLoginUserDetail(getEncodedCredential(username, password)
-                , flagLogin)
+        compositeDisposable.add(mDataManager
+                .getLoginUserDetail(getEncodedCredential(username, password), 
flagLogin)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<User>() {
+                .subscribeWith(new DisposableObserver<User>() {
                     @Override
-                    public void onCompleted() {
-                        getMvpView().showDashboardActivity();
-                        getMvpView().showProgressDialog(false);
+                    public void onNext(User value) {
+
                     }
 
                     @Override
@@ -76,16 +75,15 @@ public class LoginPresenter extends 
BasePresenter<LoginMvpView> {
                     }
 
                     @Override
-                    public void onNext(User user) {
-
+                    public void onComplete() {
+                        getMvpView().showDashboardActivity();
+                        getMvpView().showProgressDialog(false);
                     }
-                });
+                }));
     }
 
     private String getEncodedCredential(String username, String password) {
-
         return "Basic " + Base64.encodeToString((username + ":" + 
password).getBytes(), Base64
                 .NO_WRAP);
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/ui/myworkflows/MyWorkflowPresenter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/myworkflows/MyWorkflowPresenter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/myworkflows/MyWorkflowPresenter.java
index 3661ea6..2fea21c 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/myworkflows/MyWorkflowPresenter.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/myworkflows/MyWorkflowPresenter.java
@@ -28,12 +28,13 @@ import org.apache.taverna.mobile.ui.base.BasePresenter;
 import java.util.HashMap;
 import java.util.Map;
 
-import rx.Observable;
-import rx.Observer;
-import rx.Subscription;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.functions.Func1;
-import rx.schedulers.Schedulers;
+import io.reactivex.Observable;
+import io.reactivex.ObservableSource;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.CompositeDisposable;
+import io.reactivex.functions.Function;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.schedulers.Schedulers;
 
 public class MyWorkflowPresenter extends BasePresenter<MyWorkflowMvpView> {
 
@@ -41,10 +42,11 @@ public class MyWorkflowPresenter extends 
BasePresenter<MyWorkflowMvpView> {
 
     private DataManager mDataManager;
 
-    private Subscription mSubscriptions;
+    private CompositeDisposable compositeDisposable;
 
     public MyWorkflowPresenter(DataManager dataManager) {
         mDataManager = dataManager;
+        compositeDisposable = new CompositeDisposable();
     }
 
     @Override
@@ -55,27 +57,26 @@ public class MyWorkflowPresenter extends 
BasePresenter<MyWorkflowMvpView> {
     @Override
     public void detachView() {
         super.detachView();
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
+        compositeDisposable.clear();
     }
 
     public void loadMyWorkflows() {
+        checkViewAttached();
         getMvpView().showProgressbar(true);
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
-
-        mSubscriptions = 
mDataManager.getMyWorkflows(mDataManager.getPreferencesHelper()
+        compositeDisposable.clear();
+        
compositeDisposable.add(mDataManager.getMyWorkflows(mDataManager.getPreferencesHelper()
                 .getUserID(), getQueryOptions())
-                .flatMap(new Func1<User, Observable<Workflow>>() {
+                .flatMap(new Function<User, ObservableSource<Workflow>>() {
                     @Override
-                    public Observable<Workflow> call(User user) {
+                    public ObservableSource<Workflow> apply(User user) throws 
Exception {
                         if (user.getWorkflows().getWorkflowList() != null && 
user.getWorkflows()
                                 .getWorkflowList().size() != 0) {
-                            return 
Observable.from(user.getWorkflows().getWorkflowList())
-                                    .concatMap(new Func1<Workflow, 
Observable<? extends
-                                            Workflow>>() {
-
+                            return 
Observable.fromIterable(user.getWorkflows().getWorkflowList())
+                                    .concatMap(new Function<Workflow,
+                                            ObservableSource<Workflow>>() {
                                         @Override
-                                        public Observable<? extends Workflow> 
call
-                                                (Workflow workflow) {
+                                        public ObservableSource<Workflow> 
apply(Workflow workflow)
+                                                throws Exception {
                                             return 
mDataManager.getDetailWorkflow(workflow.getId(),
                                                     getWorkflowQueryOptions());
                                         }
@@ -87,12 +88,10 @@ public class MyWorkflowPresenter extends 
BasePresenter<MyWorkflowMvpView> {
                 })
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<Workflow>() {
+                .subscribeWith(new DisposableObserver<Workflow>() {
                     @Override
-                    public void onCompleted() {
-
-                        getMvpView().showProgressbar(false);
-                        getMvpView().checkWorkflowSize();
+                    public void onNext(Workflow workflow) {
+                        getMvpView().showWorkflow(workflow);
                     }
 
                     @Override
@@ -102,23 +101,20 @@ public class MyWorkflowPresenter extends 
BasePresenter<MyWorkflowMvpView> {
                     }
 
                     @Override
-                    public void onNext(Workflow workflow) {
-                        getMvpView().showWorkflow(workflow);
+                    public void onComplete() {
+                        getMvpView().showProgressbar(false);
+                        getMvpView().checkWorkflowSize();
                     }
-                });
-
+                }));
     }
 
     private Map<String, String> getQueryOptions() {
-
         Map<String, String> option = new HashMap<>();
         option.put("elements", "workflows");
         return option;
     }
 
-
     private Map<String, String> getWorkflowQueryOptions() {
-
         Map<String, String> option = new HashMap<>();
         option.put("elements", "title,type,uploader,preview,created-at");
         return option;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/ui/playerlogin/PlayerLoginPresenter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/playerlogin/PlayerLoginPresenter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/playerlogin/PlayerLoginPresenter.java
index 8113cbd..fbc00e4 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/playerlogin/PlayerLoginPresenter.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/playerlogin/PlayerLoginPresenter.java
@@ -25,13 +25,12 @@ import org.apache.taverna.mobile.R;
 import org.apache.taverna.mobile.data.DataManager;
 import org.apache.taverna.mobile.ui.base.BasePresenter;
 
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.CompositeDisposable;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.schedulers.Schedulers;
 import okhttp3.ResponseBody;
-import retrofit2.adapter.rxjava.HttpException;
-import rx.Observer;
-import rx.Subscription;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.schedulers.Schedulers;
-
+import retrofit2.HttpException;
 
 public class PlayerLoginPresenter extends BasePresenter<PlayerLoginMvpView> {
 
@@ -39,10 +38,11 @@ public class PlayerLoginPresenter extends 
BasePresenter<PlayerLoginMvpView> {
 
     private DataManager mDataManager;
 
-    private Subscription mSubscriptions;
+    private CompositeDisposable compositeDisposable;
 
     public PlayerLoginPresenter(DataManager dataManager) {
         mDataManager = dataManager;
+        compositeDisposable = new CompositeDisposable();
     }
 
     @Override
@@ -53,20 +53,19 @@ public class PlayerLoginPresenter extends 
BasePresenter<PlayerLoginMvpView> {
     @Override
     public void detachView() {
         super.detachView();
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
+        compositeDisposable.clear();
     }
 
     public void playerLogin(final String username, final String password, 
final boolean loginFlag) {
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
-
-        mSubscriptions = 
mDataManager.authPlayerUserLoginDetail(getEncodedCredential(username,
-                password), loginFlag)
+        compositeDisposable.clear();
+        compositeDisposable.add(mDataManager
+                .authPlayerUserLoginDetail(getEncodedCredential(username, 
password), loginFlag)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<ResponseBody>() {
+                .subscribeWith(new DisposableObserver<ResponseBody>() {
                     @Override
-                    public void onCompleted() {
-
+                    public void onNext(ResponseBody responseBody) {
+                        Log.d(TAG, "onCompleted: " + 
responseBody.byteStream());
                     }
 
                     @Override
@@ -88,15 +87,13 @@ public class PlayerLoginPresenter extends 
BasePresenter<PlayerLoginMvpView> {
                     }
 
                     @Override
-                    public void onNext(ResponseBody responseBody) {
-                        Log.d(TAG, "onCompleted: " + 
responseBody.byteStream());
-                    }
-                });
+                    public void onComplete() {
 
+                    }
+                }));
     }
 
     private String getEncodedCredential(String username, String password) {
-
         return "Basic " + Base64.encodeToString((username + ":" + 
password).getBytes(), Base64
                 .NO_WRAP);
     }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/ui/workflow/WorkflowPresenter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/workflow/WorkflowPresenter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/workflow/WorkflowPresenter.java
index d378d9c..fd5bdcd 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/workflow/WorkflowPresenter.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/workflow/WorkflowPresenter.java
@@ -32,25 +32,21 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
-import rx.Observer;
-import rx.Subscriber;
-import rx.Subscription;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.schedulers.Schedulers;
-import rx.subscriptions.CompositeSubscription;
-
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.CompositeDisposable;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.schedulers.Schedulers;
 
 public class WorkflowPresenter extends BasePresenter<WorkflowMvpView> {
 
     public final String LOG_TAG = WorkflowPresenter.class.getSimpleName();
     private DataManager mDataManager;
-    private Subscription mSearchViewSubscription;
-    private CompositeSubscription mSubscriptions;
+    private CompositeDisposable compositeDisposable;
 
 
     public WorkflowPresenter(DataManager dataManager) {
         mDataManager = dataManager;
-        mSubscriptions = new CompositeSubscription();
+        compositeDisposable = new CompositeDisposable();
     }
 
     @Override
@@ -61,19 +57,21 @@ public class WorkflowPresenter extends 
BasePresenter<WorkflowMvpView> {
     @Override
     public void detachView() {
         super.detachView();
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
-
+        compositeDisposable.clear();
     }
 
     public void loadAllWorkflow(int pageNumber) {
+        checkViewAttached();
         getMvpView().showProgressbar(true);
-
-        
mSubscriptions.add(mDataManager.getAllWorkflow(getQueryOptions(pageNumber))
+        
compositeDisposable.add(mDataManager.getAllWorkflow(getQueryOptions(pageNumber))
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<Workflows>() {
+                .subscribeWith(new DisposableObserver<Workflows>() {
                     @Override
-                    public void onCompleted() {
+                    public void onNext(Workflows workflows) {
+                        getMvpView().showProgressbar(false);
+                        getMvpView().removeLoadMoreProgressbar();
+                        getMvpView().showWorkflows(workflows);
                     }
 
                     @Override
@@ -84,25 +82,27 @@ public class WorkflowPresenter extends 
BasePresenter<WorkflowMvpView> {
                     }
 
                     @Override
-                    public void onNext(Workflows workflows) {
-                        getMvpView().showProgressbar(false);
-                        getMvpView().removeLoadMoreProgressbar();
-                        getMvpView().showWorkflows(workflows);
+                    public void onComplete() {
+
                     }
                 }));
 
     }
 
     public void attachSearchHandler(final SearchView searchView) {
-        mSearchViewSubscription = RxSearch.fromSearchView(searchView)
+        checkViewAttached();
+        compositeDisposable.add(RxSearch.fromSearchView(searchView)
                 .distinctUntilChanged()
                 .debounce(300, TimeUnit.MILLISECONDS)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Subscriber<String>() {
+                .subscribeWith(new DisposableObserver<String>() {
                     @Override
-                    public void onCompleted() {
-
+                    public void onNext(String s) {
+                        getMvpView().performSearch(s);
+                        if (!TextUtils.isEmpty(s)) {
+                            searchWorkflow(1, s);
+                        }
                     }
 
                     @Override
@@ -111,33 +111,36 @@ public class WorkflowPresenter extends 
BasePresenter<WorkflowMvpView> {
                     }
 
                     @Override
-                    public void onNext(String s) {
-                        getMvpView().performSearch(s);
-                        if (!TextUtils.isEmpty(s)) {
-                            searchWorkflow(1, s);
-                        }
+                    public void onComplete() {
+
                     }
-                });
-        mSubscriptions.add(mSearchViewSubscription);
+                }));
+        compositeDisposable.add(compositeDisposable);
     }
 
     public void detachSearchHandler() {
-        if (mSearchViewSubscription != null) 
mSearchViewSubscription.unsubscribe();
+        compositeDisposable.clear();
     }
 
     public void searchWorkflow(int pageNumber, String query) {
+        checkViewAttached();
         if (!TextUtils.isEmpty(query)) {
             if (pageNumber == 1) {
                 getMvpView().showSwipeRefreshLayout(true);
             }
-            
mSubscriptions.add(mDataManager.getSearchWorkflowResult(getSearchQueryOptions
+            
compositeDisposable.add(mDataManager.getSearchWorkflowResult(getSearchQueryOptions
                     (pageNumber, query))
                     .observeOn(AndroidSchedulers.mainThread())
                     .subscribeOn(Schedulers.io())
-                    .subscribe(new Subscriber<Search>() {
+                    .subscribeWith(new DisposableObserver<Search>() {
                         @Override
-                        public void onCompleted() {
-                            getMvpView().showSwipeRefreshLayout(false);
+                        public void onNext(Search search) {
+                            getMvpView().removeLoadMoreProgressbar();
+                            if (search.getWorkflowList().size() > 0) {
+                                
getMvpView().showSearchResult(search.getWorkflowList());
+                            } else {
+                                
getMvpView().showSnackBar(R.string.msg_no_workflow_found);
+                            }
                         }
 
                         @Override
@@ -146,13 +149,8 @@ public class WorkflowPresenter extends 
BasePresenter<WorkflowMvpView> {
                         }
 
                         @Override
-                        public void onNext(Search search) {
-                            getMvpView().removeLoadMoreProgressbar();
-                            if (search.getWorkflowList().size() > 0) {
-                                
getMvpView().showSearchResult(search.getWorkflowList());
-                            } else {
-                                
getMvpView().showSnackBar(R.string.msg_no_workflow_found);
-                            }
+                        public void onComplete() {
+                            getMvpView().showSwipeRefreshLayout(false);
                         }
                     }));
         }
@@ -167,13 +165,10 @@ public class WorkflowPresenter extends 
BasePresenter<WorkflowMvpView> {
         return option;
     }
 
-
     private Map<String, String> getSearchQueryOptions(int pageNumber, String 
query) {
         Map<String, String> option = getQueryOptions(pageNumber);
         option.put("query", query);
         option.put("type", "workflow");
         return option;
     }
-
-
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/ui/workflowdetail/WorkflowDetailPresenter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/workflowdetail/WorkflowDetailPresenter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/workflowdetail/WorkflowDetailPresenter.java
index e3df516..2af95af 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/workflowdetail/WorkflowDetailPresenter.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/workflowdetail/WorkflowDetailPresenter.java
@@ -27,22 +27,20 @@ import org.apache.taverna.mobile.ui.base.BasePresenter;
 import java.util.HashMap;
 import java.util.Map;
 
-import rx.Observer;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.schedulers.Schedulers;
-import rx.subscriptions.CompositeSubscription;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.CompositeDisposable;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.schedulers.Schedulers;
 
 public class WorkflowDetailPresenter extends 
BasePresenter<WorkflowDetailMvpView> {
 
     public final String LOG_TAG = getClass().getSimpleName();
     private DataManager mDataManager;
-    private CompositeSubscription mCompositeSubscription;
-
+    private CompositeDisposable compositeDisposable;
 
     public WorkflowDetailPresenter(DataManager dataManager) {
-
         mDataManager = dataManager;
-        mCompositeSubscription = new CompositeSubscription();
+        compositeDisposable = new CompositeDisposable();
     }
 
     @Override
@@ -53,19 +51,21 @@ public class WorkflowDetailPresenter extends 
BasePresenter<WorkflowDetailMvpView
     @Override
     public void detachView() {
         super.detachView();
-        if (mCompositeSubscription != null) 
mCompositeSubscription.unsubscribe();
+        compositeDisposable.clear();
     }
 
     public void loadWorkflowDetail(String id) {
+        checkViewAttached();
         getMvpView().showProgressbar(true);
-
-        mCompositeSubscription.add(mDataManager.getDetailWorkflow(id, 
getDetailQueryOptions())
+        compositeDisposable.add(mDataManager.getDetailWorkflow(id, 
getDetailQueryOptions())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<Workflow>() {
+                .subscribeWith(new DisposableObserver<Workflow>() {
                     @Override
-                    public void onCompleted() {
-                        getMvpView().showProgressbar(false);
+                    public void onNext(Workflow workflow) {
+                        getMvpView().showWorkflowDetail(workflow);
+                        loadUserDetail(workflow.getUploader().getId());
+                        getFavourite(workflow.getId());
                     }
 
                     @Override
@@ -74,25 +74,22 @@ public class WorkflowDetailPresenter extends 
BasePresenter<WorkflowDetailMvpView
                     }
 
                     @Override
-                    public void onNext(Workflow workflow) {
-                        getMvpView().showWorkflowDetail(workflow);
-                        loadUserDetail(workflow.getUploader().getId());
-                        getFavourite(workflow.getId());
+                    public void onComplete() {
+                        getMvpView().showProgressbar(false);
                     }
                 }));
     }
 
     private void loadUserDetail(String id) {
-
+        checkViewAttached();
         getMvpView().showProgressbar(true);
-
-        mCompositeSubscription.add(mDataManager.getUserDetail(id, 
getUserQueryOptions())
+        compositeDisposable.add(mDataManager.getUserDetail(id, 
getUserQueryOptions())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<User>() {
+                .subscribeWith(new DisposableObserver<User>() {
                     @Override
-                    public void onCompleted() {
-                        getMvpView().showProgressbar(false);
+                    public void onNext(User user) {
+                        getMvpView().setImage(user);
                     }
 
                     @Override
@@ -103,23 +100,22 @@ public class WorkflowDetailPresenter extends 
BasePresenter<WorkflowDetailMvpView
                     }
 
                     @Override
-                    public void onNext(User user) {
-                        getMvpView().setImage(user);
+                    public void onComplete() {
+                        getMvpView().showProgressbar(false);
                     }
                 }));
     }
 
     public void loadLicenseDetail(String id) {
-
+        checkViewAttached();
         getMvpView().showLicenseProgress(true);
-
-        mCompositeSubscription.add(mDataManager.getLicenseDetail(id, 
getLicenceQueryOptions())
+        compositeDisposable.add(mDataManager.getLicenseDetail(id, 
getLicenceQueryOptions())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<License>() {
+                .subscribeWith(new DisposableObserver<License>() {
                     @Override
-                    public void onCompleted() {
-                        getMvpView().showLicenseProgress(false);
+                    public void onNext(License license) {
+                        getMvpView().showLicense(license);
                     }
 
                     @Override
@@ -130,22 +126,26 @@ public class WorkflowDetailPresenter extends 
BasePresenter<WorkflowDetailMvpView
                     }
 
                     @Override
-                    public void onNext(License license) {
-                        getMvpView().showLicense(license);
+                    public void onComplete() {
+                        getMvpView().showLicenseProgress(false);
                     }
                 }));
     }
 
     public void setFavourite(String id) {
-
-
-        mCompositeSubscription.add(mDataManager.setFavoriteWorkflow(id)
+        checkViewAttached();
+        compositeDisposable.add(mDataManager.setFavoriteWorkflow(id)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<Boolean>() {
+                .subscribeWith(new DisposableObserver<Boolean>() {
                     @Override
-                    public void onCompleted() {
-
+                    public void onNext(Boolean b) {
+                        if (b) {
+                            getMvpView().setFavouriteIcon();
+                        } else {
+                            getMvpView().showErrorSnackBar("Something went 
wrong please try after" +
+                                    "sometime");
+                        }
                     }
 
                     @Override
@@ -155,28 +155,21 @@ public class WorkflowDetailPresenter extends 
BasePresenter<WorkflowDetailMvpView
                     }
 
                     @Override
-                    public void onNext(Boolean b) {
-                        if (b) {
-                            getMvpView().setFavouriteIcon();
-                        } else {
-                            getMvpView().showErrorSnackBar("Something went 
wrong please try after" +
-                                    "sometime");
-                        }
+                    public void onComplete() {
 
                     }
                 }));
     }
 
     public void getFavourite(String id) {
-
-
-        mCompositeSubscription.add(mDataManager.getFavoriteWorkflow(id)
+        checkViewAttached();
+        compositeDisposable.add(mDataManager.getFavoriteWorkflow(id)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<Boolean>() {
+                .subscribeWith(new DisposableObserver<Boolean>() {
                     @Override
-                    public void onCompleted() {
-
+                    public void onNext(Boolean b) {
+                        getMvpView().getFavouriteIcon(b);
                     }
 
                     @Override
@@ -186,15 +179,14 @@ public class WorkflowDetailPresenter extends 
BasePresenter<WorkflowDetailMvpView
                     }
 
                     @Override
-                    public void onNext(Boolean b) {
-                        getMvpView().getFavouriteIcon(b);
+                    public void onComplete() {
+
                     }
                 }));
     }
 
 
     private Map<String, String> getDetailQueryOptions() {
-
         Map<String, String> option = new HashMap<>();
         option.put("elements", 
"id,title,type,uploader,preview,created-at,svg,updated-at," +
                 "description,license-type,tags,content-uri");
@@ -202,25 +194,20 @@ public class WorkflowDetailPresenter extends 
BasePresenter<WorkflowDetailMvpView
     }
 
     private Map<String, String> getUserQueryOptions() {
-
         Map<String, String> option = new HashMap<>();
         option.put("elements", "avatar");
         return option;
     }
 
     private Map<String, String> getLicenceQueryOptions() {
-
         Map<String, String> option = new HashMap<>();
         option.put("elements", "title,description,url,created-at");
         return option;
     }
 
     private Map<String, String> getUserWorkflowsQueryOptions() {
-
         Map<String, String> option = new HashMap<>();
         option.put("elements", "workflow");
         return option;
     }
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/ui/workflowrun/WorkflowRunPresenter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/workflowrun/WorkflowRunPresenter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/workflowrun/WorkflowRunPresenter.java
index afb8761..cc56c40 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/ui/workflowrun/WorkflowRunPresenter.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/workflowrun/WorkflowRunPresenter.java
@@ -31,50 +31,48 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 
+import io.reactivex.Observable;
+import io.reactivex.ObservableSource;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.CompositeDisposable;
+import io.reactivex.functions.Function;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.schedulers.Schedulers;
 import okhttp3.MediaType;
 import okhttp3.RequestBody;
 import okhttp3.ResponseBody;
-import rx.Observable;
-import rx.Observer;
-import rx.Subscription;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.functions.Func1;
-import rx.schedulers.Schedulers;
 
 public class WorkflowRunPresenter extends BasePresenter<WorkflowRunMvpView> {
 
     private static final String TAG = 
WorkflowRunPresenter.class.getSimpleName();
-    private final DataManager mDataManager;
-    private Subscription mSubscriptions;
 
+    private final DataManager mDataManager;
+    private CompositeDisposable compositeDisposable;
 
     public WorkflowRunPresenter(DataManager dataManager) {
         mDataManager = dataManager;
-
+        compositeDisposable = new CompositeDisposable();
     }
 
     @Override
     public void attachView(WorkflowRunMvpView mvpView) {
-
         super.attachView(mvpView);
-
     }
 
     @Override
     public void detachView() {
         super.detachView();
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
+        compositeDisposable.clear();
     }
 
-
     public void runWorkflow(String contentURL) {
-        if (mSubscriptions != null) mSubscriptions.unsubscribe();
+        compositeDisposable.clear();
+        
compositeDisposable.add(mDataManager.downloadWorkflowContent(contentURL)
+                .concatMap(new Function<ResponseBody, 
ObservableSource<PlayerWorkflow>>() {
 
-        mSubscriptions = mDataManager.downloadWorkflowContent(contentURL)
-                .concatMap(new Func1<ResponseBody, 
Observable<PlayerWorkflow>>() {
                     @Override
-                    public Observable<PlayerWorkflow> call(ResponseBody 
responseBody) {
-
+                    public ObservableSource<PlayerWorkflow> apply(ResponseBody 
responseBody)
+                            throws Exception {
                         StringBuffer sb = new StringBuffer();
                         String post = "";
 
@@ -111,38 +109,34 @@ public class WorkflowRunPresenter extends 
BasePresenter<WorkflowRunMvpView> {
                         } else {
                             return Observable.empty();
                         }
-
-
                     }
                 })
-                .concatMap(new Func1<PlayerWorkflow, 
Observable<PlayerWorkflowDetail>>() {
-                    @Override
-                    public Observable<PlayerWorkflowDetail> 
call(PlayerWorkflow playerWorkflow) {
+                .concatMap(new Function<PlayerWorkflow, 
ObservableSource<PlayerWorkflowDetail>>() {
 
+                    @Override
+                    public ObservableSource<PlayerWorkflowDetail> apply(
+                            PlayerWorkflow playerWorkflow) throws Exception {
                         return 
mDataManager.getWorkflowDetail(playerWorkflow.getId());
                     }
                 })
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribeOn(Schedulers.io())
-                .subscribe(new Observer<PlayerWorkflowDetail>() {
+                .subscribeWith(new DisposableObserver<PlayerWorkflowDetail>() {
                     @Override
-                    public void onCompleted() {
-                        getMvpView().movetoInputs();
+                    public void onNext(PlayerWorkflowDetail 
playerWorkflowDetail) {
+                        
getMvpView().setInputsAttribute(playerWorkflowDetail.getRun()
+                                .getWorkflowId());
                     }
 
                     @Override
                     public void onError(Throwable e) {
-
                         getMvpView().showError();
                     }
 
                     @Override
-                    public void onNext(PlayerWorkflowDetail 
playerWorkflowDetail) {
-                        
getMvpView().setInputsAttribute(playerWorkflowDetail.getRun()
-                                .getWorkflowId());
+                    public void onComplete() {
+
                     }
-                });
+                }));
     }
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/main/java/org/apache/taverna/mobile/utils/RxSearch.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/RxSearch.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/RxSearch.java
index bf5b560..f05d002 100644
--- a/app/src/main/java/org/apache/taverna/mobile/utils/RxSearch.java
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/RxSearch.java
@@ -3,21 +3,21 @@ package org.apache.taverna.mobile.utils;
 import android.support.annotation.NonNull;
 import android.support.v7.widget.SearchView;
 
-import rx.Observable;
-import rx.subjects.BehaviorSubject;
+import io.reactivex.Observable;
+import io.reactivex.subjects.BehaviorSubject;
 
 
 public class RxSearch {
 
     public static Observable<String> fromSearchView(@NonNull final SearchView 
searchView) {
-        final BehaviorSubject<String> subject = BehaviorSubject.create("");
+        final BehaviorSubject<String> subject = BehaviorSubject.create();
 
         searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() 
{
 
             @Override
             public boolean onQueryTextSubmit(String query) {
                 subject.onNext(query);
-                subject.onCompleted();
+                subject.onComplete();
                 searchView.clearFocus();
                 return true;
             }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/test/java/org/apache/taverna/mobile/AnnouncementPresenterTest.java
----------------------------------------------------------------------
diff --git 
a/app/src/test/java/org/apache/taverna/mobile/AnnouncementPresenterTest.java 
b/app/src/test/java/org/apache/taverna/mobile/AnnouncementPresenterTest.java
index b61b17c..6150a73 100644
--- a/app/src/test/java/org/apache/taverna/mobile/AnnouncementPresenterTest.java
+++ b/app/src/test/java/org/apache/taverna/mobile/AnnouncementPresenterTest.java
@@ -15,7 +15,7 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 
-import rx.Observable;
+import io.reactivex.Observable;
 
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/test/java/org/apache/taverna/mobile/FavouriteWorkflowsPresenterTest.java
----------------------------------------------------------------------
diff --git 
a/app/src/test/java/org/apache/taverna/mobile/FavouriteWorkflowsPresenterTest.java
 
b/app/src/test/java/org/apache/taverna/mobile/FavouriteWorkflowsPresenterTest.java
index 9561475..3a29ec9 100644
--- 
a/app/src/test/java/org/apache/taverna/mobile/FavouriteWorkflowsPresenterTest.java
+++ 
b/app/src/test/java/org/apache/taverna/mobile/FavouriteWorkflowsPresenterTest.java
@@ -17,7 +17,7 @@ import org.mockito.runners.MockitoJUnitRunner;
 import java.util.ArrayList;
 import java.util.List;
 
-import rx.Observable;
+import io.reactivex.Observable;
 
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/3e921aca/app/src/test/java/org/apache/taverna/mobile/utils/RxSchedulersOverrideRule.java
----------------------------------------------------------------------
diff --git 
a/app/src/test/java/org/apache/taverna/mobile/utils/RxSchedulersOverrideRule.java
 
b/app/src/test/java/org/apache/taverna/mobile/utils/RxSchedulersOverrideRule.java
index d1e9142..b6be49f 100644
--- 
a/app/src/test/java/org/apache/taverna/mobile/utils/RxSchedulersOverrideRule.java
+++ 
b/app/src/test/java/org/apache/taverna/mobile/utils/RxSchedulersOverrideRule.java
@@ -4,52 +4,55 @@ import org.junit.rules.TestRule;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
 
-import rx.Scheduler;
-import rx.android.plugins.RxAndroidPlugins;
-import rx.android.plugins.RxAndroidSchedulersHook;
-import rx.plugins.RxJavaPlugins;
-import rx.plugins.RxJavaSchedulersHook;
-import rx.schedulers.Schedulers;
+import java.util.concurrent.Callable;
 
+import io.reactivex.Scheduler;
+import io.reactivex.android.plugins.RxAndroidPlugins;
+import io.reactivex.functions.Function;
+import io.reactivex.plugins.RxJavaPlugins;
+import io.reactivex.schedulers.Schedulers;
 
-public class RxSchedulersOverrideRule implements TestRule {
-
-    private final RxJavaSchedulersHook mRxJavaSchedulersHook = new 
RxJavaSchedulersHook() {
-        @Override
-        public Scheduler getIOScheduler() {
-            return Schedulers.immediate();
-        }
-
-        @Override
-        public Scheduler getNewThreadScheduler() {
-            return Schedulers.immediate();
-        }
-    };
 
-    private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new 
RxAndroidSchedulersHook() {
-        @Override
-        public Scheduler getMainThreadScheduler() {
-            return Schedulers.immediate();
-        }
-    };
+public class RxSchedulersOverrideRule implements TestRule {
 
+    private final Function<Callable<Scheduler>, Scheduler> 
mRxAndroidSchedulersHook =
+            new Function<Callable<Scheduler>, Scheduler>() {
+                @Override
+                public Scheduler apply(Callable<Scheduler> schedulerCallable)
+                        throws Exception {
+                    return getScheduler();
+                }
+            };
+
+    private final Function<Scheduler, Scheduler> mRxJavaImmediateScheduler =
+            new Function<Scheduler, Scheduler>() {
+                @Override
+                public Scheduler apply(Scheduler scheduler) throws Exception {
+                    return getScheduler();
+                }
+            };
 
     @Override
     public Statement apply(final Statement base, Description description) {
         return new Statement() {
             @Override
             public void evaluate() throws Throwable {
+                RxAndroidPlugins.reset();
+                
RxAndroidPlugins.setInitMainThreadSchedulerHandler(mRxAndroidSchedulersHook);
 
-                RxAndroidPlugins.getInstance().reset();
-                
RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
-                RxJavaPlugins.getInstance().reset();
-                
RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
+                RxJavaPlugins.reset();
+                RxJavaPlugins.setIoSchedulerHandler(mRxJavaImmediateScheduler);
+                
RxJavaPlugins.setNewThreadSchedulerHandler(mRxJavaImmediateScheduler);
 
                 base.evaluate();
 
-                RxAndroidPlugins.getInstance().reset();
-                RxJavaPlugins.getInstance().reset();
+                RxAndroidPlugins.reset();
+                RxJavaPlugins.reset();
             }
         };
     }
-}
\ No newline at end of file
+
+    public Scheduler getScheduler() {
+        return Schedulers.trampoline();
+    }
+}

Reply via email to