From 40b6c8d7bd6b96c545078895a0bcd59753ab8832 Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Tue, 28 Aug 2018 14:52:27 +0200 Subject: [PATCH] Fix purchase feedback. Fixes #1033 --- .../com/habitrpg/android/habitica/data/ApiClient.kt | 10 +++++----- .../android/habitica/data/InventoryRepository.kt | 8 ++++---- .../habitica/data/implementation/ApiClientImpl.kt | 10 +++++----- .../data/implementation/InventoryRepositoryImpl.kt | 8 ++++---- .../android/habitica/ui/views/shops/PurchaseDialog.kt | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/data/ApiClient.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/data/ApiClient.kt index 7b0592f69..815a9ac07 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/data/ApiClient.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/data/ApiClient.kt @@ -57,14 +57,14 @@ interface ApiClient { fun buyItem(itemKey: String): Flowable - fun purchaseItem(type: String, itemKey: String): Flowable + fun purchaseItem(type: String, itemKey: String): Flowable - fun purchaseHourglassItem(type: String, itemKey: String): Flowable + fun purchaseHourglassItem(type: String, itemKey: String): Flowable - fun purchaseMysterySet(itemKey: String): Flowable + fun purchaseMysterySet(itemKey: String): Flowable - fun purchaseQuest(key: String): Flowable - fun validateSubscription(request: SubscriptionValidationRequest): Flowable + fun purchaseQuest(key: String): Flowable + fun validateSubscription(request: SubscriptionValidationRequest): Flowable fun sellItem(itemType: String, itemKey: String): Flowable diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/data/InventoryRepository.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/data/InventoryRepository.kt index b5ba483df..8f3e2e36e 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/data/InventoryRepository.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/data/InventoryRepository.kt @@ -75,13 +75,13 @@ interface InventoryRepository : ContentRepository { fun retrieveShopInventory(identifier: String): Flowable fun retrieveMarketGear(): Flowable - fun purchaseMysterySet(categoryIdentifier: String): Flowable + fun purchaseMysterySet(categoryIdentifier: String): Flowable - fun purchaseHourglassItem(purchaseType: String, key: String): Flowable + fun purchaseHourglassItem(purchaseType: String, key: String): Flowable - fun purchaseQuest(key: String): Flowable + fun purchaseQuest(key: String): Flowable - fun purchaseItem(purchaseType: String, key: String): Flowable + fun purchaseItem(purchaseType: String, key: String): Flowable fun togglePinnedItem(item: ShopItem): Flowable> } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/data/implementation/ApiClientImpl.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/data/implementation/ApiClientImpl.kt index 0776fdeab..c6018a621 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/data/implementation/ApiClientImpl.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/data/implementation/ApiClientImpl.kt @@ -308,11 +308,11 @@ class ApiClientImpl//private OnHabitsAPIResult mResultListener; return apiService.buyItem(itemKey).compose(configureApiCallObserver()) } - override fun purchaseItem(type: String, itemKey: String): Flowable { + override fun purchaseItem(type: String, itemKey: String): Flowable { return apiService.purchaseItem(type, itemKey).compose(configureApiCallObserver()) } - override fun validateSubscription(request: SubscriptionValidationRequest): Flowable { + override fun validateSubscription(request: SubscriptionValidationRequest): Flowable { return apiService.validateSubscription(request).map { habitResponse -> if (habitResponse.notifications != null) { popupNotificationsManager.showNotificationDialog(habitResponse.notifications) @@ -321,15 +321,15 @@ class ApiClientImpl//private OnHabitsAPIResult mResultListener; } } - override fun purchaseHourglassItem(type: String, itemKey: String): Flowable { + override fun purchaseHourglassItem(type: String, itemKey: String): Flowable { return apiService.purchaseHourglassItem(type, itemKey).compose(configureApiCallObserver()) } - override fun purchaseMysterySet(itemKey: String): Flowable { + override fun purchaseMysterySet(itemKey: String): Flowable { return apiService.purchaseMysterySet(itemKey).compose(configureApiCallObserver()) } - override fun purchaseQuest(key: String): Flowable { + override fun purchaseQuest(key: String): Flowable { return apiService.purchaseQuest(key).compose(configureApiCallObserver()) } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/data/implementation/InventoryRepositoryImpl.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/data/implementation/InventoryRepositoryImpl.kt index ba2c5af8e..613788fc2 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/data/implementation/InventoryRepositoryImpl.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/data/implementation/InventoryRepositoryImpl.kt @@ -223,19 +223,19 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie return apiClient.retrieveMarketGear() } - override fun purchaseMysterySet(categoryIdentifier: String): Flowable { + override fun purchaseMysterySet(categoryIdentifier: String): Flowable { return apiClient.purchaseMysterySet(categoryIdentifier) } - override fun purchaseHourglassItem(purchaseType: String, key: String): Flowable { + override fun purchaseHourglassItem(purchaseType: String, key: String): Flowable { return apiClient.purchaseHourglassItem(purchaseType, key) } - override fun purchaseQuest(key: String): Flowable { + override fun purchaseQuest(key: String): Flowable { return apiClient.purchaseQuest(key) } - override fun purchaseItem(purchaseType: String, key: String): Flowable { + override fun purchaseItem(purchaseType: String, key: String): Flowable { return apiClient.purchaseItem(purchaseType, key) } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/shops/PurchaseDialog.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/shops/PurchaseDialog.kt index 4a405dfc7..cde3fb501 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/shops/PurchaseDialog.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/shops/PurchaseDialog.kt @@ -217,7 +217,7 @@ class PurchaseDialog(context: Context, component: AppComponent?, val item: ShopI } val gemsLeft = if (shopItem.limitedNumberLeft != null) shopItem.limitedNumberLeft else 0 if ((gemsLeft == 0 && shopItem.purchaseType == "gems") || shopItem.canAfford(user)) { - val observable: Flowable + val observable: Flowable if (shopIdentifier != null && shopIdentifier == Shop.TIME_TRAVELERS_SHOP || "mystery_set" == shopItem.purchaseType) { observable = if (shopItem.purchaseType == "gear") { inventoryRepository.purchaseMysterySet(shopItem.categoryIdentifier) @@ -227,7 +227,7 @@ class PurchaseDialog(context: Context, component: AppComponent?, val item: ShopI } else if (shopItem.purchaseType == "quests" && shopItem.currency == "gold") { observable = inventoryRepository.purchaseQuest(shopItem.key) } else if ("gold" == shopItem.currency && "gem" != shopItem.key) { - observable = inventoryRepository.buyItem(user, shopItem.key, shopItem.value.toDouble()).flatMap { buyResponse -> + observable = inventoryRepository.buyItem(user, shopItem.key, shopItem.value.toDouble()).map { buyResponse -> if (shopItem.key == "armoire") { snackbarText[0] = when { buyResponse.armoire["type"] == "gear" -> context.getString(R.string.armoireEquipment, buyResponse.armoire["dropText"]) @@ -235,7 +235,7 @@ class PurchaseDialog(context: Context, component: AppComponent?, val item: ShopI else -> context.getString(R.string.armoireExp) } } - Flowable.empty() + buyResponse } } else { observable = inventoryRepository.purchaseItem(shopItem.purchaseType, shopItem.key)