当前位置: 首页>>代码示例>>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;未经允许,请勿转载。