本文整理汇总了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);
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
}
示例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();
}
}
}
示例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);
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
}
}
示例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;
}