mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-21 13:19:02 +00:00
Indicate which gear is two handed. See #688
This commit is contained in:
parent
2ab544d03e
commit
bb8b795cfa
7 changed files with 51 additions and 6 deletions
6
Habitica/res/drawable/layout_rounded_bg_white.xml
Normal file
6
Habitica/res/drawable/layout_rounded_bg_white.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/white" />
|
||||
<corners android:radius="@dimen/rounded_button_radius"/>
|
||||
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
|
||||
</shape>
|
||||
|
|
@ -7,12 +7,17 @@
|
|||
style="@style/RowWrapper"
|
||||
android:id="@+id/gear_container">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:layout_width="@dimen/gear_image_size"
|
||||
android:layout_height="@dimen/gear_image_size"
|
||||
android:id="@+id/gear_image"
|
||||
android:layout_marginRight="@dimen/row_padding"
|
||||
app:actualImageScaleType="fitCenter"/>
|
||||
<FrameLayout
|
||||
android:id="@+id/gear_icon_background_view"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginRight="@dimen/row_padding">
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:layout_width="@dimen/gear_image_size"
|
||||
android:layout_height="@dimen/gear_image_size"
|
||||
android:id="@+id/gear_image"
|
||||
app:actualImageScaleType="fitCenter"/>
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
|
|
@ -38,6 +43,13 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:id="@+id/gear_notes"
|
||||
style="@style/RowText" />
|
||||
<TextView
|
||||
android:id="@+id/two_handed_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/two_handed"
|
||||
android:textColor="@color/brand_400"
|
||||
android:drawablePadding="@dimen/spacing_small"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -812,4 +812,5 @@
|
|||
<string name="week_reminder_text">Breaks are healthy, but you can still earn points for simple activities to level up and get cool gear!</string>
|
||||
<string name="last_login">Latest Check In</string>
|
||||
<string name="total_checkins">Total Checkins</string>
|
||||
<string name="two_handed">Two-Handed</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -22,4 +22,5 @@ open class Equipment : RealmObject() {
|
|||
@SerializedName("int")
|
||||
var _int: Int = 0
|
||||
var owned: Boolean? = null
|
||||
var twoHanded = false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
package com.habitrpg.android.habitica.ui.adapter.inventory
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.extensions.backgroundCompat
|
||||
import com.habitrpg.android.habitica.extensions.notNull
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import com.habitrpg.android.habitica.models.inventory.Equipment
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.realm.OrderedRealmCollection
|
||||
import io.realm.RealmRecyclerViewAdapter
|
||||
|
|
@ -42,13 +46,16 @@ class EquipmentRecyclerViewAdapter(data: OrderedRealmCollection<Equipment>?, aut
|
|||
private val gearNameTextView: TextView by bindView(itemView, R.id.gear_text)
|
||||
private val gearNotesTextView: TextView by bindView(itemView, R.id.gear_notes)
|
||||
private val imageView: SimpleDraweeView by bindView(itemView, R.id.gear_image)
|
||||
private val imageViewWrapper: FrameLayout by bindView(itemView, R.id.gear_icon_background_view)
|
||||
private val equippedIndicator: View by bindView(itemView, R.id.equippedIndicator)
|
||||
private val twoHandedView: TextView by bindView(R.id.two_handed_view)
|
||||
|
||||
var gear: Equipment? = null
|
||||
var context: Context = itemView.context
|
||||
|
||||
init {
|
||||
context = itemView.context
|
||||
twoHandedView.setCompoundDrawablesWithIntrinsicBounds(BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfTwoHandedIcon()), null, null, null)
|
||||
itemView.setOnClickListener {
|
||||
val key = gear?.key
|
||||
if (key != null) {
|
||||
|
|
@ -71,10 +78,13 @@ class EquipmentRecyclerViewAdapter(data: OrderedRealmCollection<Equipment>?, aut
|
|||
if (gear.key == equippedGear) {
|
||||
this.equippedIndicator.visibility = View.VISIBLE
|
||||
this.gearContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.brand_700))
|
||||
imageViewWrapper.backgroundCompat = ContextCompat.getDrawable(context, R.drawable.layout_rounded_bg_white)
|
||||
} else {
|
||||
this.equippedIndicator.visibility = View.GONE
|
||||
this.gearContainer.setBackgroundResource(R.drawable.selection_highlight)
|
||||
imageViewWrapper.backgroundCompat = ContextCompat.getDrawable(context, R.drawable.layout_rounded_bg_gray_700)
|
||||
}
|
||||
twoHandedView.visibility = if (gear.twoHanded) View.VISIBLE else View.GONE
|
||||
DataBindingUtils.loadImage(imageView, "shop_"+gear.key)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -657,4 +657,18 @@ public class HabiticaIconsHelper {
|
|||
|
||||
return imageOfChatDeleteIcon;
|
||||
}
|
||||
|
||||
private static Bitmap imageOfTwoHandedIcon = null;
|
||||
public static Bitmap imageOfTwoHandedIcon() {
|
||||
if (imageOfTwoHandedIcon != null)
|
||||
return imageOfTwoHandedIcon;
|
||||
|
||||
int size = scaleSize(15);
|
||||
imageOfTwoHandedIcon = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(imageOfTwoHandedIcon);
|
||||
canvas.scale(displayDensity, displayDensity);
|
||||
HabiticaIcons.drawTwoHandedIcon(canvas);
|
||||
|
||||
return imageOfTwoHandedIcon;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class EquipmentListDeserializer implements JsonDeserializer<List<Equipmen
|
|||
item.setStr(parsedItem.getStr());
|
||||
item.setPer(parsedItem.getPer());
|
||||
item.set_int(parsedItem.get_int());
|
||||
item.setTwoHanded(parsedItem.getTwoHanded());
|
||||
} else {
|
||||
item.setOwned(itemObject.getAsBoolean());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue