當前位置: 首頁>>代碼示例>>Java>>正文


Java ActiveAndroid類代碼示例

本文整理匯總了Java中com.activeandroid.ActiveAndroid的典型用法代碼示例。如果您正苦於以下問題:Java ActiveAndroid類的具體用法?Java ActiveAndroid怎麽用?Java ActiveAndroid使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ActiveAndroid類屬於com.activeandroid包,在下文中一共展示了ActiveAndroid類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@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());
}
 
開發者ID:symph-team,項目名稱:mobile-android-survey-app,代碼行數:20,代碼來源:Application.java

示例2: onCreate

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@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;
}
 
開發者ID:symph-team,項目名稱:mobile-android-survey-app,代碼行數:24,代碼來源:ContentProvider.java

示例3: postExecute

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@Override
public void postExecute(JSONObject response, Bundle result) throws JSONException {
    JSONObject data = response.getJSONObject("data");
    int entityId = data.getInt("entity_id");
    int likesCount = data.getInt("likes_count");
    boolean voted = data.has("voted") ? data.getBoolean("voted") : true;

    ActiveAndroid.beginTransaction();
    try {
        QuestionEntry entry = QuestionEntry.byQId(entityId);
        entry.likesCount = likesCount;
        entry.voted = voted;
        entry.save();
        ActiveAndroid.setTransactionSuccessful();
    } finally {
        ActiveAndroid.endTransaction();
    }

    result.putInt(ServiceCallback.EntityVoteExtras.ENTITY_ID, entityId);
    result.putInt(ServiceCallback.EntityVoteExtras.VOTES_COUNT, likesCount);
}
 
開發者ID:tech-team,項目名稱:decider-android,代碼行數:22,代碼來源:QuestionLikeProcessor.java

示例4: postExecute

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@Override
public void postExecute(JSONObject response, Bundle result) throws JSONException {
    JSONObject data = response.getJSONObject("data");
    JSONObject userJson = data.getJSONObject("user");

    String uid = null;
    String username = null;

    ActiveAndroid.beginTransaction();
    try {
        UserEntry entry = UserEntry.fromJson(userJson);
        entry.save();
        ActiveAndroid.setTransactionSuccessful();

        uid = entry.getUid();
        username = entry.getUsername();
    } finally {
        ActiveAndroid.endTransaction();
    }

    result.putString(ServiceCallback.LoginRegisterExtras.USERNAME, username);
    result.putString(ServiceCallback.LoginRegisterExtras.TOKEN, apiUI.extractToken(data));
    result.putLong(ServiceCallback.LoginRegisterExtras.EXPIRES, System.currentTimeMillis() + apiUI.extractTokenExpires(data) * 1000);
    result.putString(ServiceCallback.LoginRegisterExtras.REFRESH_TOKEN, apiUI.extractRefreshToken(data));
    result.putString(ServiceCallback.LoginRegisterExtras.USER_ID, uid);
}
 
開發者ID:tech-team,項目名稱:decider-android,代碼行數:27,代碼來源:LoginRegisterProcessor.java

示例5: onCreate

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    //initialize a database and the Crashlitics
    ActiveAndroid.initialize(this);
    Fabric.with(this, new Crashlytics());

    //The first time you need create file with key: "redmine_key.json"
    // file must have next values:
    // { "key": "5d263a7acadb85301873a17a58" }
    String key = Utility.getInstance().loadKey(getApplicationContext());

    //save the key to the database
    AppSettings.setKey(key);

    //init Calls
    Calls.getInstance();
    Calls.setContext(getApplicationContext());

    // Start alarm
    AlarmReceiver.schedule(getApplicationContext());
}
 
開發者ID:andrewgrow,項目名稱:Redmine-Notifications,代碼行數:24,代碼來源:StartApp.java

示例6: InitDb

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
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()");
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:17,代碼來源:Sensor.java

示例7: onCreate

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
public void onCreate() {
    super.onCreate();

    Iconify.with(new FontAwesomeModule());
    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
            .setDefaultFontPath("fonts/bariol_regular-webfont.ttf")
            .setFontAttrId(R.attr.fontPath)
            .build());

    Configuration dbConfiguration = new Configuration.Builder(this)
            .setDatabaseName("storage.db")
            .addModelClass(NewsModel.class)
            .create();

    ActiveAndroid.initialize(dbConfiguration);
}
 
開發者ID:niranjan94,項目名稱:amrita-info-desk,代碼行數:17,代碼來源:MainApplication.java

示例8: onCreate

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    progress = (ProgressActivity) findViewById(R.id.progress);

    if (BuildConfig.DEBUG)
        ActiveAndroid.setLoggingEnabled(true);
    grapttClient = new GrapttClient(this, getString(R.string.api_url), new GrapttClient.OnConnectListener() {
        @Override
        public void onConnect(String status) {
            Log.d("GrapttClient", status);
        }
        @Override
        public void onError(String message) {
            Log.d("GrapttClient", message);
        }
    });
}
 
開發者ID:c910335,項目名稱:PTR,代碼行數:22,代碼來源:MainActivity.java

示例9: ensureAllFoodsExistInDatabase

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@DebugLog
public static void ensureAllFoodsExistInDatabase(final String[] foodNames,
                                                 final String[] foodIdNames,
                                                 final int[] recommendedServings) {
    ActiveAndroid.beginTransaction();

    try {
        for (int i = 0; i < foodNames.length; i++) {
            createFoodIfDoesNotExist(foodNames[i], foodIdNames[i], recommendedServings[i]);
        }

        ActiveAndroid.setTransactionSuccessful();
    } finally {
        ActiveAndroid.endTransaction();
    }
}
 
開發者ID:nutritionfactsorg,項目名稱:daily-dozen-android,代碼行數:17,代碼來源:Food.java

示例10: createServingsForDay

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@DebugLog
private void createServingsForDay(List<Food> allFoods, DateTime current) {
    ActiveAndroid.beginTransaction();

    try {
        final Day day = new Day(current);
        day.save();

        for (Food food : allFoods) {
            final int recommendedServings = food.getRecommendedServings();
            final int numServings = taskParams.generateRandomData() ? random.nextInt(recommendedServings + 1) : recommendedServings;

            if (numServings > 0) {
                Servings.createServingsIfDoesNotExist(day, food, numServings);
            }
        }

        ActiveAndroid.setTransactionSuccessful();
    } finally {
        ActiveAndroid.endTransaction();
    }
}
 
開發者ID:nutritionfactsorg,項目名稱:daily-dozen-android,代碼行數:23,代碼來源:GenerateDataTask.java

示例11: doInBackground

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@Override
protected Void doInBackground(Void... params) {
    // Moves the current Thread into the background
    android.os.Process.setThreadPriority(
            android.os.Process.THREAD_PRIORITY_BACKGROUND);
    // save the ingredient list
    ActiveAndroid.beginTransaction();
    try {
        for (IngredientHelper ingredient : ingredientHelpers) {
            new Ingredient(Integer.parseInt(ingredient.getId()),
                    ingredient.getNaziv()).save();
        }
        ActiveAndroid.setTransactionSuccessful();
    } finally {
        ActiveAndroid.endTransaction();
        EventBus.getDefault().post(new IngredientsEvent("success"));
    }
    return null;
}
 
開發者ID:Drakuwa,項目名稱:Fridge,代碼行數:20,代碼來源:FirstTimeWizardActivity.java

示例12: testAddressItems

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
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();
}
 
開發者ID:Raizlabs,項目名稱:AndroidDatabaseLibraryComparison,代碼行數:24,代碼來源:AATester.java

示例13: onCreate

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@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();
}
 
開發者ID:Raizlabs,項目名稱:AndroidDatabaseLibraryComparison,代碼行數:26,代碼來源:MainApplication.java

示例14: postExecute

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@Override
public void postExecute(JSONObject response, Bundle result) throws JSONException {
    JSONArray data = response.getJSONArray("data");
    ActiveAndroid.beginTransaction();
    try {
        for (int i = 0; i < data.length(); ++i) {
            CommentEntry entry = CommentEntry.fromJson(data.getJSONObject(i));
            entry.saveTotal();
        }

        QuestionEntry questionEntry = QuestionEntry.byQId(getRequest().getCommentData().getQuestionId());
        questionEntry.commentsCount += data.length();
        questionEntry.save();

        ActiveAndroid.setTransactionSuccessful();

        result.putInt(ServiceCallback.CreateQuestionExtras.COUNT, data.length());

    } finally {
        ActiveAndroid.endTransaction();
    }
}
 
開發者ID:tech-team,項目名稱:decider-android,代碼行數:23,代碼來源:CommentCreateProcessor.java

示例15: postExecute

import com.activeandroid.ActiveAndroid; //導入依賴的package包/類
@Override
public void postExecute(JSONObject response, Bundle result) throws JSONException {
    ActiveAndroid.beginTransaction();
    try {
        JSONArray data = response.getJSONArray("data");
        for (int i = 0; i < data.length(); ++i) {
            JSONObject q = data.getJSONObject(i);
            CategoryEntry entry = CategoryEntry.fromJson(q);
            CategoryEntry dbEntry = CategoryEntry.byUid(entry.getUid());
            if (dbEntry == null || !dbEntry.contentEquals(entry)) {
                entry.setSelected(true);
                entry.save();
            }
        }
        ActiveAndroid.setTransactionSuccessful();

        result.putInt(ServiceCallback.GetCategoriesExtras.COUNT, data.length());
    } finally {
        ActiveAndroid.endTransaction();
    }
}
 
開發者ID:tech-team,項目名稱:decider-android,代碼行數:22,代碼來源:CategoriesGetProcessor.java


注:本文中的com.activeandroid.ActiveAndroid類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。