Fixes full height cards problem.

This commit is contained in:
Amine 2017-10-29 12:55:03 +01:00
parent 95d64dc5e8
commit 07e545079c
2 changed files with 135 additions and 148 deletions

View File

@ -52,7 +52,7 @@ class ItemCardAdapter(private val app: Activity,
private val generator: ColorGenerator = ColorGenerator.MATERIAL private val generator: ColorGenerator = ColorGenerator.MATERIAL
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { 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) return ViewHolder(v)
} }
@ -69,14 +69,9 @@ class ItemCardAdapter(private val app: Activity,
Glide.with(c).clear(holder.itemImage) Glide.with(c).clear(holder.itemImage)
holder.itemImage.setImageDrawable(null) holder.itemImage.setImageDrawable(null)
} else { } else {
if (fullHeightCards) { c.bitmapCenterCrop(itm.getThumbnail(c), holder.itemImage)
c.bitmapFitCenter(itm.getThumbnail(c), holder.itemImage)
} else {
c.bitmapCenterCrop(itm.getThumbnail(c), holder.itemImage)
}
} }
val fHolder = holder
if (itm.getIcon(c).isEmpty()) { if (itm.getIcon(c).isEmpty()) {
val color = generator.getColor(itm.sourcetitle) 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 saveBtn: LikeButton
lateinit var browserBtn: ImageButton lateinit var browserBtn: ImageButton
lateinit var shareBtn: ImageButton lateinit var shareBtn: ImageButton
@ -173,7 +168,7 @@ class ItemCardAdapter(private val app: Activity,
lateinit var sourceTitleAndDate: TextView lateinit var sourceTitleAndDate: TextView
init { init {
(mView.findViewById<CardView>(R.id.card)).setCardBackgroundColor(appColors.cardBackground) mView.setCardBackgroundColor(appColors.cardBackground)
handleClickListeners() handleClickListeners()
handleCustomTabActions() handleCustomTabActions()
} }

View File

@ -1,157 +1,149 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v7.widget.CardView
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"> xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
app:layout_constraintHorizontal_bias="0.62"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
card_view:cardElevation="2dp"
card_view:cardUseCompatPadding="true"
card_view:layout_constraintBottom_toBottomOf="parent">
<android.support.v7.widget.CardView <android.support.constraint.ConstraintLayout
android:id="@+id/card" android:layout_width="match_parent"
xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_height="wrap_content">
android:layout_width="0dp"
app:layout_constraintRight_toRightOf="parent" <ImageView
app:layout_constraintLeft_toLeftOf="parent" android:id="@+id/itemImage"
app:layout_constraintHorizontal_bias="0.62" android:layout_width="0dp"
app:layout_constraintTop_toTopOf="parent" android:layout_height="wrap_content"
card_view:cardElevation="2dp" android:adjustViewBounds="true"
card_view:cardUseCompatPadding="true" android:cropToPadding="true"
android:layout_height="wrap_content" app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="8dp" app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp" app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp" app:srcCompat="@drawable/background_splash"
android:layout_marginEnd="8dp" card_view:layout_constraintBottom_toTopOf="@+id/constraintLayout" />
android:layout_marginRight="8dp">
<android.support.constraint.ConstraintLayout <android.support.constraint.ConstraintLayout
android:layout_width="match_parent" android:id="@+id/constraintLayout"
android:layout_height="wrap_content"> 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">
<ImageView <ImageView
android:layout_width="0dp" android:id="@+id/sourceImage"
android:layout_height="wrap_content" android:layout_width="40dp"
app:srcCompat="@drawable/background_splash" android:layout_height="40dp"
android:id="@+id/itemImage" android:layout_marginLeft="8dp"
android:scaleType="fitCenter" android:layout_marginStart="8dp"
android:adjustViewBounds="true" android:layout_marginTop="8dp"
android:cropToPadding="true"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="parent" />
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/itemImage"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/background_splash" />
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:gravity="start"
android:textAlignment="viewStart"
android:textStyle="bold"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="@+id/sourceImage"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/sourceImage"
tools:text="Titre" />
<TextView
android:id="@+id/sourceTitleAndDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="start"
android:textAlignment="viewStart"
android:textSize="14sp"
app:layout_constraintLeft_toLeftOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/title"
tools:text="Google Actualité Il y a 5h" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
> app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/sourceTitleAndDate">
<ImageView <com.like.LikeButton
android:layout_height="40dp" android:id="@+id/favButton"
app:srcCompat="@drawable/background_splash" android:layout_width="35dp"
android:id="@+id/sourceImage" android:layout_height="35dp"
app:layout_constraintLeft_toLeftOf="parent" android:layout_alignParentEnd="true"
android:layout_marginStart="8dp" android:layout_alignParentRight="true"
android:layout_marginLeft="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
android:layout_width="40dp" />
<TextView android:layout_centerVertical="true"
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginStart="8dp" android:elevation="5dp"
android:gravity="start" android:padding="4dp"
android:textAlignment="viewStart" app:icon_size="22dp"
android:textStyle="bold" app:icon_type="heart" />
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="@+id/sourceImage"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/sourceImage"
tools:text="Titre" />
<TextView <ImageButton
android:layout_width="wrap_content" android:id="@+id/shareBtn"
android:layout_height="wrap_content" android:layout_width="35dp"
android:id="@+id/sourceTitleAndDate" android:layout_height="35dp"
android:textSize="14sp" android:layout_centerVertical="true"
tools:text="Google Actualité Il y a 5h" android:layout_marginEnd="16dp"
android:textAlignment="viewStart" android:layout_marginRight="16dp"
app:layout_constraintTop_toBottomOf="@+id/title" android:layout_toLeftOf="@+id/favButton"
android:layout_marginTop="8dp" android:layout_toStartOf="@+id/favButton"
app:layout_constraintLeft_toLeftOf="@+id/title" android:adjustViewBounds="true"
android:gravity="start" /> android:background="@android:color/transparent"
android:elevation="5dp"
android:padding="4dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_share_black_24dp"
android:tint="?android:attr/textColorPrimary" />
<RelativeLayout <ImageButton
android:layout_width="0dp" android:id="@+id/browserBtn"
android:layout_height="wrap_content" android:layout_width="35dp"
app:layout_constraintTop_toBottomOf="@+id/sourceTitleAndDate" android:layout_height="35dp"
android:layout_marginTop="16dp" android:layout_centerVertical="true"
app:layout_constraintLeft_toLeftOf="parent" android:layout_marginEnd="16dp"
app:layout_constraintRight_toRightOf="parent" android:layout_marginRight="16dp"
app:layout_constraintBottom_toBottomOf="parent"> android:layout_toLeftOf="@+id/shareBtn"
android:layout_toStartOf="@+id/shareBtn"
android:adjustViewBounds="true"
android:background="@android:color/transparent"
android:elevation="5dp"
android:padding="4dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_open_in_browser_black_24dp"
android:tint="?android:attr/textColorPrimary" />
<com.like.LikeButton </RelativeLayout>
app:icon_type="heart"
app:icon_size="22dp"
android:id="@+id/favButton"
android:layout_width="35dp"
android:layout_height="35dp"
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"/>
<ImageButton
android:id="@+id/shareBtn"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@+id/favButton"
android:layout_toStartOf="@+id/favButton"
android:adjustViewBounds="true"
android:background="@android:color/transparent"
android:elevation="5dp"
android:padding="4dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_share_black_24dp"
android:tint="?android:attr/textColorPrimary" />
<ImageButton
android:id="@+id/browserBtn"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@+id/shareBtn"
android:layout_toStartOf="@+id/shareBtn"
android:adjustViewBounds="true"
android:background="@android:color/transparent"
android:elevation="5dp"
android:padding="4dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_open_in_browser_black_24dp"
android:tint="?android:attr/textColorPrimary" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>