Fix purchase feedback. Fixes #1033

This commit is contained in:
Phillip Thelen 2018-08-28 14:52:27 +02:00
parent 29227f7772
commit 40b6c8d7bd
5 changed files with 21 additions and 21 deletions

View file

@ -57,14 +57,14 @@ interface ApiClient {
fun buyItem(itemKey: String): Flowable<BuyResponse>
fun purchaseItem(type: String, itemKey: String): Flowable<Void>
fun purchaseItem(type: String, itemKey: String): Flowable<Any>
fun purchaseHourglassItem(type: String, itemKey: String): Flowable<Void>
fun purchaseHourglassItem(type: String, itemKey: String): Flowable<Any>
fun purchaseMysterySet(itemKey: String): Flowable<Void>
fun purchaseMysterySet(itemKey: String): Flowable<Any>
fun purchaseQuest(key: String): Flowable<Void>
fun validateSubscription(request: SubscriptionValidationRequest): Flowable<Void>
fun purchaseQuest(key: String): Flowable<Any>
fun validateSubscription(request: SubscriptionValidationRequest): Flowable<Any>
fun sellItem(itemType: String, itemKey: String): Flowable<User>

View file

@ -75,13 +75,13 @@ interface InventoryRepository : ContentRepository {
fun retrieveShopInventory(identifier: String): Flowable<Shop>
fun retrieveMarketGear(): Flowable<Shop>
fun purchaseMysterySet(categoryIdentifier: String): Flowable<Void>
fun purchaseMysterySet(categoryIdentifier: String): Flowable<Any>
fun purchaseHourglassItem(purchaseType: String, key: String): Flowable<Void>
fun purchaseHourglassItem(purchaseType: String, key: String): Flowable<Any>
fun purchaseQuest(key: String): Flowable<Void>
fun purchaseQuest(key: String): Flowable<Any>
fun purchaseItem(purchaseType: String, key: String): Flowable<Void>
fun purchaseItem(purchaseType: String, key: String): Flowable<Any>
fun togglePinnedItem(item: ShopItem): Flowable<List<ShopItem>>
}

View file

@ -308,11 +308,11 @@ class ApiClientImpl//private OnHabitsAPIResult mResultListener;
return apiService.buyItem(itemKey).compose(configureApiCallObserver())
}
override fun purchaseItem(type: String, itemKey: String): Flowable<Void> {
override fun purchaseItem(type: String, itemKey: String): Flowable<Any> {
return apiService.purchaseItem(type, itemKey).compose(configureApiCallObserver())
}
override fun validateSubscription(request: SubscriptionValidationRequest): Flowable<Void> {
override fun validateSubscription(request: SubscriptionValidationRequest): Flowable<Any> {
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<Void> {
override fun purchaseHourglassItem(type: String, itemKey: String): Flowable<Any> {
return apiService.purchaseHourglassItem(type, itemKey).compose(configureApiCallObserver())
}
override fun purchaseMysterySet(itemKey: String): Flowable<Void> {
override fun purchaseMysterySet(itemKey: String): Flowable<Any> {
return apiService.purchaseMysterySet(itemKey).compose(configureApiCallObserver())
}
override fun purchaseQuest(key: String): Flowable<Void> {
override fun purchaseQuest(key: String): Flowable<Any> {
return apiService.purchaseQuest(key).compose(configureApiCallObserver())
}

View file

@ -223,19 +223,19 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie
return apiClient.retrieveMarketGear()
}
override fun purchaseMysterySet(categoryIdentifier: String): Flowable<Void> {
override fun purchaseMysterySet(categoryIdentifier: String): Flowable<Any> {
return apiClient.purchaseMysterySet(categoryIdentifier)
}
override fun purchaseHourglassItem(purchaseType: String, key: String): Flowable<Void> {
override fun purchaseHourglassItem(purchaseType: String, key: String): Flowable<Any> {
return apiClient.purchaseHourglassItem(purchaseType, key)
}
override fun purchaseQuest(key: String): Flowable<Void> {
override fun purchaseQuest(key: String): Flowable<Any> {
return apiClient.purchaseQuest(key)
}
override fun purchaseItem(purchaseType: String, key: String): Flowable<Void> {
override fun purchaseItem(purchaseType: String, key: String): Flowable<Any> {
return apiClient.purchaseItem(purchaseType, key)
}

View file

@ -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<Void>
val observable: Flowable<Any>
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<Void>()
buyResponse
}
} else {
observable = inventoryRepository.purchaseItem(shopItem.purchaseType, shopItem.key)