mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-19 05:43:56 +00:00
random option
This commit is contained in:
@@ -300,6 +300,19 @@ class MediaAdaptor(
|
||||
return type
|
||||
}
|
||||
|
||||
fun randomOptionClick() { //used for user list
|
||||
val media = mediaList?.random()
|
||||
if (media != null) {
|
||||
mediaList?.let {
|
||||
clicked(
|
||||
it.indexOf(media),
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inner class MediaViewHolder(val binding: ItemMediaCompactBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
|
||||
@@ -162,5 +162,15 @@ class ListActivity : AppCompatActivity() {
|
||||
popup.inflate(R.menu.list_sort_menu)
|
||||
popup.show()
|
||||
}
|
||||
|
||||
binding.random.setOnClickListener {
|
||||
//get the current tab
|
||||
val currentTab =
|
||||
binding.listTabLayout.getTabAt(binding.listTabLayout.selectedTabPosition)
|
||||
val currentViewePager = binding.listViewPager.getChildAt(0)
|
||||
val currentFragment =
|
||||
supportFragmentManager.findFragmentByTag("f" + currentTab?.position.toString()) as? ListFragment
|
||||
currentFragment?.randomOptionClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,11 @@ class ListFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
fun randomOptionClick() {
|
||||
val adapter = binding.listRecyclerView.adapter as MediaAdaptor
|
||||
adapter.randomOptionClick()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(pos: Int, calendar: Boolean = false): ListFragment =
|
||||
ListFragment().apply {
|
||||
|
||||
Reference in New Issue
Block a user