本文整理匯總了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;
}