Remove RelativeLayout from covers for better performance

This commit is contained in:
len 2016-04-29 20:00:03 +02:00
parent f9783407bd
commit 47bc1f7a9f
5 changed files with 36 additions and 40 deletions

View File

@ -107,7 +107,6 @@ dependencies {
compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION" compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION" compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION" compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:percent:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:preference-v7:$SUPPORT_LIBRARY_VERSION" compile "com.android.support:preference-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:preference-v14:$SUPPORT_LIBRARY_VERSION" compile "com.android.support:preference-v14:$SUPPORT_LIBRARY_VERSION"

View File

@ -1,8 +1,9 @@
package eu.kanade.tachiyomi.ui.catalogue package eu.kanade.tachiyomi.ui.catalogue
import android.view.Gravity
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.widget.RelativeLayout import android.widget.FrameLayout
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
@ -71,12 +72,14 @@ class CatalogueAdapter(val fragment: CatalogueFragment) : FlexibleAdapter<Catalo
*/ */
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CatalogueHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CatalogueHolder {
if (parent.id == R.id.catalogue_grid) { if (parent.id == R.id.catalogue_grid) {
val v = parent.inflate(R.layout.item_catalogue_grid) val view = parent.inflate(R.layout.item_catalogue_grid).apply {
v.image_container.layoutParams = RelativeLayout.LayoutParams(MATCH_PARENT, coverHeight) card.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, coverHeight)
return CatalogueGridHolder(v, this, fragment) gradient.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, coverHeight / 2, Gravity.BOTTOM)
}
return CatalogueGridHolder(view, this, fragment)
} else { } else {
val v = parent.inflate(R.layout.item_catalogue_list) val view = parent.inflate(R.layout.item_catalogue_list)
return CatalogueListHolder(v, this, fragment) return CatalogueListHolder(view, this, fragment)
} }
} }

View File

@ -1,8 +1,9 @@
package eu.kanade.tachiyomi.ui.library package eu.kanade.tachiyomi.ui.library
import android.view.Gravity
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.widget.RelativeLayout import android.widget.FrameLayout
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
@ -83,8 +84,10 @@ class LibraryCategoryAdapter(val fragment: LibraryCategoryFragment) :
* @return a new view holder for a manga. * @return a new view holder for a manga.
*/ */
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LibraryHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LibraryHolder {
val view = parent.inflate(R.layout.item_catalogue_grid) val view = parent.inflate(R.layout.item_catalogue_grid).apply {
view.image_container.layoutParams = RelativeLayout.LayoutParams(MATCH_PARENT, coverHeight) card.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, coverHeight)
gradient.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, coverHeight / 2, Gravity.BOTTOM)
}
return LibraryHolder(view, this, fragment) return LibraryHolder(view, this, fragment)
} }

View File

@ -38,7 +38,7 @@ class LibraryHolder(private val view: View, private val adapter: LibraryCategory
view.title.text = manga.title view.title.text = manga.title
// Update the unread count and its visibility. // Update the unread count and its visibility.
with(view.unreadText) { with(view.unread_text) {
visibility = if (manga.unread > 0) View.VISIBLE else View.GONE visibility = if (manga.unread > 0) View.VISIBLE else View.GONE
text = manga.unread.toString() text = manga.unread.toString()
} }

View File

@ -7,40 +7,32 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectable_list_drawable"> android:background="?attr/selectable_list_drawable">
<RelativeLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="220dp"
android:id="@+id/card"
android:background="@drawable/card_background"> android:background="@drawable/card_background">
<android.support.percent.PercentFrameLayout <ImageView
android:id="@+id/image_container" android:id="@+id/thumbnail"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="220dp"> android:layout_height="match_parent"
android:background="?android:attr/colorBackground"
tools:background="?android:attr/colorBackground"
tools:src="@mipmap/ic_launcher" />
<ImageView <View
android:id="@+id/thumbnail" android:id="@+id/gradient"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="?android:attr/colorBackground" android:layout_gravity="bottom"
tools:background="?android:attr/colorBackground" android:background="@drawable/gradient_shape" />
tools:src="@mipmap/ic_launcher"/>
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/gradient_shape"
app:layout_heightPercent="50%"/>
</android.support.percent.PercentFrameLayout>
<TextView <TextView
android:id="@+id/unreadText" android:id="@+id/unread_text"
style="@style/TextAppearance.Regular.Caption.Light" style="@style/TextAppearance.Regular.Caption.Light"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="?attr/colorAccent" android:background="?attr/colorAccent"
android:paddingBottom="1dp" android:paddingBottom="1dp"
android:paddingLeft="3dp" android:paddingLeft="3dp"
@ -54,8 +46,7 @@
app:typeface="ptsansNarrowBold" app:typeface="ptsansNarrowBold"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignBottom="@+id/image_container" android:layout_gravity="bottom"
android:layout_gravity="center_vertical"
android:ellipsize="end" android:ellipsize="end"
android:lineSpacingExtra="-4dp" android:lineSpacingExtra="-4dp"
android:maxLines="2" android:maxLines="2"
@ -66,6 +57,6 @@
android:shadowRadius="4" android:shadowRadius="4"
tools:text="Sample name"/> tools:text="Sample name"/>
</RelativeLayout> </FrameLayout>
</FrameLayout> </FrameLayout>