PreferencesActivity -> jetpack
This commit is contained in:
parent
3f229dfa9b
commit
3022214105
|
@ -7,19 +7,22 @@ import android.text.TextWatcher
|
|||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceScreen
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActivityPreferencesBinding
|
||||
import info.nightscout.androidaps.utils.locale.LocaleHelper
|
||||
import kotlinx.android.synthetic.main.activity_preferences.*
|
||||
|
||||
class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompat.OnPreferenceStartScreenCallback {
|
||||
|
||||
var preferenceId = 0
|
||||
var myPreferenceFragment: MyPreferenceFragment? = null
|
||||
private var preferenceId = 0
|
||||
private var myPreferenceFragment: MyPreferenceFragment? = null
|
||||
|
||||
private lateinit var binding: ActivityPreferencesBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_preferences)
|
||||
binding = ActivityPreferencesBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
pref_filter.addTextChangedListener(object : TextWatcher {
|
||||
binding.prefFilter.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
filterPreferences()
|
||||
|
@ -35,7 +38,7 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa
|
|||
preferenceId = intent.getIntExtra("id", -1)
|
||||
myPreferenceFragment?.arguments = Bundle().also {
|
||||
it.putInt("id", preferenceId)
|
||||
it.putString("filter", pref_filter.text.toString())
|
||||
it.putString("filter", binding.prefFilter.text.toString())
|
||||
}
|
||||
if (savedInstanceState == null)
|
||||
supportFragmentManager.beginTransaction().replace(R.id.frame_layout, myPreferenceFragment!!).commit()
|
||||
|
@ -56,6 +59,6 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa
|
|||
}
|
||||
|
||||
private fun filterPreferences() {
|
||||
myPreferenceFragment?.setFilter(pref_filter.text.toString())
|
||||
myPreferenceFragment?.setFilter(binding.prefFilter.text.toString())
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue