From 08bf1a2336c691dfeda33dd2372b1ba4b9fe29fa Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Fri, 22 Mar 2024 16:45:47 -0400 Subject: [PATCH] chore: eliminate overlap layouts --- .../ani/dantotsu/home/AnimePageAdapter.kt | 61 +++++----- .../ani/dantotsu/home/MangaPageAdapter.kt | 55 ++++----- app/src/main/res/layout/item_anime_page.xml | 100 +---------------- app/src/main/res/layout/item_manga_page.xml | 103 +---------------- app/src/main/res/layout/layout_trending.xml | 105 ++++++++++++++++++ 5 files changed, 168 insertions(+), 256 deletions(-) create mode 100644 app/src/main/res/layout/layout_trending.xml diff --git a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt index 59d401c8..43c7db04 100644 --- a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt @@ -22,6 +22,7 @@ import ani.dantotsu.R import ani.dantotsu.connections.anilist.Anilist import ani.dantotsu.currContext import ani.dantotsu.databinding.ItemAnimePageBinding +import ani.dantotsu.databinding.LayoutTrendingBinding import ani.dantotsu.loadImage import ani.dantotsu.media.CalendarActivity import ani.dantotsu.media.GenreActivity @@ -42,6 +43,7 @@ import com.google.android.material.textfield.TextInputLayout class AnimePageAdapter : RecyclerView.Adapter() { val ready = MutableLiveData(false) lateinit var binding: ItemAnimePageBinding + private lateinit var trendingBinding: LayoutTrendingBinding private var trendHandler: Handler? = null private lateinit var trendRun: Runnable var trendingViewPager: ViewPager2? = null @@ -54,14 +56,15 @@ class AnimePageAdapter : RecyclerView.Adapter(R.id.animeSearchBar) + val textInputLayout = holder.itemView.findViewById(R.id.searchBar) val currentColor = textInputLayout.boxBackgroundColor val semiTransparentColor = (currentColor and 0x00FFFFFF) or 0xA8000000.toInt() textInputLayout.boxBackgroundColor = semiTransparentColor val materialCardView = - holder.itemView.findViewById(R.id.animeUserAvatarContainer) + holder.itemView.findViewById(R.id.userAvatarContainer) materialCardView.setCardBackgroundColor(semiTransparentColor) val typedValue = TypedValue() currContext()?.theme?.resolveAttribute(android.R.attr.windowBackground, typedValue, true) @@ -70,33 +73,29 @@ class AnimePageAdapter : RecyclerView.Adapter { + if (PrefManager.getVal(PrefName.SmallView)) trendingBinding.trendingContainer.updateLayoutParams { bottomMargin = (-108f).px } updateAvatar() - binding.animeSearchBar.hint = "ANIME" - binding.animeSearchBarText.setOnClickListener { + trendingBinding.searchBar.hint = "ANIME" + trendingBinding.searchBarText.setOnClickListener { ContextCompat.startActivity( it.context, - Intent(it.context, SearchActivity::class.java).putExtra("type", "ANIME"), + Intent(it.context, SearchActivity::class.java).putExtra("type", "MANGA"), null ) } - binding.animeSearchBar.setEndIconOnClickListener { - binding.animeSearchBarText.performClick() - } - - binding.animeUserAvatar.setSafeOnClickListener { + trendingBinding.userAvatar.setSafeOnClickListener { val dialogFragment = SettingsDialogFragment.newInstance(SettingsDialogFragment.Companion.PageType.ANIME) dialogFragment.show((it.context as AppCompatActivity).supportFragmentManager, "dialog") } - binding.animeUserAvatar.setOnLongClickListener { view -> + trendingBinding.userAvatar.setOnLongClickListener { view -> ContextCompat.startActivity( view.context, Intent(view.context, ProfileActivity::class.java) @@ -105,8 +104,12 @@ class AnimePageAdapter : RecyclerView.Adapter 0) View.VISIBLE else View.GONE - binding.animeNotificationCount.text = Anilist.unreadNotificationCount.toString() + trendingBinding.searchBar.setEndIconOnClickListener { + trendingBinding.searchBar.performClick() + } + + trendingBinding.notificationCount.visibility = if (Anilist.unreadNotificationCount > 0) View.VISIBLE else View.GONE + trendingBinding.notificationCount.text = Anilist.unreadNotificationCount.toString() listOf( binding.animePreviousSeason, @@ -159,17 +162,17 @@ class AnimePageAdapter : RecyclerView.Adapter 0) View.VISIBLE else View.GONE - binding.animeNotificationCount.text = Anilist.unreadNotificationCount.toString() + trendingBinding.notificationCount.text = Anilist.unreadNotificationCount.toString() } } diff --git a/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt b/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt index 1321d8bb..7ca0687f 100644 --- a/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt @@ -22,6 +22,7 @@ import ani.dantotsu.R import ani.dantotsu.connections.anilist.Anilist import ani.dantotsu.currContext import ani.dantotsu.databinding.ItemMangaPageBinding +import ani.dantotsu.databinding.LayoutTrendingBinding import ani.dantotsu.loadImage import ani.dantotsu.media.GenreActivity import ani.dantotsu.media.MediaAdaptor @@ -41,6 +42,7 @@ import com.google.android.material.textfield.TextInputLayout class MangaPageAdapter : RecyclerView.Adapter() { val ready = MutableLiveData(false) lateinit var binding: ItemMangaPageBinding + private lateinit var trendingBinding: LayoutTrendingBinding private var trendHandler: Handler? = null private lateinit var trendRun: Runnable var trendingViewPager: ViewPager2? = null @@ -53,14 +55,15 @@ class MangaPageAdapter : RecyclerView.Adapter(R.id.mangaSearchBar) + val textInputLayout = holder.itemView.findViewById(R.id.searchBar) val currentColor = textInputLayout.boxBackgroundColor val semiTransparentColor = (currentColor and 0x00FFFFFF) or 0xA8000000.toInt() textInputLayout.boxBackgroundColor = semiTransparentColor val materialCardView = - holder.itemView.findViewById(R.id.mangaUserAvatarContainer) + holder.itemView.findViewById(R.id.userAvatarContainer) materialCardView.setCardBackgroundColor(semiTransparentColor) val typedValue = TypedValue() currContext()?.theme?.resolveAttribute(android.R.attr.windowBackground, typedValue, true) @@ -69,17 +72,17 @@ class MangaPageAdapter : RecyclerView.Adapter { + if (PrefManager.getVal(PrefName.SmallView)) trendingBinding.trendingContainer.updateLayoutParams { bottomMargin = (-108f).px } updateAvatar() - binding.mangaNotificationCount.isVisible = Anilist.unreadNotificationCount > 0 - binding.mangaNotificationCount.text = Anilist.unreadNotificationCount.toString() - binding.mangaSearchBar.hint = "MANGA" - binding.mangaSearchBarText.setOnClickListener { + trendingBinding.notificationCount.isVisible = Anilist.unreadNotificationCount > 0 + trendingBinding.notificationCount.text = Anilist.unreadNotificationCount.toString() + trendingBinding.searchBar.hint = "MANGA" + trendingBinding.searchBarText.setOnClickListener { ContextCompat.startActivity( it.context, Intent(it.context, SearchActivity::class.java).putExtra("type", "MANGA"), @@ -87,12 +90,12 @@ class MangaPageAdapter : RecyclerView.Adapter + trendingBinding.userAvatar.setOnLongClickListener { view -> ContextCompat.startActivity( view.context, Intent(view.context, ProfileActivity::class.java) @@ -101,8 +104,8 @@ class MangaPageAdapter : RecyclerView.Adapter 0) View.VISIBLE else View.GONE - binding.mangaNotificationCount.text = Anilist.unreadNotificationCount.toString() + trendingBinding.notificationCount.text = Anilist.unreadNotificationCount.toString() } } diff --git a/app/src/main/res/layout/item_anime_page.xml b/app/src/main/res/layout/item_anime_page.xml index e4d77693..2cc202a0 100644 --- a/app/src/main/res/layout/item_anime_page.xml +++ b/app/src/main/res/layout/item_anime_page.xml @@ -9,105 +9,7 @@ android:layout_marginEnd="-16dp" android:orientation="vertical"> - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file