Skip to content

Commit

Permalink
fix: list view crash
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelonion committed May 21, 2024
1 parent b3ed8ac commit 66805bd
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 30 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
LinearLayoutManager.HORIZONTAL,
false
)
MediaListViewActivity.passedMedia = media.toCollection(ArrayList())
more.setOnClickListener {
ContextCompat.startActivity(
it.context, Intent(it.context, MediaListViewActivity::class.java)
.putExtra("title", string)
.putExtra("media", media as ArrayList<Media>),
.putExtra("title", string),
null
)
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/ani/dantotsu/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ class HomeFragment : Fragment() {
false
)
more.setOnClickListener { i ->
MediaListViewActivity.passedMedia = it
ContextCompat.startActivity(
i.context, Intent(i.context, MediaListViewActivity::class.java)
.putExtra("title", string)
.putExtra("media", it),
.putExtra("title", string),
null
)
}
Expand Down Expand Up @@ -393,11 +393,11 @@ class HomeFragment : Fragment() {
true
}
binding.homeHiddenItemsMore.setSafeOnClickListener { _ ->
MediaListViewActivity.passedMedia = it
ContextCompat.startActivity(
requireActivity(),
Intent(requireActivity(), MediaListViewActivity::class.java)
.putExtra("title", getString(R.string.hidden))
.putExtra("media", it),
.putExtra("title", getString(R.string.hidden)),
null
)
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
false
)
more.setOnClickListener {
MediaListViewActivity.passedMedia = media.toCollection(ArrayList())
ContextCompat.startActivity(
it.context, Intent(it.context, MediaListViewActivity::class.java)
.putExtra("title", string)
.putExtra("media", media as ArrayList<Media>),
.putExtra("title", string),
null
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class MediaListViewActivity: AppCompatActivity() {
binding.listAppBar.setBackgroundColor(primaryColor)
binding.listTitle.setTextColor(primaryTextColor)
val screenWidth = resources.displayMetrics.run { widthPixels / density }
val mediaList = intent.getSerialized("media") as? ArrayList<Media> ?: ArrayList()
val mediaList = passedMedia ?: intent.getSerialized("media") as? ArrayList<Media> ?: ArrayList()
if (passedMedia != null) passedMedia = null
val view = PrefManager.getCustomVal("mediaView", 0)
var mediaView: View = when (view) {
1 -> binding.mediaList
Expand Down Expand Up @@ -85,4 +86,8 @@ class MediaListViewActivity: AppCompatActivity() {
if (view == 1) 1 else (screenWidth / 120f).toInt()
)
}

companion object {
var passedMedia: ArrayList<Media>? = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ExtensionTestSettingsBottomDialog : BottomSheetDialogFragment() {
}

var extensionType = "anime"
var testType = "ping"
var testType = "basic"
var searchQuery = "Chainsaw Man"
var extensionsToTest: MutableList<String> = mutableListOf()
}
Expand Down
36 changes: 16 additions & 20 deletions app/src/main/res/layout/activity_media_list_view.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto">

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/listAppBar"
android:layout_width="match_parent"
Expand Down Expand Up @@ -60,20 +57,19 @@
tools:ignore="ContentDescription,ImageContrastCheck" />
</LinearLayout>


<ani.dantotsu.FadingEdgeRecyclerView
android:id="@+id/mediaRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:requiresFadingEdge="horizontal"
tools:itemCount="4"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_media_compact"
tools:orientation="horizontal" />

</com.google.android.material.appbar.AppBarLayout>
</androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
<ani.dantotsu.FadingEdgeRecyclerView
android:id="@+id/mediaRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:requiresFadingEdge="horizontal"
android:nestedScrollingEnabled="false"
tools:itemCount="4"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_media_compact"
tools:orientation="horizontal" />

</LinearLayout>

0 comments on commit 66805bd

Please sign in to comment.