mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-26 05:05:15 +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,51 +2,54 @@ 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)
|
||||
|
||||
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 {
|
||||
dismiss()
|
||||
AppVersionSelectorDialog.newInstance(
|
||||
versions = musicVersionsConv,
|
||||
app = "music"
|
||||
).show(requireActivity())
|
||||
}
|
||||
binding.musicInstall.setOnClickListener {
|
||||
dismiss()
|
||||
AppDownloadDialog.newInstance(
|
||||
app = getString(R.string.music)
|
||||
).show(requireActivity())
|
||||
private fun bindData() {
|
||||
with(binding) {
|
||||
val musicVersionsConv = musicVersions.get()?.value?.reversed()?.convertToAppVersions()
|
||||
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())
|
||||
}
|
||||
musicInstall.setOnClickListener {
|
||||
dismiss()
|
||||
AppDownloadDialog.newInstance(
|
||||
app = getString(R.string.music)
|
||||
).show(requireActivity())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +1,43 @@
|
|||
<?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">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/BottomDialogCard">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/music_install_title"
|
||||
style="@style/BottomDialogCardTitle"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:layout_marginTop="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/music_install_title"
|
||||
style="@style/BottomDialogCardTitle" />
|
||||
android:id="@+id/music_version"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toStartOf="@id/open_version_selector"
|
||||
style="@style/BottomDialogCardTextItem"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
<ImageButton
|
||||
android:id="@+id/open_version_selector"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp">
|
||||
android:layout_alignParentEnd="true"
|
||||
android:background="@android:color/transparent"
|
||||
android:maxWidth="24dp"
|
||||
android:maxHeight="24dp"
|
||||
android:src="@drawable/ic_baseline_navigate_next_36"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/music_version"
|
||||
style="@style/BottomDialogCardTextItem"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toStartOf="@id/open_version_selector" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/open_version_selector"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:background="@android:color/transparent"
|
||||
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" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</layout>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/music_install"
|
||||
android:text="@string/install"
|
||||
style="@style/BottomDialogButtonStyle"/>
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
Loading…
Reference in a new issue