mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Convert the rest of SingleSelectionHelper to ViewBinding (#724)
This commit is contained in:
parent
ef36bccc90
commit
4b93524e57
1 changed files with 28 additions and 23 deletions
|
@ -7,10 +7,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.AbsListView
|
import android.widget.AbsListView
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.EditText
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.ListView
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
|
@ -20,8 +17,10 @@ import androidx.core.view.marginRight
|
||||||
import androidx.core.view.marginTop
|
import androidx.core.view.marginTop
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.databinding.BottomTextDialogBinding
|
import com.lagradost.cloudstream3.databinding.BottomInputDialogBinding
|
||||||
import com.lagradost.cloudstream3.databinding.BottomSelectionDialogBinding
|
import com.lagradost.cloudstream3.databinding.BottomSelectionDialogBinding
|
||||||
|
import com.lagradost.cloudstream3.databinding.BottomTextDialogBinding
|
||||||
|
import com.lagradost.cloudstream3.databinding.OptionsPopupTvBinding
|
||||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIconsAndNoStringRes
|
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIconsAndNoStringRes
|
||||||
|
@ -56,14 +55,14 @@ object SingleSelectionHelper {
|
||||||
if (this == null) return
|
if (this == null) return
|
||||||
|
|
||||||
if (isTvSettings()) {
|
if (isTvSettings()) {
|
||||||
val builder =
|
val binding = OptionsPopupTvBinding.inflate(layoutInflater)
|
||||||
AlertDialog.Builder(this, R.style.AlertDialogCustom)
|
val dialog = AlertDialog.Builder(this, R.style.AlertDialogCustom)
|
||||||
.setView(R.layout.options_popup_tv)
|
.setView(binding.root)
|
||||||
|
.create()
|
||||||
|
|
||||||
val dialog = builder.create()
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
dialog.findViewById<ListView>(R.id.listview1)?.let { listView ->
|
binding.listview1.let { listView ->
|
||||||
listView.choiceMode = AbsListView.CHOICE_MODE_SINGLE
|
listView.choiceMode = AbsListView.CHOICE_MODE_SINGLE
|
||||||
listView.adapter =
|
listView.adapter =
|
||||||
ArrayAdapter<String>(this, R.layout.sort_bottom_single_choice_color).apply {
|
ArrayAdapter<String>(this, R.layout.sort_bottom_single_choice_color).apply {
|
||||||
|
@ -76,7 +75,7 @@ object SingleSelectionHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.findViewById<ImageView>(R.id.imageView)?.apply {
|
binding.imageView.apply {
|
||||||
isGone = poster.isNullOrEmpty()
|
isGone = poster.isNullOrEmpty()
|
||||||
setImage(poster)
|
setImage(poster)
|
||||||
}
|
}
|
||||||
|
@ -107,12 +106,12 @@ object SingleSelectionHelper {
|
||||||
if (this == null) return
|
if (this == null) return
|
||||||
|
|
||||||
val realShowApply = showApply || isMultiSelect
|
val realShowApply = showApply || isMultiSelect
|
||||||
val listView = binding.listview1//.findViewById<ListView>(R.id.listview1)!!
|
val listView = binding.listview1
|
||||||
val textView = binding.text1//.findViewById<TextView>(R.id.text1)!!
|
val textView = binding.text1
|
||||||
val applyButton = binding.applyBtt//.findViewById<TextView>(R.id.apply_btt)
|
val applyButton = binding.applyBtt
|
||||||
val cancelButton = binding.cancelBtt//findViewById<TextView>(R.id.cancel_btt)
|
val cancelButton = binding.cancelBtt
|
||||||
val applyHolder =
|
val applyHolder =
|
||||||
binding.applyBttHolder//.findViewById<LinearLayout>(R.id.apply_btt_holder)
|
binding.applyBttHolder
|
||||||
|
|
||||||
applyHolder.isVisible = realShowApply
|
applyHolder.isVisible = realShowApply
|
||||||
if (!realShowApply) {
|
if (!realShowApply) {
|
||||||
|
@ -175,8 +174,8 @@ object SingleSelectionHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun Activity?.showInputDialog(
|
private fun Activity?.showInputDialog(
|
||||||
|
binding: BottomInputDialogBinding,
|
||||||
dialog: Dialog,
|
dialog: Dialog,
|
||||||
value: String,
|
value: String,
|
||||||
name: String,
|
name: String,
|
||||||
|
@ -186,11 +185,11 @@ object SingleSelectionHelper {
|
||||||
) {
|
) {
|
||||||
if (this == null) return
|
if (this == null) return
|
||||||
|
|
||||||
val inputView = dialog.findViewById<EditText>(R.id.nginx_text_input)!!
|
val inputView = binding.nginxTextInput
|
||||||
val textView = dialog.findViewById<TextView>(R.id.text1)!!
|
val textView = binding.text1
|
||||||
val applyButton = dialog.findViewById<TextView>(R.id.apply_btt)!!
|
val applyButton = binding.applyBtt
|
||||||
val cancelButton = dialog.findViewById<TextView>(R.id.cancel_btt)!!
|
val cancelButton = binding.cancelBtt
|
||||||
val applyHolder = dialog.findViewById<LinearLayout>(R.id.apply_btt_holder)!!
|
val applyHolder = binding.applyBttHolder
|
||||||
|
|
||||||
applyHolder.isVisible = true
|
applyHolder.isVisible = true
|
||||||
textView.text = name
|
textView.text = name
|
||||||
|
@ -352,11 +351,17 @@ object SingleSelectionHelper {
|
||||||
dismissCallback: () -> Unit,
|
dismissCallback: () -> Unit,
|
||||||
callback: (String) -> Unit,
|
callback: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
val builder = BottomSheetDialog(this) // probably the stuff at the bottom
|
val builder = BottomSheetDialog(this)
|
||||||
builder.setContentView(R.layout.bottom_input_dialog) // input layout
|
|
||||||
|
val binding: BottomInputDialogBinding = BottomInputDialogBinding.inflate(
|
||||||
|
LayoutInflater.from(this)
|
||||||
|
)
|
||||||
|
|
||||||
|
builder.setContentView(binding.root)
|
||||||
|
|
||||||
builder.show()
|
builder.show()
|
||||||
showInputDialog(
|
showInputDialog(
|
||||||
|
binding,
|
||||||
builder,
|
builder,
|
||||||
value,
|
value,
|
||||||
name,
|
name,
|
||||||
|
|
Loading…
Reference in a new issue