migrate remaining inflated layouts to viewbinding

This commit is contained in:
fatih ergin 2023-08-17 20:00:58 +03:00
parent c1b972998f
commit 27e054e023
3 changed files with 6 additions and 5 deletions

View File

@ -4,10 +4,10 @@ import android.view.ContextThemeWrapper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.RadioButton
import android.widget.RadioGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.databinding.DialogRadioGroupBinding
import com.simplemobiletools.commons.databinding.RadioButtonBinding
import com.simplemobiletools.commons.extensions.onGlobalLayout
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.keyboard.R
@ -34,7 +34,7 @@ class KeyboardRadioGroupDialog(
val binding = DialogRadioGroupBinding.inflate(layoutInflater)
binding.dialogRadioGroup.apply {
for (i in 0 until items.size) {
val radioButton = (layoutInflater.inflate(R.layout.radio_button, null) as RadioButton).apply {
val radioButton = RadioButtonBinding.inflate(layoutInflater).dialogRadioButton.apply {
text = items[i].title
isChecked = items[i].id == checkedItemId
id = i

View File

@ -11,6 +11,7 @@ import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.core.content.res.ResourcesCompat
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.simplemobiletools.commons.databinding.DialogTitleBinding
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.commons.models.RadioItem
@ -120,8 +121,7 @@ fun Context.setupKeyboardDialogStuff(
} else {
var title: TextView? = null
if (titleId != 0 || titleText.isNotEmpty()) {
title = LayoutInflater.from(this).inflate(R.layout.dialog_title, null) as TextView
title.apply {
title = DialogTitleBinding.inflate(LayoutInflater.from(this)).dialogTitleTextview.apply {
if (titleText.isNotEmpty()) {
text = titleText
} else {

View File

@ -37,6 +37,7 @@ import com.simplemobiletools.keyboard.activities.ManageClipboardItemsActivity
import com.simplemobiletools.keyboard.activities.SettingsActivity
import com.simplemobiletools.keyboard.adapters.ClipsKeyboardAdapter
import com.simplemobiletools.keyboard.adapters.EmojisAdapter
import com.simplemobiletools.keyboard.databinding.KeyboardKeyPreviewBinding
import com.simplemobiletools.keyboard.databinding.KeyboardPopupKeyboardBinding
import com.simplemobiletools.keyboard.databinding.KeyboardViewKeyboardBinding
import com.simplemobiletools.keyboard.dialogs.ChangeLanguagePopup
@ -206,7 +207,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
}
mPreviewPopup = PopupWindow(context)
mPreviewText = inflater.inflate(resources.getLayout(R.layout.keyboard_key_preview), null) as TextView
mPreviewText = KeyboardKeyPreviewBinding.inflate(inflater).root
mPreviewTextSizeLarge = context.resources.getDimension(R.dimen.preview_text_size).toInt()
mPreviewPopup.contentView = mPreviewText
mPreviewPopup.setBackgroundDrawable(null)