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.NotificationManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.Toast
|
||||
@ -51,9 +52,11 @@ class VideoOptionsDialog(
|
||||
try {
|
||||
val notificationManager =
|
||||
context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.activeNotifications.forEach {
|
||||
if (it.id == PLAYER_NOTIFICATION_ID) {
|
||||
optionsList += context?.getString(R.string.add_to_queue)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
notificationManager.activeNotifications.forEach {
|
||||
if (it.id == PLAYER_NOTIFICATION_ID) {
|
||||
optionsList += context?.getString(R.string.add_to_queue)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
@ -108,13 +108,9 @@ class SubscriptionsFragment : BaseFragment() {
|
||||
private fun showSortDialog() {
|
||||
val sortOptions = resources.getStringArray(R.array.sortOptions)
|
||||
val sortOptionValues = resources.getStringArray(R.array.sortOptionsValues)
|
||||
val items = mutableListOf<BottomSheetItem>()
|
||||
sortOptions.forEach {
|
||||
items += BottomSheetItem(it)
|
||||
}
|
||||
|
||||
val bottomSheet = BottomSheet().apply {
|
||||
setItems(items) { index ->
|
||||
setSimpleItems(sortOptions.toList()) { index ->
|
||||
binding.sortTV.text = sortOptions[index]
|
||||
sortOrder = sortOptionValues[index]
|
||||
showFeed()
|
||||
|
@ -48,4 +48,12 @@ class BottomSheet : BottomSheetDialogFragment() {
|
||||
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