コード例 #1
0
 public static int getPersistedInt(Preference pref, int defaultReturnValue) {
   OrionApplication appContext = (OrionApplication) pref.getContext().getApplicationContext();
   LastPageInfo info = appContext.getCurrentBookParameters();
   if (info != null) {
     try {
       Field f = info.getClass().getDeclaredField(pref.getKey());
       Integer value = (Integer) f.get(info);
       return value;
     } catch (Exception e) {
       Common.d(e);
     }
   }
   return defaultReturnValue;
 }
コード例 #2
0
 public static String getPersistedString(Preference pref, String defaultReturnValue) {
   LastPageInfo info =
       ((OrionApplication) pref.getContext().getApplicationContext()).getCurrentBookParameters();
   if (info != null) {
     try {
       Field f = info.getClass().getDeclaredField(pref.getKey());
       String value = f.get(info).toString();
       return value;
     } catch (Exception e) {
       Common.d(e);
     }
   }
   return defaultReturnValue;
 }
コード例 #3
0
 public static boolean persistValue(Preference pref, String value) {
   OrionApplication appContext = (OrionApplication) pref.getContext().getApplicationContext();
   LastPageInfo info = appContext.getCurrentBookParameters();
   if (info != null) {
     try {
       Field f = info.getClass().getDeclaredField(pref.getKey());
       Class clazz = f.getType();
       Object resultValue = value;
       if (int.class.equals(clazz)) {
         resultValue = Integer.valueOf(value);
       }
       f.set(info, resultValue);
       ((OrionApplication) appContext.getApplicationContext())
           .processBookOptionChange(pref.getKey(), resultValue);
       return true;
     } catch (Exception e) {
       Common.d(e);
     }
   }
   return false;
 }