com.ryanm.preflect
Class Preflect

java.lang.Object
  extended by com.ryanm.preflect.Preflect

public class Preflect
extends java.lang.Object

Handy utility for manipulating object trees that have been marked up with Variable annotations

Author:
ryanm

Field Summary
static int ACTIVITY_REQUEST_FLAG
          The activity request flag used in Activity#startActivityForResult(Intent, int) when launching the configuration activity (value = 266344)
static java.lang.String autoSaveName
          The name under which applied configurations are automatically saved.
static boolean errorOnNonPublicVariables
          When true, a StructuralError will be thrown if a private field or method is encountered with a Variable annotation, when false, no error is raised and the variable is ignored.
static java.lang.String LOG_TAG
          Logging tag
 
Method Summary
static void applyDeferredConfigurations(java.lang.Object... configTargets)
          Call this to apply configurations previously deferred in deferActivityResult(int, int, Intent)
static void configure(Activity returnTo, boolean showPersist, boolean showConfirm, java.lang.Object... roots)
           
static void deferActivityResult(int requestCode, int resultCode, Intent data)
          Call this from your Activity.onActivityResult() instead of onActivityResult(int, int, Intent, Object...) to save a configuration for later application.
static boolean onActivityResult(int requestCode, int resultCode, Intent data, java.lang.Object... configTargets)
          Call this from your activity in Activity .onActivityResult() to apply a configuration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorOnNonPublicVariables

public static boolean errorOnNonPublicVariables
When true, a StructuralError will be thrown if a private field or method is encountered with a Variable annotation, when false, no error is raised and the variable is ignored. Default value is true


autoSaveName

public static java.lang.String autoSaveName
The name under which applied configurations are automatically saved. Set to null to disable automatic saving


LOG_TAG

public static final java.lang.String LOG_TAG
Logging tag

See Also:
Constant Field Values

ACTIVITY_REQUEST_FLAG

public static final int ACTIVITY_REQUEST_FLAG
The activity request flag used in Activity#startActivityForResult(Intent, int) when launching the configuration activity (value = 266344)

See Also:
Constant Field Values
Method Detail

configure

public static void configure(Activity returnTo,
                             boolean showPersist,
                             boolean showConfirm,
                             java.lang.Object... roots)
Parameters:
returnTo - The activity to return to when we are done configuring
showPersist - When true, the user will be able manually save multiple different configurations.
showConfirm - When true, the user will have to confirm or cancel configuration changes before leaving the generated PreferenceActivity. This might be useful if the preference hierarchy is deep and the user risks prematurely leaving the activity by accident
roots - The (annotated) objects to configure.

onActivityResult

public static boolean onActivityResult(int requestCode,
                                       int resultCode,
                                       Intent data,
                                       java.lang.Object... configTargets)
Call this from your activity in Activity .onActivityResult() to apply a configuration

Parameters:
requestCode - from Activity.onActivityResult()
resultCode - from Activity.onActivityResult()
data - from Activity.onActivityResult()
configTargets - roots of the object trees to apply configurations to
Returns:
true if the configuration was applied, false otherwise

deferActivityResult

public static void deferActivityResult(int requestCode,
                                       int resultCode,
                                       Intent data)
Call this from your Activity.onActivityResult() instead of onActivityResult(int, int, Intent, Object...) to save a configuration for later application. This is useful if your configuration changes need to be done in a particular thread like, for example, OpenGL stuff

Parameters:
requestCode - from Activity.onActivityResult()
resultCode - from Activity.onActivityResult()
data - from Activity.onActivityResult()

applyDeferredConfigurations

public static void applyDeferredConfigurations(java.lang.Object... configTargets)
Call this to apply configurations previously deferred in deferActivityResult(int, int, Intent)

Parameters:
configTargets - roots of the object trees to apply configurations to