Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5748b9b8 authored by Chaohui Wang's avatar Chaohui Wang
Browse files

Migrate to TwoStatePreference

SwitchPreference and SwitchPreferenceCompat are both TwoStatePreference.

Using TwoStatePreference in Java will helps migration in the future.

Bug: 306771414
Test: manual - robo test
Change-Id: I7f22ca816d8aeb0c688cdb635d868f918e441605
parent ce80e37f
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package com.android.settingslib.core.instrumentation
import android.view.View
import androidx.annotation.VisibleForTesting
import androidx.preference.PreferenceGroupAdapter
import androidx.preference.SwitchPreference
import androidx.preference.TwoStatePreference
import androidx.recyclerview.widget.RecyclerView
import com.android.internal.jank.InteractionJankMonitor
import java.util.concurrent.Executors
@@ -43,7 +43,10 @@ object SettingsJankMonitor {
     * @param preference the clicked preference
     */
    @JvmStatic
    fun detectSwitchPreferenceClickJank(recyclerView: RecyclerView, preference: SwitchPreference) {
    fun detectSwitchPreferenceClickJank(
        recyclerView: RecyclerView,
        preference: TwoStatePreference,
    ) {
        val adapter = recyclerView.adapter as? PreferenceGroupAdapter ?: return
        val adapterPosition = adapter.getPreferenceAdapterPosition(preference)
        val viewHolder = recyclerView.findViewHolderForAdapterPosition(adapterPosition) ?: return