Beispiel #1
0
  public static synchronized void dispose() {
    checkInitialization();
    closeDatabase();

    sEntities = null;
    sModelInfo = null;
    sDatabaseHelper = null;

    sIsInitialized = false;

    Log.v("ActiveAndroid disposed. Call initialize to use library.");
  }
Beispiel #2
0
  public static synchronized Model getEntity(Class<? extends Model> type, long id) {
    checkInitialization();
    for (Model entity : sEntities) {
      if (entity != null
          && entity.getClass() != null
          && entity.getClass() == type
          && entity.getId() != null
          && entity.getId() == id) {

        return entity;
      }
    }

    return null;
  }
Beispiel #3
0
 public static synchronized SQLiteDatabase openDatabase() {
   if (sDatabaseHelper == null) {
     checkInitialization();
   }
   return sDatabaseHelper.getWritableDatabase();
 }
Beispiel #4
0
 public static synchronized String getTableName(Class<? extends Model> type) {
   checkInitialization();
   return sModelInfo.getTableInfo(type).getTableName();
 }
Beispiel #5
0
 public static synchronized TypeSerializer getParserForType(Class<?> type) {
   checkInitialization();
   return sModelInfo.getTypeSerializer(type);
 }
Beispiel #6
0
 public static synchronized Collection<TableInfo> getTableInfos() {
   checkInitialization();
   return sModelInfo.getTableInfos();
 }
Beispiel #7
0
 public static synchronized void removeEntity(Model entity) {
   checkInitialization();
   sEntities.remove(entity);
 }
Beispiel #8
0
 public static synchronized void addEntity(Model entity) {
   checkInitialization();
   sEntities.add(entity);
 }
Beispiel #9
0
 public static Context getContext() {
   checkInitialization();
   return sContext;
 }
Beispiel #10
0
 public static synchronized void closeDatabase() {
   checkInitialization();
   sDatabaseHelper.close();
 }