fix: banner crash
This commit is contained in:
parent
31c509f88c
commit
71870ff235
10 changed files with 366 additions and 127 deletions
|
@ -1358,10 +1358,10 @@ fun blurImage(imageView: ImageView, banner: String?) {
|
|||
if (banner != null) {
|
||||
val radius = PrefManager.getVal<Float>(PrefName.BlurRadius).toInt()
|
||||
val sampling = PrefManager.getVal<Float>(PrefName.BlurSampling).toInt()
|
||||
if (PrefManager.getVal(PrefName.BlurBanners)) {
|
||||
val context = imageView.context
|
||||
if (!(context as Activity).isDestroyed) {
|
||||
val url = PrefManager.getVal<String>(PrefName.ImageUrl).ifEmpty { banner }
|
||||
val context = imageView.context
|
||||
if (!(context as Activity).isDestroyed) {
|
||||
val url = PrefManager.getVal<String>(PrefName.ImageUrl).ifEmpty { banner }
|
||||
if (PrefManager.getVal(PrefName.BlurBanners)) {
|
||||
Glide.with(context as Context)
|
||||
.load(
|
||||
if (banner.startsWith("http")) GlideUrl(url) else if (banner.startsWith("content://")) Uri.parse(
|
||||
|
@ -1371,9 +1371,17 @@ fun blurImage(imageView: ImageView, banner: String?) {
|
|||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE).override(400)
|
||||
.apply(RequestOptions.bitmapTransform(BlurTransformation(radius, sampling)))
|
||||
.into(imageView)
|
||||
|
||||
} else {
|
||||
Glide.with(context as Context)
|
||||
.load(
|
||||
if (banner.startsWith("http")) GlideUrl(url) else if (banner.startsWith("content://")) Uri.parse(
|
||||
url
|
||||
) else File(url)
|
||||
)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE).override(400)
|
||||
.into(imageView)
|
||||
}
|
||||
} else {
|
||||
imageView.loadImage(banner)
|
||||
}
|
||||
} else {
|
||||
imageView.setImageResource(R.drawable.linear_gradient_bg)
|
||||
|
|
|
@ -204,22 +204,22 @@ class AnimeFragment : Fragment() {
|
|||
if (i) {
|
||||
model.getUpdated().observe(viewLifecycleOwner) {
|
||||
if (it != null) {
|
||||
animePageAdapter.updateRecent(MediaAdaptor(0, it, requireActivity()))
|
||||
animePageAdapter.updateRecent(MediaAdaptor(0, it, requireActivity()), it)
|
||||
}
|
||||
}
|
||||
model.getMovies().observe(viewLifecycleOwner) {
|
||||
if (it != null) {
|
||||
animePageAdapter.updateMovies(MediaAdaptor(0, it, requireActivity()))
|
||||
animePageAdapter.updateMovies(MediaAdaptor(0, it, requireActivity()), it)
|
||||
}
|
||||
}
|
||||
model.getTopRated().observe(viewLifecycleOwner) {
|
||||
if (it != null) {
|
||||
animePageAdapter.updateTopRated(MediaAdaptor(0, it, requireActivity()))
|
||||
animePageAdapter.updateTopRated(MediaAdaptor(0, it, requireActivity()), it)
|
||||
}
|
||||
}
|
||||
model.getMostFav().observe(viewLifecycleOwner) {
|
||||
if (it != null) {
|
||||
animePageAdapter.updateMostFav(MediaAdaptor(0, it, requireActivity()))
|
||||
animePageAdapter.updateMostFav(MediaAdaptor(0, it, requireActivity()), it)
|
||||
}
|
||||
}
|
||||
if (animePageAdapter.trendingViewPager != null) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -23,11 +24,14 @@ import ani.dantotsu.connections.anilist.Anilist
|
|||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.databinding.ItemAnimePageBinding
|
||||
import ani.dantotsu.databinding.LayoutTrendingBinding
|
||||
import ani.dantotsu.getAppString
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.media.CalendarActivity
|
||||
import ani.dantotsu.media.GenreActivity
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaAdaptor
|
||||
import ani.dantotsu.media.MediaListViewActivity
|
||||
import ani.dantotsu.media.SearchActivity
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.px
|
||||
|
@ -193,13 +197,16 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
|
|||
LayoutAnimationController(setSlideIn(), 0.25f)
|
||||
}
|
||||
|
||||
fun updateRecent(adaptor: MediaAdaptor) {
|
||||
fun updateRecent(adaptor: MediaAdaptor, media: MutableList<Media>) {
|
||||
binding.apply {
|
||||
init(
|
||||
adaptor,
|
||||
animeUpdatedRecyclerView,
|
||||
animeUpdatedProgressBar,
|
||||
animeRecently
|
||||
animeRecently,
|
||||
animeRecentlyMore,
|
||||
getAppString(R.string.updated),
|
||||
media
|
||||
)
|
||||
animePopular.visibility = View.VISIBLE
|
||||
animePopular.startAnimation(setSlideUp())
|
||||
|
@ -210,40 +217,49 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
|
|||
|
||||
}
|
||||
|
||||
fun updateMovies(adaptor: MediaAdaptor) {
|
||||
fun updateMovies(adaptor: MediaAdaptor, media: MutableList<Media>) {
|
||||
binding.apply {
|
||||
init(
|
||||
adaptor,
|
||||
animeMoviesRecyclerView,
|
||||
animeMoviesProgressBar,
|
||||
animeMovies
|
||||
animeMovies,
|
||||
animeMoviesMore,
|
||||
getAppString(R.string.trending_movies),
|
||||
media
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateTopRated(adaptor: MediaAdaptor) {
|
||||
fun updateTopRated(adaptor: MediaAdaptor, media: MutableList<Media>) {
|
||||
binding.apply {
|
||||
init(
|
||||
adaptor,
|
||||
animeTopRatedRecyclerView,
|
||||
animeTopRatedProgressBar,
|
||||
animeTopRated
|
||||
animeTopRated,
|
||||
animeTopRatedMore,
|
||||
getAppString(R.string.top_rated),
|
||||
media
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateMostFav(adaptor: MediaAdaptor) {
|
||||
fun updateMostFav(adaptor: MediaAdaptor, media: MutableList<Media>) {
|
||||
binding.apply {
|
||||
init(
|
||||
adaptor,
|
||||
animeMostFavRecyclerView,
|
||||
animeMostFavProgressBar,
|
||||
animeMostFav
|
||||
animeMostFav,
|
||||
animeMostFavMore,
|
||||
getAppString(R.string.most_favourite),
|
||||
media
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun init(adaptor: MediaAdaptor, recyclerView: RecyclerView, progress: View, title: View) {
|
||||
fun init(adaptor: MediaAdaptor, recyclerView: RecyclerView, progress: View, title: View , more: View , string: String, media : MutableList<Media>) {
|
||||
progress.visibility = View.GONE
|
||||
recyclerView.adapter = adaptor
|
||||
recyclerView.layoutManager =
|
||||
|
@ -252,9 +268,19 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
|
|||
LinearLayoutManager.HORIZONTAL,
|
||||
false
|
||||
)
|
||||
more.setOnClickListener {
|
||||
ContextCompat.startActivity(
|
||||
it.context, Intent(it.context, MediaListViewActivity::class.java)
|
||||
.putExtra("title", string)
|
||||
.putExtra("media", media as ArrayList<Media>),
|
||||
null
|
||||
)
|
||||
}
|
||||
recyclerView.visibility = View.VISIBLE
|
||||
title.visibility = View.VISIBLE
|
||||
more.visibility = View.VISIBLE
|
||||
title.startAnimation(setSlideUp())
|
||||
more.startAnimation(setSlideUp())
|
||||
recyclerView.layoutAnimation =
|
||||
LayoutAnimationController(setSlideIn(), 0.25f)
|
||||
}
|
||||
|
|
|
@ -233,10 +233,10 @@ class HomeFragment : Fragment() {
|
|||
false
|
||||
)
|
||||
more.setOnClickListener { _ ->
|
||||
MediaListViewActivity.mediaList = it
|
||||
ContextCompat.startActivity(
|
||||
requireActivity(), Intent(requireActivity(), MediaListViewActivity::class.java)
|
||||
.putExtra("title", string),
|
||||
.putExtra("title", string)
|
||||
.putExtra("media", it),
|
||||
null
|
||||
)
|
||||
}
|
||||
|
@ -249,6 +249,7 @@ class HomeFragment : Fragment() {
|
|||
}
|
||||
more.visibility = View.VISIBLE
|
||||
title.visibility = View.VISIBLE
|
||||
more.startAnimation(setSlideUp())
|
||||
title.startAnimation(setSlideUp())
|
||||
progress.visibility = View.GONE
|
||||
}
|
||||
|
|
|
@ -162,12 +162,12 @@ class MangaFragment : Fragment() {
|
|||
if (i == true) {
|
||||
model.getPopularNovel().observe(viewLifecycleOwner) {
|
||||
if (it != null) {
|
||||
mangaPageAdapter.updateNovel(MediaAdaptor(0, it, requireActivity()))
|
||||
mangaPageAdapter.updateNovel(MediaAdaptor(0, it, requireActivity()), it)
|
||||
}
|
||||
}
|
||||
model.getPopularManga().observe(viewLifecycleOwner) {
|
||||
if (it != null) {
|
||||
mangaPageAdapter.updateTrendingManga(MediaAdaptor(0, it, requireActivity()))
|
||||
mangaPageAdapter.updateTrendingManga(MediaAdaptor(0, it, requireActivity()), it)
|
||||
}
|
||||
}
|
||||
model.getPopularManhwa().observe(viewLifecycleOwner) {
|
||||
|
@ -177,18 +177,18 @@ class MangaFragment : Fragment() {
|
|||
0,
|
||||
it,
|
||||
requireActivity()
|
||||
)
|
||||
), it
|
||||
)
|
||||
}
|
||||
}
|
||||
model.getTopRated().observe(viewLifecycleOwner) {
|
||||
if (it != null) {
|
||||
mangaPageAdapter.updateTopRated(MediaAdaptor(0, it, requireActivity()))
|
||||
mangaPageAdapter.updateTopRated(MediaAdaptor(0, it, requireActivity()), it)
|
||||
}
|
||||
}
|
||||
model.getMostFav().observe(viewLifecycleOwner) {
|
||||
if (it != null) {
|
||||
mangaPageAdapter.updateMostFav(MediaAdaptor(0, it, requireActivity()))
|
||||
mangaPageAdapter.updateMostFav(MediaAdaptor(0, it, requireActivity()), it)
|
||||
}
|
||||
}
|
||||
if (mangaPageAdapter.trendingViewPager != null) {
|
||||
|
|
|
@ -22,10 +22,13 @@ import ani.dantotsu.R
|
|||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.databinding.ItemMangaPageBinding
|
||||
import ani.dantotsu.databinding.LayoutTrendingBinding
|
||||
import ani.dantotsu.getAppString
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.media.GenreActivity
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaAdaptor
|
||||
import ani.dantotsu.media.MediaListViewActivity
|
||||
import ani.dantotsu.media.SearchActivity
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.px
|
||||
|
@ -178,65 +181,80 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
|
|||
|
||||
}
|
||||
|
||||
fun updateTrendingManga(adaptor: MediaAdaptor) {
|
||||
fun updateTrendingManga(adaptor: MediaAdaptor, media: MutableList<Media>) {
|
||||
binding.apply {
|
||||
init(
|
||||
adaptor,
|
||||
mangaTrendingMangaRecyclerView,
|
||||
mangaTrendingMangaProgressBar,
|
||||
mangaTrendingManga
|
||||
mangaTrendingManga,
|
||||
mangaTrendingMangaMore,
|
||||
getAppString(R.string.trending_manga),
|
||||
media
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateTrendingManhwa(adaptor: MediaAdaptor) {
|
||||
fun updateTrendingManhwa(adaptor: MediaAdaptor, media: MutableList<Media>) {
|
||||
binding.apply {
|
||||
init(
|
||||
adaptor,
|
||||
mangaTrendingManhwaRecyclerView,
|
||||
mangaTrendingManhwaProgressBar,
|
||||
mangaTrendingManhwa
|
||||
mangaTrendingManhwa,
|
||||
mangaTrendingManhwaMore,
|
||||
getAppString(R.string.trending_manhwa),
|
||||
media
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateNovel(adaptor: MediaAdaptor) {
|
||||
fun updateNovel(adaptor: MediaAdaptor, media: MutableList<Media>) {
|
||||
binding.apply {
|
||||
init(
|
||||
adaptor,
|
||||
mangaNovelRecyclerView,
|
||||
mangaNovelProgressBar,
|
||||
mangaNovel
|
||||
mangaNovel,
|
||||
mangaNovelMore,
|
||||
getAppString(R.string.trending_novel),
|
||||
media
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun updateTopRated(adaptor: MediaAdaptor) {
|
||||
fun updateTopRated(adaptor: MediaAdaptor, media: MutableList<Media>) {
|
||||
binding.apply {
|
||||
init(
|
||||
adaptor,
|
||||
mangaTopRatedRecyclerView,
|
||||
mangaTopRatedProgressBar,
|
||||
mangaTopRated
|
||||
mangaTopRated,
|
||||
mangaTopRatedMore,
|
||||
getAppString(R.string.top_rated),
|
||||
media
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateMostFav(adaptor: MediaAdaptor) {
|
||||
fun updateMostFav(adaptor: MediaAdaptor, media: MutableList<Media>) {
|
||||
binding.apply {
|
||||
init(
|
||||
adaptor,
|
||||
mangaMostFavRecyclerView,
|
||||
mangaMostFavProgressBar,
|
||||
mangaMostFav
|
||||
mangaMostFav,
|
||||
mangaMostFavMore,
|
||||
getAppString(R.string.most_favourite),
|
||||
media
|
||||
)
|
||||
mangaPopular.visibility = View.VISIBLE
|
||||
mangaPopular.startAnimation(setSlideUp())
|
||||
}
|
||||
}
|
||||
|
||||
fun init(adaptor: MediaAdaptor, recyclerView: RecyclerView, progress: View, title: View) {
|
||||
fun init(adaptor: MediaAdaptor, recyclerView: RecyclerView, progress: View, title: View , more: View , string: String, media : MutableList<Media>) {
|
||||
progress.visibility = View.GONE
|
||||
recyclerView.adapter = adaptor
|
||||
recyclerView.layoutManager =
|
||||
|
@ -245,9 +263,19 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
|
|||
LinearLayoutManager.HORIZONTAL,
|
||||
false
|
||||
)
|
||||
more.setOnClickListener {
|
||||
ContextCompat.startActivity(
|
||||
it.context, Intent(it.context, MediaListViewActivity::class.java)
|
||||
.putExtra("title", string)
|
||||
.putExtra("media", media as ArrayList<Media>),
|
||||
null
|
||||
)
|
||||
}
|
||||
recyclerView.visibility = View.VISIBLE
|
||||
title.visibility = View.VISIBLE
|
||||
more.visibility = View.VISIBLE
|
||||
title.startAnimation(setSlideUp())
|
||||
more.startAnimation(setSlideUp())
|
||||
recyclerView.layoutAnimation =
|
||||
LayoutAnimationController(setSlideIn(), 0.25f)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ani.dantotsu.media
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
@ -13,7 +12,7 @@ import ani.dantotsu.databinding.ActivityMediaListViewBinding
|
|||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.hideSystemBarsExtendView
|
||||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.statusBarHeight
|
||||
|
@ -50,15 +49,14 @@ class MediaListViewActivity: AppCompatActivity() {
|
|||
topMargin = statusBarHeight
|
||||
}
|
||||
}
|
||||
val screenWidth = resources.displayMetrics.run { widthPixels / density }
|
||||
val mediaList = intent.getSerialized("media") as? ArrayList<Media> ?: ArrayList()
|
||||
binding.listTitle.text = intent.getStringExtra("title")
|
||||
|
||||
binding.mediaRecyclerView.adapter = MediaAdaptor(0, mediaList, this)
|
||||
val screenWidth = resources.displayMetrics.run { widthPixels / density }
|
||||
binding.mediaRecyclerView.layoutManager = GridLayoutManager(
|
||||
this,
|
||||
(screenWidth / 120f).toInt()
|
||||
)
|
||||
}
|
||||
companion object{
|
||||
var mediaList: ArrayList<Media> = arrayListOf()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue