Catch NoProviderException
This commit is contained in:
parent
f9ca9e80e8
commit
5d64a9b27d
|
@ -14,11 +14,8 @@ import org.unifiedpush.distributor.nextpush.account.Account.accountType
|
||||||
import org.unifiedpush.distributor.nextpush.account.Account.deviceId
|
import org.unifiedpush.distributor.nextpush.account.Account.deviceId
|
||||||
import org.unifiedpush.distributor.nextpush.account.Account.getAccount
|
import org.unifiedpush.distributor.nextpush.account.Account.getAccount
|
||||||
import org.unifiedpush.distributor.nextpush.account.AccountType
|
import org.unifiedpush.distributor.nextpush.account.AccountType
|
||||||
import org.unifiedpush.distributor.nextpush.api.provider.ApiDirectFactory
|
import org.unifiedpush.distributor.nextpush.api.provider.* // ktlint-disable no-wildcard-imports
|
||||||
import org.unifiedpush.distributor.nextpush.api.provider.ApiProvider
|
|
||||||
import org.unifiedpush.distributor.nextpush.api.provider.ApiProvider.Companion.mApiEndpoint
|
import org.unifiedpush.distributor.nextpush.api.provider.ApiProvider.Companion.mApiEndpoint
|
||||||
import org.unifiedpush.distributor.nextpush.api.provider.ApiProviderFactory
|
|
||||||
import org.unifiedpush.distributor.nextpush.api.provider.ApiSSOFactory
|
|
||||||
import org.unifiedpush.distributor.nextpush.api.response.ApiResponse
|
import org.unifiedpush.distributor.nextpush.api.response.ApiResponse
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
@ -61,7 +58,7 @@ object Api {
|
||||||
Log.d(TAG, "No deviceId found.")
|
Log.d(TAG, "No deviceId found.")
|
||||||
|
|
||||||
val parameters = mapOf("deviceName" to Build.MODEL)
|
val parameters = mapOf("deviceName" to Build.MODEL)
|
||||||
|
try {
|
||||||
withApiProvider { apiProvider ->
|
withApiProvider { apiProvider ->
|
||||||
apiProvider.createDevice(parameters)
|
apiProvider.createDevice(parameters)
|
||||||
?.subscribeOn(Schedulers.newThread())
|
?.subscribeOn(Schedulers.newThread())
|
||||||
|
@ -90,6 +87,9 @@ object Api {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} catch (e: NoProviderException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ object Api {
|
||||||
|
|
||||||
fun Context.apiDeleteDevice(block: () -> Unit = {}) {
|
fun Context.apiDeleteDevice(block: () -> Unit = {}) {
|
||||||
val deviceId = deviceId ?: return
|
val deviceId = deviceId ?: return
|
||||||
|
try {
|
||||||
withApiProvider { apiProvider ->
|
withApiProvider { apiProvider ->
|
||||||
apiProvider.deleteDevice(deviceId)
|
apiProvider.deleteDevice(deviceId)
|
||||||
?.subscribeOn(Schedulers.newThread())
|
?.subscribeOn(Schedulers.newThread())
|
||||||
|
@ -138,6 +138,9 @@ object Api {
|
||||||
})
|
})
|
||||||
this.deviceId = null
|
this.deviceId = null
|
||||||
}
|
}
|
||||||
|
} catch (e: NoProviderException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.apiCreateApp(
|
fun Context.apiCreateApp(
|
||||||
|
@ -151,7 +154,7 @@ object Api {
|
||||||
"appName" to appName
|
"appName" to appName
|
||||||
)
|
)
|
||||||
} ?: return
|
} ?: return
|
||||||
|
try {
|
||||||
withApiProvider { apiProvider ->
|
withApiProvider { apiProvider ->
|
||||||
apiProvider.createApp(parameters)
|
apiProvider.createApp(parameters)
|
||||||
?.subscribeOn(Schedulers.newThread())
|
?.subscribeOn(Schedulers.newThread())
|
||||||
|
@ -180,9 +183,13 @@ object Api {
|
||||||
override fun onComplete() {}
|
override fun onComplete() {}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} catch (e: NoProviderException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.apiDeleteApp(nextpushToken: String, block: () -> Unit) {
|
fun Context.apiDeleteApp(nextpushToken: String, block: () -> Unit) {
|
||||||
|
try {
|
||||||
withApiProvider { apiProvider ->
|
withApiProvider { apiProvider ->
|
||||||
apiProvider.deleteApp(nextpushToken)
|
apiProvider.deleteApp(nextpushToken)
|
||||||
?.subscribeOn(Schedulers.newThread())
|
?.subscribeOn(Schedulers.newThread())
|
||||||
|
@ -209,5 +216,8 @@ object Api {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} catch (e: NoProviderException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue