Update pet detail design

This commit is contained in:
Phillip Thelen 2020-06-25 17:57:01 +02:00
parent d5b113ea7a
commit 901bd078fd
9 changed files with 29 additions and 31 deletions

View file

@ -162,7 +162,7 @@ android {
multiDexEnabled true
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
versionCode 2459
versionCode 2462
versionName "2.7"
}

View file

@ -1,28 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="96dp"
android:layout_width="76dp"
android:background="@drawable/layout_rounded_bg_gray_700"
android:orientation="vertical"
style="@style/CardContent">
android:padding="8dp">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/imageView"
android:layout_width="@dimen/pet_image_width"
android:layout_height="@dimen/pet_image_height"
android:layout_gravity="center_horizontal"
android:scaleType="fitEnd" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="@+id/titleTextView"
style="@style/RowTitle"/>
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center"
app:actualImageScaleType="fitCenter"/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/trainedProgressBar"
android:progressTint="@color/green_100"
android:progressBackgroundTint="@color/gray_600"
android:progressBackgroundTintMode="src_over"
android:layout_marginTop="4dp"
android:max="50" />
</LinearLayout>

View file

@ -368,7 +368,12 @@ class ApiClientImpl//private OnHabitsAPIResult mResultListener;
}
override fun feedPet(petKey: String, foodKey: String): Flowable<FeedResponse> {
return apiService.feedPet(petKey, foodKey).compose(configureApiCallObserver())
return apiService.feedPet(petKey, foodKey)
.map {
it.data.message = it.message
it
}
.compose(configureApiCallObserver())
}
override fun hatchPet(eggKey: String, hatchingPotionKey: String): Flowable<Items> {

View file

@ -204,7 +204,7 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie
override fun feedPet(pet: Pet, food: Food): Flowable<FeedResponse> {
return apiClient.feedPet(pet.key, food.key)
.doOnNext { feedResponse ->
localRepository.feedPet(food.key, pet.key, feedResponse.value, userID)
localRepository.feedPet(food.key, pet.key, feedResponse.value ?: 0, userID)
}
}

View file

@ -1,7 +0,0 @@
package com.habitrpg.android.habitica.models.responses;
public class FeedResponse {
public Integer value;
}

View file

@ -0,0 +1,6 @@
package com.habitrpg.android.habitica.models.responses
class FeedResponse {
var value: Int? = null
var message: String? = null
}

View file

@ -13,6 +13,7 @@ public class HabitResponse<T> {
public T data;
public List<Notification> notifications;
private Boolean success;
public String message;
/**
* @return The success

View file

@ -432,7 +432,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
val pet = event.usingPet
compositeSubscription.add(this.inventoryRepository.feedPet(event.usingPet, event.usingFood)
.subscribe(Consumer { feedResponse ->
HabiticaSnackbar.showSnackbar(snackbarContainer, getString(R.string.notification_pet_fed, pet.text), SnackbarDisplayType.NORMAL)
HabiticaSnackbar.showSnackbar(snackbarContainer, feedResponse.message, SnackbarDisplayType.NORMAL)
if (feedResponse.value == -1) {
val mountWrapper = View.inflate(this, R.layout.pet_imageview, null) as? FrameLayout
val mountImageView = mountWrapper?.findViewById(R.id.pet_imageview) as? SimpleDraweeView

View file

@ -72,7 +72,6 @@ class PetDetailRecyclerAdapter(data: OrderedRealmCollection<Pet>?, autoUpdate: B
var ownedPet: OwnedPet? = null
private val imageView: SimpleDraweeView by bindView(R.id.imageView)
private val titleView: TextView by bindView(R.id.titleTextView)
private val trainedProgressbar: ProgressBar by bindView(R.id.trainedProgressBar)
private val isOwned: Boolean
@ -95,13 +94,8 @@ class PetDetailRecyclerAdapter(data: OrderedRealmCollection<Pet>?, autoUpdate: B
fun bind(item: Pet, ownedPet: OwnedPet?) {
this.animal = item
this.ownedPet = ownedPet
titleView.text = when {
item.color == "Veggie" -> context?.getString(R.string.garden)
item.type == "special" ->item.text
else -> item.color
}
this.imageView.alpha = 1.0f
val imageName = "Pet-$itemType-${item.color}"
val imageName = "social_Pet-$itemType-${item.color}"
if (this.ownedPet?.trained ?: 0 > 0) {
if (this.canRaiseToMount) {
this.trainedProgressbar.visibility = View.VISIBLE