package org.ccci.gto.android.common.preference;

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

public class ListPreferenceCompat extends ListPreference {
    public ListPreferenceCompat(final Context context) {
        super(context);
    }

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

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

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

    /**
     * Sets the value of the key. This should be one of the entries in
     * {@link #getEntryValues()}.
     *
     * @param value The value to set for the key.
     * @see <a href="http://stackoverflow.com/a/21642401/4721910">http://stackoverflow.com/a/21642401/4721910</a>
     */
    @Override
    public void setValue(final String value) {
        // Android pre-KitKat didn't let the preference know that data had changed, which caused stale Summaries.
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            String oldValue = getValue();
            super.setValue(value);
            if (!TextUtils.equals(value, oldValue)) {
                notifyChanged();
            }
        } else {
            super.setValue(value);
        }
    }
}

@@ -182,39 +182,8 @@
 ce;%0A
-import android.text.TextUtils;%0A
 impo
@@ -959,787 +959,7 @@
    %7D
-%0A%0A    /**%0A     * Sets the value of the key. This should be one of the entries in%0A     * %7B@link #getEntryValues()%7D.%0A     *%0A     * @param value The value to set for the key.%0A     * @see %3Ca href=%22http://stackoverflow.com/a/21642401/4721910%22%3Ehttp://stackoverflow.com/a/21642401/4721910%3C/a%3E%0A     */%0A    @Override%0A    public void setValue(final String value) %7B%0A        // Android pre-KitKat didn't let the preference know that data had changed, which caused stale Summaries.%0A        if (Build.VERSION.SDK_INT %3C Build.VERSION_CODES.KITKAT) %7B%0A            String oldValue = getValue();%0A            super.setValue(value);%0A            if (!TextUtils.equals(value, oldValue)) %7B%0A                notifyChanged();%0A            %7D%0A        %7D else %7B%0A            super.setValue(value);%0A        %7D%0A    %7D
 %0A%7D%0A

remove unnecessary override for older versions of Android we no longer support