mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
cleanup
This commit is contained in:
parent
c4580d2d21
commit
3647f1ed1c
@ -3,6 +3,7 @@ package com.github.libretube.dialogs
|
|||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
@ -51,11 +52,13 @@ class VideoOptionsDialog(
|
|||||||
try {
|
try {
|
||||||
val notificationManager =
|
val notificationManager =
|
||||||
context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
notificationManager.activeNotifications.forEach {
|
notificationManager.activeNotifications.forEach {
|
||||||
if (it.id == PLAYER_NOTIFICATION_ID) {
|
if (it.id == PLAYER_NOTIFICATION_ID) {
|
||||||
optionsList += context?.getString(R.string.add_to_queue)
|
optionsList += context?.getString(R.string.add_to_queue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
@ -108,13 +108,9 @@ class SubscriptionsFragment : BaseFragment() {
|
|||||||
private fun showSortDialog() {
|
private fun showSortDialog() {
|
||||||
val sortOptions = resources.getStringArray(R.array.sortOptions)
|
val sortOptions = resources.getStringArray(R.array.sortOptions)
|
||||||
val sortOptionValues = resources.getStringArray(R.array.sortOptionsValues)
|
val sortOptionValues = resources.getStringArray(R.array.sortOptionsValues)
|
||||||
val items = mutableListOf<BottomSheetItem>()
|
|
||||||
sortOptions.forEach {
|
|
||||||
items += BottomSheetItem(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
val bottomSheet = BottomSheet().apply {
|
val bottomSheet = BottomSheet().apply {
|
||||||
setItems(items) { index ->
|
setSimpleItems(sortOptions.toList()) { index ->
|
||||||
binding.sortTV.text = sortOptions[index]
|
binding.sortTV.text = sortOptions[index]
|
||||||
sortOrder = sortOptionValues[index]
|
sortOrder = sortOptionValues[index]
|
||||||
showFeed()
|
showFeed()
|
||||||
|
@ -48,4 +48,12 @@ class BottomSheet : BottomSheetDialogFragment() {
|
|||||||
dialog?.dismiss()
|
dialog?.dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setSimpleItems(titles: List<String>, listener: (index: Int) -> Unit) {
|
||||||
|
this.items = titles.map { BottomSheetItem(it) }
|
||||||
|
this.listener = { index ->
|
||||||
|
listener.invoke(index)
|
||||||
|
dialog?.dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user