mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-29 14:33:01 +00:00
MusicPreferencesDialog migrate to view binding
This commit is contained in:
parent
7e05a3846f
commit
83ac980ecc
2 changed files with 65 additions and 69 deletions
|
@ -2,47 +2,49 @@ package com.vanced.manager.ui.dialogs
|
|||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.DialogMusicPreferencesBinding
|
||||
import com.vanced.manager.ui.core.BindingBottomSheetDialogFragment
|
||||
import com.vanced.manager.utils.Extensions.convertToAppVersions
|
||||
import com.vanced.manager.utils.Extensions.getDefaultPrefs
|
||||
import com.vanced.manager.utils.Extensions.show
|
||||
import com.vanced.manager.utils.InternetTools.musicVersions
|
||||
|
||||
class MusicPreferencesDialog : BottomSheetDialogFragment() {
|
||||
class MusicPreferencesDialog : BindingBottomSheetDialogFragment<DialogMusicPreferencesBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
fun newInstance(): MusicPreferencesDialog = MusicPreferencesDialog().apply {
|
||||
arguments = Bundle()
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var binding: DialogMusicPreferencesBinding
|
||||
private val prefs by lazy { requireActivity().getDefaultPrefs() }
|
||||
|
||||
override fun onCreateView(
|
||||
override fun binding(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.dialog_music_preferences, container, false)
|
||||
return binding.root
|
||||
) = DialogMusicPreferencesBinding.inflate(inflater, container, false)
|
||||
|
||||
override fun otherSetups() {
|
||||
bindData()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
private fun bindData() {
|
||||
with(binding) {
|
||||
val musicVersionsConv = musicVersions.get()?.value?.reversed()?.convertToAppVersions()
|
||||
|
||||
binding.musicInstallTitle.text = requireActivity().getString(R.string.app_installation_preferences, requireActivity().getString(R.string.music))
|
||||
binding.musicVersion.text = requireActivity().getString(R.string.chosen_version, prefs.getString("music_version", "latest"))
|
||||
|
||||
binding.openVersionSelector.setOnClickListener {
|
||||
musicInstallTitle.text = getString(R.string.app_installation_preferences, getString(R.string.music))
|
||||
musicVersion.text = getString(R.string.chosen_version, prefs.getString("music_version", "latest"))
|
||||
openVersionSelector.setOnClickListener {
|
||||
dismiss()
|
||||
AppVersionSelectorDialog.newInstance(
|
||||
versions = musicVersionsConv,
|
||||
app = "music"
|
||||
).show(requireActivity())
|
||||
}
|
||||
binding.musicInstall.setOnClickListener {
|
||||
musicInstall.setOnClickListener {
|
||||
dismiss()
|
||||
AppDownloadDialog.newInstance(
|
||||
app = getString(R.string.music)
|
||||
|
@ -50,3 +52,4 @@ class MusicPreferencesDialog : BottomSheetDialogFragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/BottomDialogCard">
|
||||
|
@ -21,10 +19,10 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/music_version"
|
||||
style="@style/BottomDialogCardTextItem"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toStartOf="@id/open_version_selector" />
|
||||
android:layout_toStartOf="@id/open_version_selector"
|
||||
style="@style/BottomDialogCardTextItem"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/open_version_selector"
|
||||
|
@ -35,16 +33,11 @@
|
|||
android:maxWidth="24dp"
|
||||
android:maxHeight="24dp"
|
||||
android:src="@drawable/ic_baseline_navigate_next_36"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/music_install"
|
||||
style="@style/BottomDialogButtonStyle"
|
||||
android:text="@string/install" />
|
||||
|
||||
android:text="@string/install"
|
||||
style="@style/BottomDialogButtonStyle"/>
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</layout>
|
||||
|
|
Loading…
Reference in a new issue