Use cached Views

This commit is contained in:
Benoit Marty 2020-08-26 12:30:26 +02:00
parent ef912e066b
commit 9f3f981ab0
5 changed files with 8 additions and 9 deletions

View File

@ -20,7 +20,6 @@ import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.RadioGroup
import android.widget.TextView
import androidx.preference.PreferenceViewHolder
import im.vector.app.R
import org.matrix.android.sdk.api.pushrules.RuleSetKey
@ -162,7 +161,7 @@ class PushRulePreference : VectorPreference {
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
holder.itemView.findViewById<TextView>(android.R.id.summary)?.visibility = View.GONE
holder.findViewById(android.R.id.summary)?.visibility = View.GONE
holder.itemView.setOnClickListener(null)
holder.itemView.setOnLongClickListener(null)

View File

@ -45,7 +45,7 @@ class VectorEditTextPreference : EditTextPreference {
override fun onBindViewHolder(holder: PreferenceViewHolder) {
// display the title in multi-line to avoid ellipsis.
try {
holder.itemView.findViewById<TextView>(android.R.id.title)?.isSingleLine = false
(holder.findViewById(android.R.id.title) as? TextView)?.isSingleLine = false
} catch (e: Exception) {
Timber.e(e, "onBindView")
}

View File

@ -84,15 +84,15 @@ open class VectorPreference : Preference {
// display the title in multi-line to avoid ellipsis.
try {
val title = itemView.findViewById<TextView>(android.R.id.title)
val summary = itemView.findViewById<TextView>(android.R.id.summary)
val title = holder.findViewById(android.R.id.title) as? TextView
val summary = holder.findViewById(android.R.id.summary) as? TextView
if (title != null) {
title.isSingleLine = false
title.setTypeface(null, mTypeface)
}
if (title !== summary) {
summary.setTypeface(null, mTypeface)
summary?.setTypeface(null, mTypeface)
}
// cancel existing animation (find a way to resume if happens during anim?)

View File

@ -45,7 +45,7 @@ class VectorPreferenceCategory : PreferenceCategory {
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
val titleTextView = holder.itemView.findViewById<TextView>(android.R.id.title)
val titleTextView = holder.findViewById(android.R.id.title) as? TextView
titleTextView?.setTypeface(null, Typeface.BOLD)
titleTextView?.setTextColor(ThemeUtils.getColor(context, R.attr.riotx_text_primary))

View File

@ -58,7 +58,7 @@ class VectorSwitchPreference : SwitchPreference {
override fun onBindViewHolder(holder: PreferenceViewHolder) {
// display the title in multi-line to avoid ellipsis.
holder.itemView.findViewById<TextView>(android.R.id.title)?.isSingleLine = false
(holder.findViewById(android.R.id.title) as? TextView)?.isSingleLine = false
// cancel existing animation (find a way to resume if happens during anim?)
currentHighlightAnimator?.cancel()