com.activeandroid.ActiveAndroid Java Examples
The following examples show how to use
com.activeandroid.ActiveAndroid.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentProvider.java From mobile-android-survey-app with MIT License | 6 votes |
@Override public boolean onCreate() { ActiveAndroid.initialize(getConfiguration()); sAuthority = getAuthority(); final List<TableInfo> tableInfos = new ArrayList<TableInfo>(Cache.getTableInfos()); final int size = tableInfos.size(); for (int i = 0; i < size; i++) { final TableInfo tableInfo = tableInfos.get(i); final int tableKey = (i * 2) + 1; final int itemKey = (i * 2) + 2; // content://<authority>/<table> URI_MATCHER.addURI(sAuthority, tableInfo.getTableName().toLowerCase(), tableKey); TYPE_CODES.put(tableKey, tableInfo.getType()); // content://<authority>/<table>/<id> URI_MATCHER.addURI(sAuthority, tableInfo.getTableName().toLowerCase() + "/#", itemKey); TYPE_CODES.put(itemKey, tableInfo.getType()); } return true; }
Example #2
Source File: Application.java From mobile-android-survey-app with MIT License | 6 votes |
@Override public void onCreate() { super.onCreate(); Log.setCallback(this); Prefs.setServer(getServer()); ActiveAndroid.initialize(this); Fabric fabric = new Fabric.Builder(this) .kits(new Crashlytics()) .debuggable(true) .build(); Fabric.with(fabric); if (Prefs.hasName()) { Crashlytics.setUserName(Prefs.getName()); } if (Prefs.hasUsername()) { Crashlytics.setUserEmail(Prefs.getUsername()); } Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler()); }
Example #3
Source File: ContentProvider.java From clear-todolist with GNU General Public License v3.0 | 6 votes |
@Override public boolean onCreate() { ActiveAndroid.initialize(getConfiguration()); sAuthority = getAuthority(); final List<TableInfo> tableInfos = new ArrayList<TableInfo>(Cache.getTableInfos()); final int size = tableInfos.size(); for (int i = 0; i < size; i++) { final TableInfo tableInfo = tableInfos.get(i); final int tableKey = (i * 2) + 1; final int itemKey = (i * 2) + 2; // content://<authority>/<table> URI_MATCHER.addURI(sAuthority, tableInfo.getTableName().toLowerCase(), tableKey); TYPE_CODES.put(tableKey, tableInfo.getType()); // content://<authority>/<table>/<id> URI_MATCHER.addURI(sAuthority, tableInfo.getTableName().toLowerCase() + "/#", itemKey); TYPE_CODES.put(itemKey, tableInfo.getType()); } return true; }
Example #4
Source File: MainApplication.java From AndroidDatabaseLibraryComparison with MIT License | 6 votes |
@Override public void onCreate() { super.onCreate(); ActiveAndroid.initialize(new Configuration.Builder(this) .setDatabaseName("activeandroid") .setDatabaseVersion(1) .setModelClasses(SimpleAddressItem.class, AddressItem.class, AddressBook.class, Contact.class).create()); Ollie.with(this) .setName("ollie") .setVersion(1) .setLogLevel(Ollie.LogLevel.FULL) .init(); FlowManager.init(this); Sprinkles.init(this, "sprinkles.db", 2); RealmConfiguration realmConfig = new RealmConfiguration.Builder(this).build(); Realm.setDefaultConfiguration(realmConfig); mDatabase = getDatabase(); }
Example #5
Source File: AATester.java From AndroidDatabaseLibraryComparison with MIT License | 6 votes |
public static void testAddressItems(Context context) { new Delete().from(SimpleAddressItem.class).execute(); final Collection<SimpleAddressItem> activeAndroidModels = Generator.getAddresses(SimpleAddressItem.class, MainActivity.LOOP_COUNT); long startTime = System.currentTimeMillis(); // Reuse method so we don't have to write TransactionManager.transact(ActiveAndroid.getDatabase(), new Runnable() { @Override public void run() { Saver.saveAll(activeAndroidModels); } }); EventBus.getDefault().post(new LogTestDataEvent(startTime, FRAMEWORK_NAME, MainActivity.SAVE_TIME)); startTime = System.currentTimeMillis(); Collection<SimpleAddressItem> activeAndroidModelLoad = new Select().from(SimpleAddressItem.class).execute(); EventBus.getDefault().post(new LogTestDataEvent(startTime, FRAMEWORK_NAME, MainActivity.LOAD_TIME)); new Delete().from(SimpleAddressItem.class).execute(); }
Example #6
Source File: MainActivity.java From multi-column-list-adapter with Apache License 2.0 | 6 votes |
private void loadToastersIntoDatabase() { List<ToasterModel> toasterModels = new Select().from(ToasterModel.class).execute(); if (toasterModels == null || toasterModels.size() == 0) { ActiveAndroid.beginTransaction(); try { Toaster[] toasters = ToasterData.getToasters(); for (Toaster toaster : toasters) { ToasterModel toasterModel = new ToasterModel(); toasterModel.name = toaster.name; toasterModel.imageResId = toaster.imageResId; toasterModel.save(); } ActiveAndroid.setTransactionSuccessful(); } finally { ActiveAndroid.endTransaction(); } } }
Example #7
Source File: xdrip.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate() { xdrip.context = getApplicationContext(); super.onCreate(); try { if (PreferenceManager.getDefaultSharedPreferences(xdrip.context).getBoolean("enable_crashlytics", true)) { initCrashlytics(this); } } catch (Exception e) { Log.e(TAG, e.toString()); } PreferenceManager.setDefaultValues(this, R.xml.preferences, true); ActiveAndroid.initialize(this); updateMigrations(); DemiGod.isPresent(); JoH.forceBatteryWhitelisting(); executor = new PlusAsyncExecutor(); VersionTracker.updateDevice(); disableUpdates(); }
Example #8
Source File: Sensor.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
public static void InitDb(Context context) {//KS Configuration dbConfiguration = new Configuration.Builder(context).create(); try { SQLiteDatabase db = Cache.openDatabase(); if (db != null) { Log.d("wearSENSOR", "InitDb DB exists"); } else { ActiveAndroid.initialize(dbConfiguration); Log.d("wearSENSOR", "InitDb DB does NOT exist. Call ActiveAndroid.initialize()"); } } catch (Exception e) { ActiveAndroid.initialize(dbConfiguration); Log.d("wearSENSOR", "InitDb CATCH: DB does NOT exist. Call ActiveAndroid.initialize()"); } }
Example #9
Source File: Animation.java From AnimeTaste with MIT License | 6 votes |
public static void removeAllFavorite(final UpdateFinishCallback callback) { new Thread() { @Override public void run() { super.run(); List<Animation> list = new Select().from(Animation.class).where("IsFavorite=?", 1).execute(); Iterator<Animation> iterator = list.iterator(); ActiveAndroid.beginTransaction(); while (iterator.hasNext()) { Animation animation = iterator.next(); animation.IsFav = false; animation.save(); } ActiveAndroid.setTransactionSuccessful(); ActiveAndroid.endTransaction(); Message msg = Message.obtain(); Looper.prepare(); msg.setTarget(new FavoriteHandler(callback, Method.REMOVE_ALL_FAVORITE)); msg.sendToTarget(); Looper.loop(); } }.start(); }
Example #10
Source File: xdrip.java From xDrip with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate() { xdrip.context = getApplicationContext(); super.onCreate(); try { if (PreferenceManager.getDefaultSharedPreferences(xdrip.context).getBoolean("enable_crashlytics", true)) { initCrashlytics(this); } } catch (Exception e) { Log.e(TAG, e.toString()); } PreferenceManager.setDefaultValues(this, R.xml.preferences, true); ActiveAndroid.initialize(this); updateMigrations(); DemiGod.isPresent(); JoH.forceBatteryWhitelisting(); executor = new PlusAsyncExecutor(); VersionTracker.updateDevice(); disableUpdates(); }
Example #11
Source File: Sensor.java From xDrip with GNU General Public License v3.0 | 6 votes |
public static void InitDb(Context context) {//KS Configuration dbConfiguration = new Configuration.Builder(context).create(); try { SQLiteDatabase db = Cache.openDatabase(); if (db != null) { Log.d("wearSENSOR", "InitDb DB exists"); } else { ActiveAndroid.initialize(dbConfiguration); Log.d("wearSENSOR", "InitDb DB does NOT exist. Call ActiveAndroid.initialize()"); } } catch (Exception e) { ActiveAndroid.initialize(dbConfiguration); Log.d("wearSENSOR", "InitDb CATCH: DB does NOT exist. Call ActiveAndroid.initialize()"); } }
Example #12
Source File: AppHolder.java From bleYan with GNU General Public License v2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); ActiveAndroid.initialize(this); BleLog.setPrintLog(true); AppLog.setPrintLog(true); _instance = this; }
Example #13
Source File: TestingApplication.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Override public void onTerminate() { try { ActiveAndroid.getDatabase().close(); } catch (Exception e) { System.out.println("Exception stopping database: " + e); } }
Example #14
Source File: Sensor.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static void DeleteAndInitDb(Context context) {//KS Configuration dbConfiguration = new Configuration.Builder(context).create(); try { ActiveAndroid.dispose(); context.deleteDatabase("DexDrip.db"); //ActiveAndroid.initialize(dbConfiguration); Log.d("wearSENSOR", "DeleteAndInitDb DexDrip.db deleted and initialized."); } catch (Exception e) { Log.e("wearSENSOR", "DeleteAndInitDb CATCH Error."); } }
Example #15
Source File: AATester.java From AndroidDatabaseLibraryComparison with MIT License | 5 votes |
public static void testAddressBooks(Context context) { new Delete().from(AddressItem.class).execute(); new Delete().from(Contact.class).execute(); new Delete().from(AddressBook.class).execute(); Collection<AddressBook> addressBooks = Generator.createAddressBooks(AddressBook.class, Contact.class, AddressItem.class, MainActivity.ADDRESS_BOOK_COUNT); long startTime = System.currentTimeMillis(); final Collection<AddressBook> finalAddressBooks = addressBooks; TransactionManager.transact(ActiveAndroid.getDatabase(), new Runnable() { @Override public void run() { Saver.saveAll(finalAddressBooks); } }); EventBus.getDefault().post(new LogTestDataEvent(startTime, FRAMEWORK_NAME, MainActivity.SAVE_TIME)); startTime = System.currentTimeMillis(); addressBooks = new Select().from(AddressBook.class).execute(); Loader.loadAllInnerData(addressBooks); EventBus.getDefault().post(new LogTestDataEvent(startTime, FRAMEWORK_NAME, MainActivity.LOAD_TIME)); new Delete().from(AddressItem.class).execute(); new Delete().from(Contact.class).execute(); new Delete().from(AddressBook.class).execute(); }
Example #16
Source File: AbsDbAPI.java From umeng_community_android with MIT License | 5 votes |
@Override public final void run() { ActiveAndroid.beginTransaction(); execute(); ActiveAndroid.setTransactionSuccessful(); ActiveAndroid.endTransaction(); }
Example #17
Source File: CommonApplication.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); // Create global configuration and initialize ImageLoader with this configuration ImageLoaderConfiguration config = UniversalImageLoader.getDefaultImageLoaderConfiguration(getApplicationContext()); ImageLoader.getInstance().init(config); ActiveAndroid.initialize(this); }
Example #18
Source File: ActiveAndroidSampleActivity.java From android-opensource-library-56 with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { ActiveAndroid.beginTransaction(); try { List<Todo> ended = new Select() .from(Todo.class) .where(Todo.COLUMN_STATUS + "=?", Integer.toString(TodoDaoHelper.STATUS_END)) .execute(); for (Todo todo : ended) { todo.setStatus(TodoDaoHelper.STATUS_ARCHIVE); todo.save(); } ActiveAndroid.setTransactionSuccessful(); } finally { ActiveAndroid.endTransaction(); } // 画面更新 if (mTodoFragment != null) { mTodoFragment.reload(); } if (mHistoryFragment != null) { mHistoryFragment.reload(); } return true; }
Example #19
Source File: JoH.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static void clearCache() { try { ActiveAndroid.clearCache(); } catch (Exception e) { Log.e(TAG, "Error clearing active android cache: " + e); } }
Example #20
Source File: Sensor.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static void DeleteAndInitDb(Context context) {//KS Configuration dbConfiguration = new Configuration.Builder(context).create(); try { ActiveAndroid.dispose(); context.deleteDatabase("DexDrip.db"); //ActiveAndroid.initialize(dbConfiguration); Log.d("wearSENSOR", "DeleteAndInitDb DexDrip.db deleted and initialized."); } catch (Exception e) { Log.e("wearSENSOR", "DeleteAndInitDb CATCH Error."); } }
Example #21
Source File: JoH.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static void clearCache() { try { ActiveAndroid.clearCache(); } catch (Exception e) { Log.e(TAG, "Error clearing active android cache: " + e); } }
Example #22
Source File: CacheTest.java From clear-todolist with GNU General Public License v3.0 | 5 votes |
@Override protected void setUp() { Configuration conf = new Configuration.Builder(getContext()) .setDatabaseName("CacheTest") .addModelClasses(CacheTestModel.class, CacheTestModel2.class) .create(); ActiveAndroid.initialize(conf, true); }
Example #23
Source File: InsertTest.java From AirData with MIT License | 5 votes |
public void testActiveAndroidBulkInsertWithTransaction() { ActiveAndroid.initialize(getContext()); ActiveAndroid.beginTransaction(); for (int i = 0; i < 10000; i++) { Student2 stu = new Student2(); stu.setMark((char) (i % 24 + 64)); stu.setName("name" + i); stu.setScore(i); stu.save(); } ActiveAndroid.setTransactionSuccessful(); ActiveAndroid.endTransaction(); }
Example #24
Source File: InsertTest.java From AirData with MIT License | 5 votes |
public void testActiveAndroidSelect(){ ActiveAndroid.initialize(getContext()); // List<Model> list = new com.activeandroid.query.Select().from(Student2.class).execute(); List<Model> list = new com.activeandroid.query.Select().from(Student2.class).limit("0, 100000").execute(); // List<Student2> list = new com.activeandroid.query.Select().from(Student2.class).where("Score > ? and Score < 50000", "1000").limit("1000, 100").execute(); // assertEquals(list.size(), new com.activeandroid.query.Select().from(Student2.class).count()); }
Example #25
Source File: PerfTestActiveAndroid.java From android-database-performance with Apache License 2.0 | 5 votes |
@Override public void tearDown() throws Exception { if (Cache.isInitialized()) { ActiveAndroid.dispose(); } getTargetContext().deleteDatabase(DATABASE_NAME); super.tearDown(); }
Example #26
Source File: PerfTestActiveAndroid.java From android-database-performance with Apache License 2.0 | 5 votes |
@Override protected void doIndexedStringEntityQueries() throws Exception { // set up database Configuration dbConfiguration = new Configuration.Builder(getTargetContext()) .setDatabaseName(DATABASE_NAME) .addModelClass(IndexedStringEntity.class) .create(); ActiveAndroid.initialize(dbConfiguration); log("Set up database."); for (int i = 0; i < RUNS; i++) { log("----Run " + (i + 1) + " of " + RUNS); indexedStringEntityQueriesRun(getBatchSize()); } }
Example #27
Source File: PerfTestActiveAndroid.java From android-database-performance with Apache License 2.0 | 5 votes |
@Override protected void onRunSetup() throws Exception { super.onRunSetup(); // set up database Configuration dbConfiguration = new Configuration.Builder(getTargetContext()) .setDatabaseName(DATABASE_NAME) .addModelClass(SimpleEntityNotNull.class) .create(); ActiveAndroid.initialize(dbConfiguration); }
Example #28
Source File: AATest.java From Storm with Apache License 2.0 | 5 votes |
@Override protected void insert(List<AAObject> list) { ActiveAndroid.beginTransaction(); try { for (AAObject aaObject: list) { aaObject.save(); } ActiveAndroid.setTransactionSuccessful(); } finally { ActiveAndroid.endTransaction(); } }
Example #29
Source File: Application.java From mobile-android-survey-app with MIT License | 5 votes |
@Override public void deleteDatabase() { Log.i(this, "deleteDatabase"); Prefs.clear(); deleteDatabase(getManifest("AA_DB_NAME")); ActiveAndroid.clearCache(); ActiveAndroid.dispose(); ActiveAndroid.initialize(this); HttpQueue.getInstance().cancel(); HttpQueue.getInstance().clear(); }
Example #30
Source File: JoH.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static void fullDatabaseReset() { try { clearCache(); ActiveAndroid.dispose(); ActiveAndroid.initialize(xdrip.getAppContext()); } catch (Exception e) { Log.e(TAG,"Error restarting active android db"); } }