本文整理汇总了Java中com.csipsimple.utils.PreferencesWrapper.gPrefClass方法的典型用法代码示例。如果您正苦于以下问题:Java PreferencesWrapper.gPrefClass方法的具体用法?Java PreferencesWrapper.gPrefClass怎么用?Java PreferencesWrapper.gPrefClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.csipsimple.utils.PreferencesWrapper
的用法示例。
在下文中一共展示了PreferencesWrapper.gPrefClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import com.csipsimple.utils.PreferencesWrapper; //导入方法依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String order) {
MatrixCursor resCursor = new MatrixCursor(new String[] { SipConfigManager.FIELD_NAME, SipConfigManager.FIELD_VALUE });
if (URI_MATCHER.match(uri) == PREF_ID) {
String name = uri.getLastPathSegment();
Class<?> aClass = null;
if (TextUtils.isEmpty(selection)) {
aClass = PreferencesWrapper.gPrefClass(name);
} else {
try {
aClass = Class.forName(selection);
} catch (ClassNotFoundException e) {
Log.e(THIS_FILE, "Impossible to retrieve class from selection");
}
}
Object value = null;
if (aClass == String.class) {
value = prefs.getPreferenceStringValue(name);
} else if (aClass == Float.class) {
value = prefs.getPreferenceFloatValue(name);
} else if (aClass == Boolean.class) {
Boolean v = prefs.getPreferenceBooleanValue(name);
if(v != null) {
value = v ? 1 : 0;
}else {
value = -1;
}
} else if(aClass == Integer.class) {
value = prefs.getPreferenceIntegerValue(name);
}
if (value != null) {
resCursor.addRow(new Object[] { name, value });
} else {
resCursor = null;
}
}
return resCursor;
}
示例2: update
import com.csipsimple.utils.PreferencesWrapper; //导入方法依赖的package包/类
@Override
public int update(Uri uri, ContentValues cv, String selection, String[] selectionArgs) {
int count = 0;
switch (URI_MATCHER.match(uri)) {
case PREFS:
// Ignore for now
break;
case PREF_ID:
String name = uri.getLastPathSegment();
Class<?> aClass = null;
if (TextUtils.isEmpty(selection)) {
aClass = PreferencesWrapper.gPrefClass(name);
} else {
try {
aClass = Class.forName(selection);
} catch (ClassNotFoundException e) {
Log.e(THIS_FILE, "Impossible to retrieve class from selection");
}
}
if (aClass == String.class) {
prefs.setPreferenceStringValue(name, cv.getAsString(SipConfigManager.FIELD_VALUE));
} else if (aClass == Float.class) {
prefs.setPreferenceFloatValue(name, cv.getAsFloat(SipConfigManager.FIELD_VALUE));
} else if (aClass == Boolean.class) {
prefs.setPreferenceBooleanValue(name, cv.getAsBoolean(SipConfigManager.FIELD_VALUE));
}
count++;
break;
case RAZ:
prefs.resetAllDefaultValues();
break;
}
return count;
}