JaRMoS  1.1
Java Reduced Model Simulations
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
Const.java
Go to the documentation of this file.
1 
4 package jarmos.app;
5 
12 
13 import java.net.URL;
14 
15 import android.content.Context;
16 import android.content.Intent;
17 import android.content.SharedPreferences;
18 
26 public class Const {
27 
33  public static final String DEX_CLASSES_JARFILE = "dexclasses.jar";
34 
42  public static String APP_DATA_DIRECTORY = null;
43 
48  public static final String EXTRA_MODELMANAGER_CLASSNAME = "amodelmanager_classname";
49 
53  public static final String EXTRA_MODELMANAGER_MODELDIR = "amodelmanager_modeldir";
54 
58  public static final String PREFERENCES_FILENAME = "jarmos.app.prefs";
59 
64  public static final String PREF_MODELCACHING = "modelCaching";
65 
70  public static final String PREF_MODELCACHING_OVERWRITE = "modelCachingOverwrite";
71 
86  public static AModelManager getModelManager(Context c, Intent i) throws ModelManagerException {
87  AModelManager res = null;
88  String classname = i.getStringExtra(EXTRA_MODELMANAGER_CLASSNAME);
89  if ("AssetModelManager".equals(classname)) {
90  res = new AssetModelManager(c);
91  } else if ("SDModelManager".equals(classname)) {
92  res = new SDModelManager(c);
93  } else if ("WebModelManager".equals(classname)) {
94  res = new WebModelManager((URL) i.getSerializableExtra("URL"), c);
95  SharedPreferences p = c.getSharedPreferences(PREFERENCES_FILENAME, 0);
96  if (p.getBoolean(PREF_MODELCACHING, false)) {
97  res = new CachingModelManager(res, new SDModelManager(c), p.getBoolean(PREF_MODELCACHING_OVERWRITE,
98  false));
99  }
100  } else {
101  if (classname == null) {
102  throw new RuntimeException("ModelManagerService: Intent string extra '" + EXTRA_MODELMANAGER_CLASSNAME
103  + "' is null");
104  } else
105  throw new RuntimeException("ModelManagerService: Class " + classname + " not known as AModelManager");
106  }
107  String md = i.getStringExtra(EXTRA_MODELMANAGER_MODELDIR);
108  if (md != null) {
109  res.useModel(md);
110  }
111  return res;
112  }
113 
114  // public static boolean showQuestion(final Activity a, String text) {
115  //
116  // class Res {
117  // public boolean result = false;
118  // }
119  // final Res r = new Res();
120  // DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
121  // @Override
122  // public void onClick(DialogInterface dialog, int which) {
123  // switch (which){
124  // case DialogInterface.BUTTON_POSITIVE:
125  // r.result = true;
126  // break;
127  // case DialogInterface.BUTTON_NEGATIVE:
128  // r.result = false;
129  // break;
130  // }
131  // dialog.dismiss();
132  // a.notify();
133  // }
134  // };
135  //
136  // new AlertDialog.Builder(a).setMessage(text).setPositiveButton("Yes", dialogClickListener)
137  // .setNegativeButton("No", dialogClickListener).show();
138  // try {
139  // a.wait();
140  // } catch (InterruptedException e) {
141  // // TODO Auto-generated catch block
142  // e.printStackTrace();
143  // }
144  // return r.result;
145  // }
146 
147 }
static final String PREF_MODELCACHING
The name for the preference storing information about whether models should be cached when loaded fro...
Definition: Const.java:64
Class for model loading from the local SD card of the mobile device running android.
static final String PREFERENCES_FILENAME
The filename for the application preferences.
Definition: Const.java:58
Class to load models from application assets.
static String APP_DATA_DIRECTORY
The directory where the application may write data to and read from.
Definition: Const.java:42
static final String DEX_CLASSES_JARFILE
The file name within a model directory that contains any runtime-loadable classes.
Definition: Const.java:33
This class serves as base class for accessing various types of models at different locations...
A model manager implementation that allows to load models from web locations.
This Exception gets thrown when an error occurs regarding the functionality of the ModelManager...
static final String EXTRA_MODELMANAGER_CLASSNAME
The string describing the class name which denotes the corret AModelManager subclass to be instantiat...
Definition: Const.java:48
static final String EXTRA_MODELMANAGER_MODELDIR
The string extra in intents to tell which model directory is currently used.
Definition: Const.java:53
Class that contains miscellaneous JaRMoS specific constants and static functions. ...
Definition: Const.java:26
A wrapper class that takes any AModelManager as source and a FileModelManager as target.
static final String PREF_MODELCACHING_OVERWRITE
The name for the preference storing information about whether existing model data is overwritten when...
Definition: Const.java:70
static AModelManager getModelManager(Context c, Intent i)
Returns a model manager instance for the current intent.
Definition: Const.java:86