You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1015 B

package com.community.pocket.util;
import androidx.annotation.StringRes;
import com.community.pocket.R;
import java.util.Locale;
//语言类型
public enum LocaleType {
auto(Locale.ENGLISH, 0, R.string.language_auto),
chs(Locale.CHINA, 1, R.string.language_chs),
en(Locale.ENGLISH, 2, R.string.language_en);
//语言
private Locale locale;
//类型值
private int type;
//选项名对应的资源id
private int resId;
public Locale getLocale() {
return locale;
}
public int getType() {
return type;
}
public int getResId() {
return resId;
}
LocaleType(Locale locale, int type, @StringRes int resId) {
this.locale = locale;
this.type = type;
this.resId = resId;
}
public static LocaleType getLocale(int type) {
for (LocaleType t : LocaleType.values()) {
if (t.type == type) {
return t;
}
}
return LocaleType.auto;
}
}