random option
This commit is contained in:
parent
ea83b722a6
commit
e26a6c647f
6 changed files with 50 additions and 2 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue