mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-24 22:55:59 +00:00
Improve background handling
This commit is contained in:
parent
48a99e1412
commit
a8914d4b95
6 changed files with 26 additions and 8 deletions
|
|
@ -110,7 +110,12 @@
|
|||
<fragment
|
||||
android:id="@+id/shopsFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.shops.ShopsFragment"
|
||||
android:label="@string/sidebar_shops" />
|
||||
android:label="@string/sidebar_shops" >
|
||||
<argument
|
||||
android:name="selectedTab"
|
||||
app:argType="integer"
|
||||
android:defaultValue="0" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/avatarOverviewFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.customization.AvatarOverviewFragment"
|
||||
|
|
|
|||
|
|
@ -272,11 +272,11 @@
|
|||
</style>
|
||||
|
||||
<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
|
||||
<item name="colorAccent">@color/brand_100</item>
|
||||
<item name="colorAccent">@color/brand_400</item>
|
||||
</style>
|
||||
|
||||
<style name="HabiticaAlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
|
||||
<item name="colorAccent">@color/brand_100</item>
|
||||
<item name="colorAccent">@color/brand_400</item>
|
||||
<item name="android:windowFrame">@null</item>
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ class CustomizationRecyclerViewAdapter : androidx.recyclerview.widget.RecyclerVi
|
|||
val dialog = HabiticaAlertDialog(itemView.context)
|
||||
dialog.setMessage(R.string.purchase_from_timetravel_shop)
|
||||
dialog.addButton(R.string.go_shopping, true) { _, _ ->
|
||||
MainNavigationController.navigate(R.id.shopsFragment)
|
||||
MainNavigationController.navigate(R.id.shopsFragment, bundleOf(Pair("selectedTab", 3)))
|
||||
}
|
||||
dialog.addButton(R.string.reward_dialog_dismiss, false)
|
||||
dialog.show()
|
||||
|
|
|
|||
|
|
@ -39,6 +39,13 @@ class ShopsFragment : BaseMainFragment() {
|
|||
setViewPagerAdapter()
|
||||
toolbarAccessoryContainer?.addView(currencyView)
|
||||
|
||||
arguments?.let {
|
||||
val args = ShopsFragmentArgs.fromBundle(it)
|
||||
if (args.selectedTab > 0) {
|
||||
viewPager.currentItem = args.selectedTab
|
||||
}
|
||||
}
|
||||
|
||||
compositeSubscription.add(userRepository.getUser().subscribe(Consumer { updateCurrencyView(it) }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
val gemsLeft = if (shopItem.limitedNumberLeft != null) shopItem.limitedNumberLeft else 0
|
||||
if ((gemsLeft == 0 && shopItem.purchaseType == "gems") || shopItem.canAfford(user, false)) {
|
||||
val observable: Flowable<Any>
|
||||
if (shopIdentifier != null && shopIdentifier == Shop.TIME_TRAVELERS_SHOP || "mystery_set" == shopItem.purchaseType) {
|
||||
if (shopIdentifier != null && shopIdentifier == Shop.TIME_TRAVELERS_SHOP || "mystery_set" == shopItem.purchaseType || shopItem.currency == "hourglasses") {
|
||||
observable = if (shopItem.purchaseType == "gear") {
|
||||
inventoryRepository.purchaseMysterySet(shopItem.key)
|
||||
} else {
|
||||
|
|
@ -253,7 +253,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
.flatMap { userRepository.retrieveUser(withTasks = false, forced = true) }
|
||||
.flatMap { inventoryRepository.retrieveInAppRewards() }
|
||||
.subscribe({
|
||||
if (item.isTypeGear) {
|
||||
if (item.isTypeGear || item.currency == "hourglasses") {
|
||||
EventBus.getDefault().post(GearPurchasedEvent(item))
|
||||
}
|
||||
}) { throwable ->
|
||||
|
|
@ -280,9 +280,9 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
|
||||
private fun setBuyButtonEnabled(enabled: Boolean) {
|
||||
if (enabled) {
|
||||
buyButton.alpha = 0.5f
|
||||
} else {
|
||||
buyButton.alpha = 1.0f
|
||||
} else {
|
||||
buyButton.alpha = 0.5f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ import android.widget.TextView
|
|||
import com.facebook.drawee.backends.pipeline.Fresco
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.extensions.dpToPx
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
||||
import com.habitrpg.android.habitica.models.shops.ShopItem
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
|
||||
|
||||
abstract class PurchaseDialogContent : LinearLayout {
|
||||
|
||||
private val imageView: SimpleDraweeView by bindView(R.id.imageView)
|
||||
|
|
@ -43,6 +45,10 @@ abstract class PurchaseDialogContent : LinearLayout {
|
|||
.setAutoPlayAnimations(true)
|
||||
.build()
|
||||
imageView.controller = controller
|
||||
val params = imageView.layoutParams
|
||||
params.height = 147.dpToPx(context)
|
||||
params.width = 140.dpToPx(context)
|
||||
imageView.layoutParams = params
|
||||
} else {
|
||||
DataBindingUtils.loadImage(imageView, item.imageName)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue