package cl.monsoon.s1next.widget;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.preference.ListPreference;
import android.util.AttributeSet;

/**
 * See https://android.googlesource.com/platform/frameworks/base/+/94c02a1a1a6d7e6900e5a459e9cc699b9510e5a2
 */
@SuppressWarnings("UnusedDeclaration")
final class ListPreferenceCompat extends ListPreference {

    public ListPreferenceCompat(Context context) {
        super(context);
    }

    public ListPreferenceCompat(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public ListPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public ListPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    /**
     * setValue() was not calling notifyChanged() before android-4.4,
     */
    @Override
    public void setValue(String value) {
        super.setValue(value);

        notifyChanged();
    }
}

@@ -164,16 +164,47 @@
 erence;%0A
+import android.text.TextUtils;%0A
 import a
@@ -1190,56 +1190,306 @@
     
-super.setValue(value);%0A%0A        notifyChanged();
+if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.KITKAT) %7B%0A            super.setValue(value);%0A        %7D else %7B%0A            String oldValue = getValue();%0A            super.setValue(value);%0A            if (!TextUtils.equals(value, oldValue)) %7B%0A                notifyChanged();%0A            %7D%0A        %7D
 %0A   

Optimize `ListPreferenceCompat`'s code