org.solovyev.android.prefs.AbstractEnumPickerDialogPreference Maven / Gradle / Ivy
package org.solovyev.android.prefs;
import android.content.Context;
import android.util.AttributeSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.Labeled;
import org.solovyev.android.LabeledFormatter;
import org.solovyev.android.view.ListRange;
import org.solovyev.android.view.Picker;
import org.solovyev.common.text.EnumMapper;
import java.util.Arrays;
/**
* User: serso
* Date: 8/10/12
* Time: 2:02 AM
*/
public abstract class AbstractEnumPickerDialogPreference extends AbstractPickerDialogPreference {
@NotNull
private final Class enumClass;
protected AbstractEnumPickerDialogPreference(Context context,
AttributeSet attrs,
@Nullable String defaultStringValue,
boolean needValueText,
@NotNull Class enumClass) {
super(context, attrs, defaultStringValue, needValueText, new EnumMapper(enumClass));
this.enumClass = enumClass;
}
@NotNull
@Override
protected Picker.Range createRange(@NotNull T selected) {
return new ListRange(Arrays.asList(enumClass.getEnumConstants()), selected, new LabeledFormatter(getContext()));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy