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.getAccount
|
||||
import org.unifiedpush.distributor.nextpush.account.AccountType
|
||||
import org.unifiedpush.distributor.nextpush.api.provider.ApiDirectFactory
|
||||
import org.unifiedpush.distributor.nextpush.api.provider.ApiProvider
|
||||
import org.unifiedpush.distributor.nextpush.api.provider.* // ktlint-disable no-wildcard-imports
|
||||
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 java.util.concurrent.TimeUnit
|
||||
|
||||
@ -61,7 +58,7 @@ object Api {
|
||||
Log.d(TAG, "No deviceId found.")
|
||||
|
||||
val parameters = mapOf("deviceName" to Build.MODEL)
|
||||
|
||||
try {
|
||||
withApiProvider { apiProvider ->
|
||||
apiProvider.createDevice(parameters)
|
||||
?.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 = {}) {
|
||||
val deviceId = deviceId ?: return
|
||||
|
||||
try {
|
||||
withApiProvider { apiProvider ->
|
||||
apiProvider.deleteDevice(deviceId)
|
||||
?.subscribeOn(Schedulers.newThread())
|
||||
@ -138,6 +138,9 @@ object Api {
|
||||
})
|
||||
this.deviceId = null
|
||||
}
|
||||
} catch (e: NoProviderException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.apiCreateApp(
|
||||
@ -151,7 +154,7 @@ object Api {
|
||||
"appName" to appName
|
||||
)
|
||||
} ?: return
|
||||
|
||||
try {
|
||||
withApiProvider { apiProvider ->
|
||||
apiProvider.createApp(parameters)
|
||||
?.subscribeOn(Schedulers.newThread())
|
||||
@ -180,9 +183,13 @@ object Api {
|
||||
override fun onComplete() {}
|
||||
})
|
||||
}
|
||||
} catch (e: NoProviderException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.apiDeleteApp(nextpushToken: String, block: () -> Unit) {
|
||||
try {
|
||||
withApiProvider { apiProvider ->
|
||||
apiProvider.deleteApp(nextpushToken)
|
||||
?.subscribeOn(Schedulers.newThread())
|
||||
@ -209,5 +216,8 @@ object Api {
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (e: NoProviderException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user