fixing complication error
This commit is contained in:
parent
7d3b599364
commit
0b268757a6
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.mariotaku.twidere.annotation;
|
||||
|
||||
import android.support.annotation.IntDef;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
@ -46,10 +44,6 @@ public @interface Preference {
|
|||
|
||||
boolean hasDefault() default false;
|
||||
|
||||
@Type int type() default Type.NULL;
|
||||
@PreferenceType int type() default PreferenceType.NULL;
|
||||
|
||||
@IntDef({Type.BOOLEAN, Type.INT, Type.LONG, Type.FLOAT, Type.STRING, Type.NULL, Type.INVALID})
|
||||
@interface Type {
|
||||
int BOOLEAN = 1, INT = 2, LONG = 3, FLOAT = 4, STRING = 5, NULL = 0, INVALID = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package org.mariotaku.twidere.annotation;
|
||||
|
||||
import android.support.annotation.IntDef;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/1/8.
|
||||
*/
|
||||
@IntDef({PreferenceType.BOOLEAN, PreferenceType.INT, PreferenceType.LONG, PreferenceType.FLOAT,
|
||||
PreferenceType.STRING, PreferenceType.NULL, PreferenceType.INVALID})
|
||||
public @interface PreferenceType {
|
||||
int BOOLEAN = 1, INT = 2, LONG = 3, FLOAT = 4, STRING = 5, NULL = 0, INVALID = -1;
|
||||
}
|
|
@ -23,10 +23,10 @@ import org.mariotaku.twidere.TwidereConstants;
|
|||
import org.mariotaku.twidere.annotation.Preference;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
|
||||
import static org.mariotaku.twidere.annotation.Preference.Type.BOOLEAN;
|
||||
import static org.mariotaku.twidere.annotation.Preference.Type.INT;
|
||||
import static org.mariotaku.twidere.annotation.Preference.Type.LONG;
|
||||
import static org.mariotaku.twidere.annotation.Preference.Type.STRING;
|
||||
import static org.mariotaku.twidere.annotation.PreferenceType.BOOLEAN;
|
||||
import static org.mariotaku.twidere.annotation.PreferenceType.INT;
|
||||
import static org.mariotaku.twidere.annotation.PreferenceType.LONG;
|
||||
import static org.mariotaku.twidere.annotation.PreferenceType.STRING;
|
||||
|
||||
public interface SharedPreferenceConstants {
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ package org.mariotaku.twidere;
|
|||
|
||||
import org.mariotaku.twidere.annotation.Preference;
|
||||
|
||||
import static org.mariotaku.twidere.annotation.Preference.Type.BOOLEAN;
|
||||
import static org.mariotaku.twidere.annotation.Preference.Type.STRING;
|
||||
import static org.mariotaku.twidere.annotation.PreferenceType.BOOLEAN;
|
||||
import static org.mariotaku.twidere.annotation.PreferenceType.STRING;
|
||||
|
||||
/**
|
||||
* Constants requires full application to build or useless for other
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.json.JSONException;
|
|||
import org.json.JSONObject;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.annotation.Preference;
|
||||
import org.mariotaku.twidere.annotation.Preference.Type;
|
||||
import org.mariotaku.twidere.annotation.PreferenceType;
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
|
@ -122,7 +122,7 @@ public class DataImportExportUtils implements Constants {
|
|||
for (final Field field : fields) {
|
||||
final Preference annotation = field.getAnnotation(Preference.class);
|
||||
if (Modifier.isStatic(field.getModifiers()) && CompareUtils.classEquals(field.getType(), String.class)
|
||||
&& annotation != null && annotation.exportable() && annotation.type() != Type.INVALID) {
|
||||
&& annotation != null && annotation.exportable() && annotation.type() != PreferenceType.INVALID) {
|
||||
try {
|
||||
supportedPrefsMap.put((String) field.get(null), annotation);
|
||||
} catch (final IllegalAccessException | IllegalArgumentException e) {
|
||||
|
@ -255,19 +255,19 @@ public class DataImportExportUtils implements Constants {
|
|||
final Preference preference = supportedMap.get(key);
|
||||
if (preference == null || !preference.exportable()) return false;
|
||||
switch (preference.type()) {
|
||||
case Type.BOOLEAN:
|
||||
case PreferenceType.BOOLEAN:
|
||||
editor.putBoolean(key, json.optBoolean(key, preference.defaultBoolean()));
|
||||
break;
|
||||
case Type.INT:
|
||||
case PreferenceType.INT:
|
||||
editor.putInt(key, json.optInt(key, preference.defaultInt()));
|
||||
break;
|
||||
case Type.LONG:
|
||||
case PreferenceType.LONG:
|
||||
editor.putLong(key, json.optLong(key, preference.defaultLong()));
|
||||
break;
|
||||
case Type.FLOAT:
|
||||
case PreferenceType.FLOAT:
|
||||
editor.putFloat(key, (float) json.optDouble(key, preference.defaultFloat()));
|
||||
break;
|
||||
case Type.STRING:
|
||||
case PreferenceType.STRING:
|
||||
editor.putString(key, json.optString(key, preference.defaultString()));
|
||||
break;
|
||||
default:
|
||||
|
@ -282,19 +282,19 @@ public class DataImportExportUtils implements Constants {
|
|||
if (preference == null || !preference.exportable()) return false;
|
||||
try {
|
||||
switch (preference.type()) {
|
||||
case Type.BOOLEAN:
|
||||
case PreferenceType.BOOLEAN:
|
||||
json.put(key, preferences.getBoolean(key, preference.defaultBoolean()));
|
||||
break;
|
||||
case Type.INT:
|
||||
case PreferenceType.INT:
|
||||
json.put(key, preferences.getInt(key, preference.defaultInt()));
|
||||
break;
|
||||
case Type.LONG:
|
||||
case PreferenceType.LONG:
|
||||
json.put(key, preferences.getLong(key, preference.defaultLong()));
|
||||
break;
|
||||
case Type.FLOAT:
|
||||
case PreferenceType.FLOAT:
|
||||
json.put(key, preferences.getFloat(key, preference.defaultFloat()));
|
||||
break;
|
||||
case Type.STRING:
|
||||
case PreferenceType.STRING:
|
||||
json.put(key, preferences.getString(key, preference.defaultString()));
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue