Created
November 18, 2018 08:08
-
-
Save alexandze/b21fcf28bbe8b4a11ed7e7372e221a21 to your computer and use it in GitHub Desktop.
rxjava exemple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void handle(Intent intent) { | |
UtilsEnlargeRadiusAlert.Builder builder = new UtilsEnlargeRadiusAlert.Builder(intent); | |
UtilsEnlargeRadiusAlert utilsEnlargeRadiusAlert = builder | |
.setRemoteServiceProxy(ipsProcessor.getProxy()) | |
.setAlertDao(ipsProcessor.getAppDatabase().alertDao()) | |
.setLocalBroadcastManager(ipsProcessor.getLbm()) | |
.setContext(ipsProcessor.getContext()) | |
.build(); | |
//sauvegarder alert sur la base de donnees | |
getApiVersion$(getApiVersion, utilsEnlargeRadiusAlert) | |
.subscribeOn(Schedulers.io()) | |
.flatMap( | |
utilsEnlargeRadiusAlert1 -> | |
utilsEnlargeRadiusAlert1.getApiVersion() >= Build.VERSION_CODES.O | |
? removeNotificationApi26$(removeNotificationApi26AndMore, utilsEnlargeRadiusAlert1) | |
: removeNotificationApi25AndLess$(removeNotificationApi25AndLess, utilsEnlargeRadiusAlert1) | |
) | |
.flatMap(utilsEnlargeRadiusAlert1 -> multiplyRadiusBy2$(multiplyRadiusBy2, utilsEnlargeRadiusAlert1)) | |
.flatMap(utilsEnlargeRadiusAlert1 -> sendAlertToServerToEnlargeRadius$(sendAlertToServerToEnlargeRadius, utilsEnlargeRadiusAlert1)) | |
.flatMap(utilsEnlargeRadiusAlert1 -> saveAlertToDatabase$(saveAlertToDatabase, utilsEnlargeRadiusAlert1)) | |
.flatMap(utilsEnlargeRadiusAlert1 -> printMessageToastSuccess$(makeToast, utilsEnlargeRadiusAlert1)) | |
.subscribe( | |
utilsEnlargeRadiusAlert1 -> localBroadcastManager.sendBroadcast(createIntentSuccess()), | |
error -> { | |
error.printStackTrace(); | |
localBroadcastManager.sendBroadcast(createIntentError()); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment