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