mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-08-01 11:40:34 +00:00
Fix minor issues
This commit is contained in:
parent
251228c269
commit
d4801a4362
4 changed files with 16 additions and 5 deletions
|
|
@ -219,6 +219,7 @@ class ApiClientImpl//private OnHabitsAPIResult mResultListener;
|
|||
return try {
|
||||
errorConverter?.convert(errorResponse) as ErrorResponse
|
||||
} catch (e: IOException) {
|
||||
crashlyticsProxy.log("Json Error: " + lastAPICallURL + ", " + e.message)
|
||||
ErrorResponse()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,15 +90,23 @@ class PurchaseHandler(activity: Activity, val crashlyticsProxy: CrashlyticsProxy
|
|||
}
|
||||
}
|
||||
|
||||
fun purchaseSubscription(sku: Sku) {
|
||||
fun purchaseSubscription(sku: Sku, onSuccess: (() -> Unit)) {
|
||||
sku.id.code?.let { code ->
|
||||
billingRequests?.isPurchased(ProductTypes.SUBSCRIPTION, code, object : RequestListener<Boolean> {
|
||||
override fun onSuccess(aBoolean: Boolean) {
|
||||
if (!aBoolean) {
|
||||
// no current product exist
|
||||
checkout?.let {
|
||||
billingRequests?.purchase(ProductTypes.SUBSCRIPTION, code, null, it.purchaseFlow)
|
||||
billingRequests?.purchase(ProductTypes.SUBSCRIPTION, code, null, it.createOneShotPurchaseFlow(object : RequestListener<Purchase> {
|
||||
override fun onSuccess(result: Purchase) {
|
||||
onSuccess()
|
||||
}
|
||||
|
||||
override fun onError(response: Int, e: java.lang.Exception) {}
|
||||
}))
|
||||
}
|
||||
} else {
|
||||
onSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ class ChallengeFormActivity : BaseActivity() {
|
|||
|
||||
challengeLocationSpinner.adapter = locationAdapter
|
||||
challengeLocationSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(adapterView: AdapterView<*>, view: View, i: Int, l: Long) {
|
||||
override fun onItemSelected(adapterView: AdapterView<*>, view: View?, i: Int, l: Long) {
|
||||
checkPrizeAndMinimumForTavern()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class SubscriptionFragment : BaseFragment(), GemPurchaseActivity.CheckoutFragmen
|
|||
|
||||
@Subscribe
|
||||
fun fetchUser(event: UserSubscribedEvent?) {
|
||||
compositeSubscription.add(userRepository.retrieveUser(false).subscribe(Consumer { this.setUser(it) }, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(userRepository.retrieveUser(false, true).subscribe(Consumer { this.setUser(it) }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
|
@ -203,7 +203,9 @@ class SubscriptionFragment : BaseFragment(), GemPurchaseActivity.CheckoutFragmen
|
|||
|
||||
private fun purchaseSubscription() {
|
||||
selectedSubscriptionSku?.let { sku ->
|
||||
purchaseHandler?.purchaseSubscription(sku)
|
||||
purchaseHandler?.purchaseSubscription(sku) {
|
||||
fetchUser(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue