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
|
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) :
|
inner class MediaViewHolder(val binding: ItemMediaCompactBinding) :
|
||||||
RecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
init {
|
init {
|
||||||
|
|
|
@ -162,5 +162,15 @@ class ListActivity : AppCompatActivity() {
|
||||||
popup.inflate(R.menu.list_sort_menu)
|
popup.inflate(R.menu.list_sort_menu)
|
||||||
popup.show()
|
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 {
|
companion object {
|
||||||
fun newInstance(pos: Int, calendar: Boolean = false): ListFragment =
|
fun newInstance(pos: Int, calendar: Boolean = false): ListFragment =
|
||||||
ListFragment().apply {
|
ListFragment().apply {
|
||||||
|
|
10
app/src/main/res/drawable/ic_shuffle_24.xml
Normal file
10
app/src/main/res/drawable/ic_shuffle_24.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M560,800v-80h104L537,593l57,-57 126,126v-102h80v240L560,800ZM216,800 L160,744 664,240L560,240v-80h240v240h-80v-104L216,800ZM367,423L160,216l56,-56 207,207 -56,56Z"/>
|
||||||
|
</vector>
|
|
@ -44,12 +44,21 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/random"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:contentDescription="@string/random_selection"
|
||||||
|
app:tint="?attr/colorOnBackground"
|
||||||
|
app:srcCompat="@drawable/ic_shuffle_24" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/listSort"
|
android:id="@+id/listSort"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:contentDescription="@string/sort_by"
|
android:contentDescription="@string/sort_by"
|
||||||
app:tint="?attr/colorOnBackground"
|
app:tint="?attr/colorOnBackground"
|
||||||
|
|
|
@ -640,5 +640,6 @@
|
||||||
<string name="available_anime">Available Anime</string>
|
<string name="available_anime">Available Anime</string>
|
||||||
<string name="installed_manga">Installed Manga</string>
|
<string name="installed_manga">Installed Manga</string>
|
||||||
<string name="color_picker">Color Picker</string>
|
<string name="color_picker">Color Picker</string>
|
||||||
|
<string name="random_selection">Random Selection</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue