当前位置: 首页>>代码示例>>Java>>正文


Java ActiveAndroid.endTransaction方法代码示例

本文整理汇总了Java中com.activeandroid.ActiveAndroid.endTransaction方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveAndroid.endTransaction方法的具体用法?Java ActiveAndroid.endTransaction怎么用?Java ActiveAndroid.endTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.activeandroid.ActiveAndroid的用法示例。


在下文中一共展示了ActiveAndroid.endTransaction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: deleteAllComments

import com.activeandroid.ActiveAndroid; //导入方法依赖的package包/类
@Override
public void deleteAllComments(List<Comment> comments) {
    Timber.v("deleting all comments");
    long now = System.currentTimeMillis();

    ActiveAndroid.beginTransaction();

    try {
        for (Comment comment : comments) {
            deleteComment(comment);
        }

        ActiveAndroid.setTransactionSuccessful();
    } finally {
        ActiveAndroid.endTransaction();
    }

    Timber.v("deleting all comments done in %d", System.currentTimeMillis() - now);
}
 
开发者ID:Orange-OpenSource,项目名称:ocara,代码行数:20,代码来源:ModelManagerImpl.java

示例6: refresh

import com.activeandroid.ActiveAndroid; //导入方法依赖的package包/类
@Override
public void refresh(Refreshable entity, RefreshStrategy strategy) {
    Timber.v("refresh entity %s with strategy : %s", entity, strategy);
    long now = System.currentTimeMillis();

    ActiveAndroid.beginTransaction();

    try {
        entity.refresh(strategy);
        ActiveAndroid.setTransactionSuccessful();
    } finally {
        ActiveAndroid.endTransaction();
    }

    Timber.v("refresh entity %s done in %d", entity, System.currentTimeMillis() - now);
}
 
开发者ID:Orange-OpenSource,项目名称:ocara,代码行数:17,代码来源:ModelManagerImpl.java

示例7: 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

示例8: run

import com.activeandroid.ActiveAndroid; //导入方法依赖的package包/类
@Override
public void run() {
    if(null!=objects && objects.size()>0) {
        ActiveAndroid.beginTransaction();
        try {
            for (OurAllianceObject object : objects) {
                if (delete) {
                    object.delete();
                } else {
                    object.saveMod();
                }
            }
            ActiveAndroid.setTransactionSuccessful();
            EventBus.getDefault().post(type.cast(objects.get(0)));
        } finally {
            ActiveAndroid.endTransaction();
        }
    }
}
 
开发者ID:mechinn,项目名称:our-alliance-android,代码行数:20,代码来源:Transaction.java

示例9: postExecute

import com.activeandroid.ActiveAndroid; //导入方法依赖的package包/类
@Override
public void postExecute(JSONObject response, Bundle result) throws JSONException {
    JSONObject data = response.getJSONObject("data");
    String uid = data.getString("uid");

    ActiveAndroid.beginTransaction();
    try {
        UploadedImageEntry entry = new UploadedImageEntry(uid, getRequest().getImageOrdinalId());
        entry.save();
        ActiveAndroid.setTransactionSuccessful();

    } finally {
        ActiveAndroid.endTransaction();
    }

    result.putString(ServiceCallback.ImageUploadExtras.UID, uid);
}
 
开发者ID:tech-team,项目名称:decider-android,代码行数:18,代码来源:ImageUploadProcessor.java

示例10: createAuditObject

import com.activeandroid.ActiveAndroid; //导入方法依赖的package包/类
private AuditObject createAuditObject(AuditObject auditObject) {
    Timber.v("auditObject creating");
    long now = System.currentTimeMillis();

    ActiveAndroid.beginTransaction();
    try {
        auditObject.save();
        computeAllQuestionAnswers(auditObject);
        updateModificationDate(auditObject.getAudit());

        ActiveAndroid.setTransactionSuccessful();
    } finally {
        ActiveAndroid.endTransaction();
    }

    Timber.v("auditObject created : %d in %d", auditObject.getId(), System.currentTimeMillis() - now);
    return auditObject;
}
 
开发者ID:Orange-OpenSource,项目名称:ocara,代码行数:19,代码来源:ModelManagerImpl.java

示例11: 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

示例12: onSaveButtonClick

import com.activeandroid.ActiveAndroid; //导入方法依赖的package包/类
@OnClick(R.id.setup_macroSavebtn)
public void onSaveButtonClick(View view) {
    if (startPlace == null) {
        Toast.makeText(this, R.string.error_start_point_invalid, Toast.LENGTH_LONG).show();
    } else {
        ActiveAndroid.beginTransaction();
        try {
            route.setName(routeNameEditText.getText().toString().trim());
            route.setStart(startPlace);
            route.setEnd(endPlace);

            ActiveAndroid.setTransactionSuccessful();
        } finally {
            ActiveAndroid.endTransaction();
        }

        Intent routeActivityIntent = new Intent(this, RouteActivity.class);
        routeActivityIntent.putExtra(ExtraData.EXTRA_ROUTE, route);
        startActivity(routeActivityIntent);
        Toast.makeText(getApplicationContext(), R.string.route_saved, Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:SenAndAaron,项目名称:voyager2-android,代码行数:23,代码来源:CreateOrEditRouteActivity.java

示例13: logOut

import com.activeandroid.ActiveAndroid; //导入方法依赖的package包/类
public void logOut() {
    mAccessToken = null;
    mAccessSecret = null;
    mUserName = null;
    saveSession();
    //remove saved db and cache items in asynctask
    AsyncTask t = new AsyncTask() {
        @Override
        protected Object doInBackground(Object[] objects) {
            ActiveAndroid.beginTransaction();
            loadCollection();
            for(Release r : collection) r.delete();
            ActiveAndroid.setTransactionSuccessful();
            ActiveAndroid.endTransaction();
            ImageLoader.getInstance().clearDiscCache();
            ImageLoader.getInstance().clearMemoryCache();
            return true;
        }
    };
    t.execute();

}
 
开发者ID:jvanhie,项目名称:discogsscrobbler,代码行数:23,代码来源:Discogs.java

示例14: loadToastersIntoDatabase

import com.activeandroid.ActiveAndroid; //导入方法依赖的package包/类
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();
        }
    }
}
 
开发者ID:twotoasters,项目名称:multi-column-list-adapter,代码行数:19,代码来源:MainActivity.java

示例15: refresh

import com.activeandroid.ActiveAndroid; //导入方法依赖的package包/类
/**
 * Obter a Lista de todas as palestras disponíveis.
 * 
 * @return Lista de Palestras.
 */
public static List<Keynote> refresh() {
	KeynoteService service = ServiceFactory.getKeynoteService();
	List<Keynote> keynotes = service.list(1L);

	ActiveAndroid.beginTransaction();
	new Delete().from(Keynote.class).execute();

	try {
		for (Keynote keynote : keynotes) {
			keynote.save();
		}
		ActiveAndroid.setTransactionSuccessful();
	} finally {
		ActiveAndroid.endTransaction();
	}

	return keynotes;
}
 
开发者ID:exmo,项目名称:GameLivreNFC,代码行数:24,代码来源:Keynote.java


注:本文中的com.activeandroid.ActiveAndroid.endTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。