resize mounts cards

This commit is contained in:
Leland Wu 2020-05-22 14:17:45 -04:00
parent 6999f3a675
commit a43340a15b
6 changed files with 66 additions and 9 deletions

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:background="@color/white"
android:focusable="true">
<LinearLayout
android:id="@+id/card_view"
android:layout_width="124dp"
android:layout_height="156dp"
android:layout_centerInParent="true"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:background="@drawable/layout_rounded_bg_shopitem"
android:orientation="vertical">
style="@style/CardContent">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/imageView"
android:layout_width="@dimen/mount_image_width"
android:layout_height="@dimen/mount_image_height"
android:layout_gravity="center_horizontal"
android:scaleType="fitEnd" />
<TextView
android:id="@+id/titleTextView"
style="@style/RowTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="3.5dp"
android:gravity="center"
android:textSize="13sp" />
<TextView
android:id="@+id/ownedTextView"
style="@style/RowText"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/layout_rounded_bg_shopitem_price"
android:gravity="center"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>

View file

@ -51,9 +51,12 @@
<dimen name="row_text_size">14sp</dimen>
<dimen name="row_title_bottommargin">2dp</dimen>
<dimen name="pet_width">84dp</dimen>
<dimen name="mount_width">120dp</dimen>
<dimen name="bottom_menu_padding">28dp</dimen>
<dimen name="pet_image_width">68dp</dimen>
<dimen name="pet_image_height">65dp</dimen>
<dimen name="mount_image_width">81dp</dimen>
<dimen name="mount_image_height">99dp</dimen>
<dimen name="shop_height">124dp</dimen>
<dimen name="bar_icon_padding">10dp</dimen>
<dimen name="task_text_padding">16dp</dimen>

View file

@ -39,7 +39,7 @@ class MountDetailRecyclerAdapter(data: OrderedRealmCollection<Mount>?, autoUpdat
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MountViewHolder {
return MountViewHolder(parent.inflate(R.layout.animal_overview_item))
return MountViewHolder(parent.inflate(R.layout.pet_overview_item))
}
override fun onBindViewHolder(holder: MountViewHolder, position: Int) {

View file

@ -6,7 +6,6 @@ import android.graphics.drawable.BitmapDrawable
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.GridLayoutManager
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
@ -45,9 +44,11 @@ class StableRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapter<
} else if (viewType == 1) {
val view = parent.inflate(R.layout.customization_section_header)
SectionViewHolder(view)
}
else {
val view = parent.inflate(R.layout.animal_overview_item)
} else if (viewType == 2) {
val view = parent.inflate(R.layout.pet_overview_item)
StableViewHolder(view)
} else {
val view = parent.inflate(R.layout.mount_overview_item)
StableViewHolder(view)
}
@ -70,15 +71,20 @@ class StableRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapter<
}
override fun getItemViewType(position: Int): Int {
return if (itemList[position] == "header") {
var item = itemList[position]
return if (item == "header") {
0
}
else if (itemList[position].javaClass == String::class.java) {
else if (item.javaClass == String::class.java) {
1
}
else {
else if (itemType == "pets") {
2
}
else {
3
}
}
override fun getItemCount(): Int = itemList.size

View file

@ -106,7 +106,8 @@ class StableRecyclerFragment : BaseFragment() {
private fun setGridSpanCount(width: Int) {
var spanCount = 0
if (context != null && context?.resources != null) {
val itemWidth: Float = context?.resources?.getDimension(R.dimen.pet_width) ?: 0.toFloat()
var animal_width = if (itemType == "pets") R.dimen.pet_width else R.dimen.mount_width
val itemWidth: Float = context?.resources?.getDimension(animal_width) ?: 0.toFloat()
spanCount = (width / itemWidth).toInt()
}