mirror of
https://github.com/YTVanced/VancedManager
synced 2024-12-01 15:27:26 +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.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.databinding.DataBindingUtil
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import com.vanced.manager.databinding.DialogMusicPreferencesBinding
|
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.convertToAppVersions
|
||||||
import com.vanced.manager.utils.Extensions.getDefaultPrefs
|
import com.vanced.manager.utils.Extensions.getDefaultPrefs
|
||||||
import com.vanced.manager.utils.Extensions.show
|
import com.vanced.manager.utils.Extensions.show
|
||||||
import com.vanced.manager.utils.InternetTools.musicVersions
|
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() }
|
private val prefs by lazy { requireActivity().getDefaultPrefs() }
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun binding(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
) = DialogMusicPreferencesBinding.inflate(inflater, container, false)
|
||||||
binding = DataBindingUtil.inflate(inflater, R.layout.dialog_music_preferences, container, false)
|
|
||||||
return binding.root
|
override fun otherSetups() {
|
||||||
|
bindData()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
private fun bindData() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
with(binding) {
|
||||||
|
|
||||||
val musicVersionsConv = musicVersions.get()?.value?.reversed()?.convertToAppVersions()
|
val musicVersionsConv = musicVersions.get()?.value?.reversed()?.convertToAppVersions()
|
||||||
|
musicInstallTitle.text = getString(R.string.app_installation_preferences, getString(R.string.music))
|
||||||
binding.musicInstallTitle.text = requireActivity().getString(R.string.app_installation_preferences, requireActivity().getString(R.string.music))
|
musicVersion.text = getString(R.string.chosen_version, prefs.getString("music_version", "latest"))
|
||||||
binding.musicVersion.text = requireActivity().getString(R.string.chosen_version, prefs.getString("music_version", "latest"))
|
openVersionSelector.setOnClickListener {
|
||||||
|
|
||||||
binding.openVersionSelector.setOnClickListener {
|
|
||||||
dismiss()
|
dismiss()
|
||||||
AppVersionSelectorDialog.newInstance(
|
AppVersionSelectorDialog.newInstance(
|
||||||
versions = musicVersionsConv,
|
versions = musicVersionsConv,
|
||||||
app = "music"
|
app = "music"
|
||||||
).show(requireActivity())
|
).show(requireActivity())
|
||||||
}
|
}
|
||||||
binding.musicInstall.setOnClickListener {
|
musicInstall.setOnClickListener {
|
||||||
dismiss()
|
dismiss()
|
||||||
AppDownloadDialog.newInstance(
|
AppDownloadDialog.newInstance(
|
||||||
app = getString(R.string.music)
|
app = getString(R.string.music)
|
||||||
|
@ -50,3 +52,4 @@ class MusicPreferencesDialog : BottomSheetDialogFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,6 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout>
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
style="@style/BottomDialogCard">
|
style="@style/BottomDialogCard">
|
||||||
|
@ -21,10 +19,10 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/music_version"
|
android:id="@+id/music_version"
|
||||||
style="@style/BottomDialogCardTextItem"
|
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_toStartOf="@id/open_version_selector" />
|
android:layout_toStartOf="@id/open_version_selector"
|
||||||
|
style="@style/BottomDialogCardTextItem"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/open_version_selector"
|
android:id="@+id/open_version_selector"
|
||||||
|
@ -35,16 +33,11 @@
|
||||||
android:maxWidth="24dp"
|
android:maxWidth="24dp"
|
||||||
android:maxHeight="24dp"
|
android:maxHeight="24dp"
|
||||||
android:src="@drawable/ic_baseline_navigate_next_36"/>
|
android:src="@drawable/ic_baseline_navigate_next_36"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/music_install"
|
android:id="@+id/music_install"
|
||||||
style="@style/BottomDialogButtonStyle"
|
android:text="@string/install"
|
||||||
android:text="@string/install" />
|
style="@style/BottomDialogButtonStyle"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
</layout>
|
|
||||||
|
|
Loading…
Reference in a new issue