mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 22:37:56 +01:00 
			
		
		
		
	Grid items optimizations (#6641)
Use ConstraintLayout for ez size ratio calculation and merge cover-only view holder with compact's
This commit is contained in:
		| @@ -1,5 +1,5 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:layout_width="match_parent" | ||||
| @@ -9,57 +9,55 @@ | ||||
|     android:foreground="@drawable/library_item_selector_overlay" | ||||
|     android:padding="4dp"> | ||||
|  | ||||
|     <androidx.constraintlayout.widget.ConstraintLayout | ||||
|     <com.google.android.material.progressindicator.CircularProgressIndicator | ||||
|         android:id="@+id/progress" | ||||
|         style="@style/Widget.Tachiyomi.CircularProgressIndicator.Small" | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:indeterminate="true" | ||||
|         android:visibility="gone" | ||||
|         app:layout_constraintBottom_toBottomOf="@+id/thumbnail" | ||||
|         app:layout_constraintEnd_toEndOf="@+id/thumbnail" | ||||
|         app:layout_constraintStart_toStartOf="@+id/thumbnail" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         tools:visibility="visible" /> | ||||
|  | ||||
|     <com.google.android.material.imageview.ShapeableImageView | ||||
|         android:id="@+id/thumbnail" | ||||
|         android:layout_width="0dp" | ||||
|         android:layout_height="0dp" | ||||
|         android:scaleType="centerCrop" | ||||
|         app:layout_constraintDimensionRatio="w,3:2" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Cover" | ||||
|         tools:ignore="ContentDescription" | ||||
|         tools:src="@mipmap/ic_launcher" /> | ||||
|  | ||||
|     <include | ||||
|         android:id="@+id/badges" | ||||
|         layout="@layout/source_grid_item_badges" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content"> | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_marginHorizontal="4dp" | ||||
|         android:layout_marginTop="4dp" | ||||
|         app:layout_constraintEnd_toEndOf="@+id/thumbnail" | ||||
|         app:layout_constraintStart_toStartOf="@+id/thumbnail" | ||||
|         app:layout_constraintTop_toTopOf="@+id/thumbnail" /> | ||||
|  | ||||
|         <FrameLayout | ||||
|             android:id="@+id/card" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="220dp" | ||||
|             android:background="@drawable/rounded_rectangle" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintStart_toStartOf="parent" | ||||
|             app:layout_constraintTop_toTopOf="parent"> | ||||
|     <TextView | ||||
|         android:id="@+id/title" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:ellipsize="end" | ||||
|         android:maxLines="2" | ||||
|         android:padding="4dp" | ||||
|         android:textAppearance="?attr/textAppearanceTitleSmall" | ||||
|         android:textColor="@color/source_comfortable_item_title" | ||||
|         android:textSize="12sp" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toBottomOf="@+id/thumbnail" | ||||
|         tools:text="Sample name" /> | ||||
|  | ||||
|             <ImageView | ||||
|                 android:id="@+id/thumbnail" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="match_parent" | ||||
|                 android:background="?attr/colorSurface" | ||||
|                 android:scaleType="centerCrop" | ||||
|                 tools:ignore="ContentDescription" | ||||
|                 tools:src="@mipmap/ic_launcher" /> | ||||
|  | ||||
|             <include | ||||
|                 android:id="@+id/badges" | ||||
|                 layout="@layout/source_grid_item_badges" /> | ||||
|  | ||||
|             <com.google.android.material.progressindicator.CircularProgressIndicator | ||||
|                 android:id="@+id/progress" | ||||
|                 style="@style/Widget.Tachiyomi.CircularProgressIndicator.Small" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_gravity="center" | ||||
|                 android:indeterminate="true" | ||||
|                 android:visibility="gone" /> | ||||
|  | ||||
|         </FrameLayout> | ||||
|  | ||||
|         <TextView | ||||
|             android:id="@+id/title" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:ellipsize="end" | ||||
|             android:maxLines="2" | ||||
|             android:padding="4dp" | ||||
|             android:textAppearance="?attr/textAppearanceTitleSmall" | ||||
|             android:textSize="12sp" | ||||
|             android:textColor="@color/source_comfortable_item_title" | ||||
|             app:layout_constraintStart_toStartOf="parent" | ||||
|             app:layout_constraintTop_toBottomOf="@+id/card" | ||||
|             tools:text="Sample name" /> | ||||
|  | ||||
|     </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|  | ||||
| </FrameLayout> | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="wrap_content" | ||||
| @@ -8,58 +9,64 @@ | ||||
|     android:foreground="@drawable/library_item_selector_overlay" | ||||
|     android:padding="4dp"> | ||||
|  | ||||
|     <FrameLayout | ||||
|         android:id="@+id/card" | ||||
|     <com.google.android.material.imageview.ShapeableImageView | ||||
|         android:id="@+id/thumbnail" | ||||
|         android:layout_width="0dp" | ||||
|         android:layout_height="0dp" | ||||
|         android:scaleType="centerCrop" | ||||
|         android:foreground="@drawable/card_gradient_shape" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintDimensionRatio="w,2:3" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Cover" | ||||
|         tools:ignore="ContentDescription" | ||||
|         tools:src="@mipmap/ic_launcher" /> | ||||
|  | ||||
|     <include | ||||
|         android:id="@+id/badges" | ||||
|         layout="@layout/source_grid_item_badges" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_marginHorizontal="4dp" | ||||
|         android:layout_marginTop="4dp" | ||||
|         app:layout_constraintEnd_toEndOf="@+id/thumbnail" | ||||
|         app:layout_constraintStart_toStartOf="@+id/thumbnail" | ||||
|         app:layout_constraintTop_toTopOf="@+id/thumbnail" /> | ||||
|  | ||||
|     <TextView | ||||
|         android:id="@+id/title" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_gravity="bottom" | ||||
|         android:ellipsize="end" | ||||
|         android:maxLines="2" | ||||
|         android:padding="8dp" | ||||
|         android:shadowColor="@color/md_black_1000" | ||||
|         android:shadowDx="0" | ||||
|         android:shadowDy="0" | ||||
|         android:shadowRadius="4" | ||||
|         android:textAppearance="?attr/textAppearanceTitleSmall" | ||||
|         android:textColor="@color/md_white_1000" | ||||
|         android:textSize="12sp" | ||||
|         app:layout_constraintBottom_toBottomOf="@+id/thumbnail" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         tools:text="Sample name" /> | ||||
|  | ||||
|     <com.google.android.material.progressindicator.CircularProgressIndicator | ||||
|         android:id="@+id/progress" | ||||
|         style="@style/Widget.Tachiyomi.CircularProgressIndicator.Small" | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="220dp" | ||||
|         android:background="@drawable/rounded_rectangle"> | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_gravity="center" | ||||
|         android:indeterminate="true" | ||||
|         android:visibility="gone" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         tools:visibility="visible" /> | ||||
|  | ||||
|         <ImageView | ||||
|             android:id="@+id/thumbnail" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent" | ||||
|             android:background="?attr/colorSurface" | ||||
|             android:scaleType="centerCrop" | ||||
|             tools:ignore="ContentDescription" | ||||
|             tools:src="@mipmap/ic_launcher" /> | ||||
|  | ||||
|         <View | ||||
|             android:id="@+id/gradient" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_gravity="bottom" | ||||
|             android:background="@drawable/gradient_shape" /> | ||||
|  | ||||
|         <include | ||||
|             android:id="@+id/badges" | ||||
|             layout="@layout/source_grid_item_badges" /> | ||||
|  | ||||
|         <TextView | ||||
|             android:id="@+id/title" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_gravity="bottom" | ||||
|             android:ellipsize="end" | ||||
|             android:maxLines="2" | ||||
|             android:padding="8dp" | ||||
|             android:shadowColor="@color/md_black_1000" | ||||
|             android:shadowDx="0" | ||||
|             android:shadowDy="0" | ||||
|             android:shadowRadius="4" | ||||
|             android:textAppearance="?attr/textAppearanceTitleSmall" | ||||
|             android:textSize="12sp" | ||||
|             android:textColor="@color/md_white_1000" | ||||
|             tools:text="Sample name" /> | ||||
|  | ||||
|         <com.google.android.material.progressindicator.CircularProgressIndicator | ||||
|             android:id="@+id/progress" | ||||
|             style="@style/Widget.Tachiyomi.CircularProgressIndicator.Small" | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_gravity="center" | ||||
|             android:indeterminate="true" | ||||
|             android:visibility="gone" /> | ||||
|  | ||||
|     </FrameLayout> | ||||
|  | ||||
| </FrameLayout> | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|   | ||||
| @@ -1,68 +0,0 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="wrap_content" | ||||
|     android:layout_margin="2dp" | ||||
|     android:background="@drawable/library_item_selector" | ||||
|     android:foreground="@drawable/library_item_selector_overlay" | ||||
|     android:padding="4dp"> | ||||
|  | ||||
|     <androidx.constraintlayout.widget.ConstraintLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content"> | ||||
|  | ||||
|         <FrameLayout | ||||
|             android:id="@+id/card" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="220dp" | ||||
|             android:background="@drawable/rounded_rectangle" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintStart_toStartOf="parent" | ||||
|             app:layout_constraintTop_toTopOf="parent"> | ||||
|  | ||||
|             <ImageView | ||||
|                 android:id="@+id/thumbnail" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="match_parent" | ||||
|                 android:background="?attr/colorSurface" | ||||
|                 android:scaleType="centerCrop" | ||||
|                 tools:ignore="ContentDescription" | ||||
|                 tools:src="@mipmap/ic_launcher" /> | ||||
|  | ||||
|             <TextView | ||||
|                 android:id="@+id/title" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_gravity="bottom" | ||||
|                 android:ellipsize="end" | ||||
|                 android:maxLines="2" | ||||
|                 android:padding="8dp" | ||||
|                 android:shadowColor="@color/md_black_1000" | ||||
|                 android:shadowDx="0" | ||||
|                 android:shadowDy="0" | ||||
|                 android:shadowRadius="4" | ||||
|                 android:textAppearance="?attr/textAppearanceTitleSmall" | ||||
|                 android:textSize="12sp" | ||||
|                 android:textColor="@color/md_white_1000" | ||||
|                 tools:text="Sample name" /> | ||||
|  | ||||
|             <include | ||||
|                 android:id="@+id/badges" | ||||
|                 layout="@layout/source_grid_item_badges" /> | ||||
|  | ||||
|             <com.google.android.material.progressindicator.CircularProgressIndicator | ||||
|                 android:id="@+id/progress" | ||||
|                 style="@style/Widget.Tachiyomi.CircularProgressIndicator.Small" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_gravity="center" | ||||
|                 android:indeterminate="true" | ||||
|                 android:visibility="gone" /> | ||||
|  | ||||
|         </FrameLayout> | ||||
|  | ||||
|     </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|  | ||||
| </FrameLayout> | ||||
		Reference in New Issue
	
	Block a user