From 07e545079cc12e63fb4c94b383a2af0938289850 Mon Sep 17 00:00:00 2001 From: Amine Date: Sun, 29 Oct 2017 12:55:03 +0100 Subject: [PATCH] Fixes full height cards problem. --- .../adapters/ItemCardAdapter.kt | 13 +- app/src/main/res/layout/card_item.xml | 270 +++++++++--------- 2 files changed, 135 insertions(+), 148 deletions(-) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt index cab17a8..126669a 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt @@ -52,7 +52,7 @@ class ItemCardAdapter(private val app: Activity, private val generator: ColorGenerator = ColorGenerator.MATERIAL override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - val v = LayoutInflater.from(c).inflate(R.layout.card_item, parent, false) as ConstraintLayout + val v = LayoutInflater.from(c).inflate(R.layout.card_item, parent, false) as CardView return ViewHolder(v) } @@ -69,14 +69,9 @@ class ItemCardAdapter(private val app: Activity, Glide.with(c).clear(holder.itemImage) holder.itemImage.setImageDrawable(null) } else { - if (fullHeightCards) { - c.bitmapFitCenter(itm.getThumbnail(c), holder.itemImage) - } else { - c.bitmapCenterCrop(itm.getThumbnail(c), holder.itemImage) - } + c.bitmapCenterCrop(itm.getThumbnail(c), holder.itemImage) } - val fHolder = holder if (itm.getIcon(c).isEmpty()) { val color = generator.getColor(itm.sourcetitle) @@ -163,7 +158,7 @@ class ItemCardAdapter(private val app: Activity, } - inner class ViewHolder(val mView: ConstraintLayout) : RecyclerView.ViewHolder(mView) { + inner class ViewHolder(val mView: CardView) : RecyclerView.ViewHolder(mView) { lateinit var saveBtn: LikeButton lateinit var browserBtn: ImageButton lateinit var shareBtn: ImageButton @@ -173,7 +168,7 @@ class ItemCardAdapter(private val app: Activity, lateinit var sourceTitleAndDate: TextView init { - (mView.findViewById(R.id.card)).setCardBackgroundColor(appColors.cardBackground) + mView.setCardBackgroundColor(appColors.cardBackground) handleClickListeners() handleCustomTabActions() } diff --git a/app/src/main/res/layout/card_item.xml b/app/src/main/res/layout/card_item.xml index cfc0fa5..082baa6 100644 --- a/app/src/main/res/layout/card_item.xml +++ b/app/src/main/res/layout/card_item.xml @@ -1,157 +1,149 @@ - + - + + + + android:id="@+id/constraintLayout" + android:layout_width="0dp" + android:layout_height="wrap_content" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toBottomOf="@+id/itemImage"> - - + + + + + + + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toBottomOf="@+id/sourceTitleAndDate"> - + + android:elevation="5dp" + android:padding="4dp" + app:icon_size="22dp" + app:icon_type="heart" /> - + - + - - android:layout_centerVertical="true" - android:layout_alignParentRight="true" - android:layout_alignParentEnd="true" - android:elevation="5dp" - android:padding="4dp" - android:layout_marginRight="8dp" - android:layout_marginEnd="8dp"/> - - - - - - - - + - - \ No newline at end of file + \ No newline at end of file