From 1728cef1523810ebbcfcb60f4ce3b343b81cb94d Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Mon, 18 Mar 2019 21:24:15 -0600 Subject: [PATCH] Added RxJava global error handler to avoid anoying the user by avoiding crashes when an error occurs on a RxJava operation, but still log the exception to Crashlytics so that we can fix the issues. --- .../utils/BitsyApplication.kt | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/BitsyApplication.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/BitsyApplication.kt index 81ab0c8..9ed67be 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/BitsyApplication.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/BitsyApplication.kt @@ -1,27 +1,36 @@ package cy.agorise.bitsybitshareswallet.utils import android.app.Application +import com.crashlytics.android.Crashlytics import cy.agorise.graphenej.api.ApiAccess import cy.agorise.graphenej.api.android.NetworkServiceManager +import io.reactivex.plugins.RxJavaPlugins + class BitsyApplication : Application() { - private val BITSHARES_NODE_URLS = arrayOf( - // PP private nodes - "wss://nl.palmpay.io/ws", + companion object { + private val BITSHARES_NODE_URLS = arrayOf( + // PP private nodes + "wss://nl.palmpay.io/ws", - // Other public nodes - "wss://bitshares.nu/ws", // Stockholm, Sweden - "wss://bitshares.openledger.info/ws", // Openledger node - "wss://dallas.bitshares.apasia.tech/ws", // Dallas, USA - "wss://atlanta.bitshares.apasia.tech/ws", // Atlanta, USA - "wss://dex.rnglab.org", // Amsterdam, Netherlands - "wss://citadel.li/node" - ) + // Other public nodes + "wss://bitshares.nu/ws", // Stockholm, Sweden + "wss://bitshares.openledger.info/ws", // Openledger node + "wss://dallas.bitshares.apasia.tech/ws", // Dallas, USA + "wss://atlanta.bitshares.apasia.tech/ws", // Atlanta, USA + "wss://dex.rnglab.org", // Amsterdam, Netherlands + "wss://citadel.li/node" + ) + } override fun onCreate() { super.onCreate() + // Add RxJava error handler to avoid crashes when an error occurs on a RxJava operation, but still log the + // exception to Crashlytics so that we can fix the issues + RxJavaPlugins.setErrorHandler { throwable -> Crashlytics.logException(throwable)} + // Specifying some important information regarding the connection, such as the // credentials and the requested API accesses val requestedApis = ApiAccess.API_DATABASE or ApiAccess.API_HISTORY or ApiAccess.API_NETWORK_BROADCAST