本文整理匯總了Java中com.activeandroid.ActiveAndroid.setTransactionSuccessful方法的典型用法代碼示例。如果您正苦於以下問題:Java ActiveAndroid.setTransactionSuccessful方法的具體用法?Java ActiveAndroid.setTransactionSuccessful怎麽用?Java ActiveAndroid.setTransactionSuccessful使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.activeandroid.ActiveAndroid
的用法示例。
在下文中一共展示了ActiveAndroid.setTransactionSuccessful方法的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: installSitePackage
import com.activeandroid.ActiveAndroid; //導入方法依賴的package包/類
private void installSitePackage(String packageName) {
Timber.v("site package installing %s", packageName);
long now = System.currentTimeMillis();
List<Site> sites = sitesLoader.installSitePackage(packageName);
Timber.v("package contains %d sites", sites.size());
ActiveAndroid.beginTransaction();
try {
for (Site site : sites) {
site.save();
}
ActiveAndroid.setTransactionSuccessful();
} finally {
ActiveAndroid.endTransaction();
}
Timber.v("site package installed %s in %d", packageName, System.currentTimeMillis() - now);
}
示例6: deleteAuditObject
import com.activeandroid.ActiveAndroid; //導入方法依賴的package包/類
@Override
public void deleteAuditObject(AuditObject auditObject) {
Timber.v("auditObject delete : %d", auditObject.getId());
ActiveAndroid.beginTransaction();
try {
deleteAllComments(auditObject.getComments());
updateModificationDate(auditObject.getAudit());
Model.delete(AuditObject.class, auditObject.getId());
ActiveAndroid.setTransactionSuccessful();
} finally {
ActiveAndroid.endTransaction();
}
Timber.v("auditObject deleted");
}
示例7: 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);
}
示例8: 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);
}
示例9: 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();
}
示例10: 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();
}
}
}
示例11: 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;
}
示例12: syncMembers
import com.activeandroid.ActiveAndroid; //導入方法依賴的package包/類
public boolean syncMembers(String courseid) {
RestMembers mrmembers = new RestMembers(token);
members = mrmembers.getMembers(courseid); // gets a list of members from api call
if (members == null) return false;
if (members.size() == 0) return false;
ActiveAndroid.beginTransaction();
try {
deleteStaleData();
for (int i = 0; i < members.size(); i++) {
final Member member = members.get(i);
member.setCourseid(courseid);
Member.findOrCreateFromJson(member); // saves contact to database
}
ActiveAndroid.setTransactionSuccessful();
}finally {
ActiveAndroid.endTransaction();
}
return true;
}
示例13: syncCourses
import com.activeandroid.ActiveAndroid; //導入方法依賴的package包/類
public boolean syncCourses(String userid) {
RestCourse mcourse = new RestCourse(token);
courses = mcourse.getCourses(userid); // gets a list of courses from api call
//check if there are no courses
if (courses == null)
return false;
if (courses.size() == 0)
return false;
ActiveAndroid.beginTransaction();
try {
deleteStaleData();
for (int i = 0; i < courses.size(); i++) {
final Course course = courses.get(i);
Course.findOrCreateFromJson(course); // saves contact to database
}
ActiveAndroid.setTransactionSuccessful();
}finally {
ActiveAndroid.endTransaction();
}
return true;
}
示例14: syncDiscussions
import com.activeandroid.ActiveAndroid; //導入方法依賴的package包/類
public boolean syncDiscussions(ArrayList<String> forumids) {
RestDiscussion mrdiscuss = new RestDiscussion(token);
discussions = mrdiscuss.getDiscussions(forumids); // get discussions from api call
List<Discussion> notifDiscussions = new ArrayList<>();
// check if there are no discussions
if (discussions == null)
return false;
if (discussions.size() == 0)
return false;
ActiveAndroid.beginTransaction();
try {
deleteStaleData();
for (int i = 0; i < discussions.size(); i++) {
final Discussion discussion = discussions.get(i);
if(Discussion.findOrCreateFromJson(discussion)==0)
{
notifDiscussions.add(discussion);
} // saves contact to database
}
ActiveAndroid.setTransactionSuccessful();
}finally {
ActiveAndroid.endTransaction();
}
if(notifDiscussions.size() >0)
{
notifyDiscussions(notifDiscussions);
}
return true;
}
示例15: syncForums
import com.activeandroid.ActiveAndroid; //導入方法依賴的package包/類
public boolean syncForums(ArrayList<String> courseids){
RestForum mrforum = new RestForum(token);
forums = mrforum.getForums(courseids); // gets forums from api call
if (forums == null) // if there are no forums
return false;
if (forums.size() == 0 )
return false;
ActiveAndroid.beginTransaction();
try {
// deleteStaleData();
for (int i = 0; i < forums.size(); i++) {
final Forum forum = forums.get(i);
Course forumCourse = new Select().from(Course.class).where("courseid = ?",forum.getCourseid()).executeSingle();
if(forumCourse!=null)
{
forum.setCoursename(forumCourse.getShortname());
}
Forum.findOrCreateFromJson(forum); // saves contact to database
}
ActiveAndroid.setTransactionSuccessful();
}finally {
ActiveAndroid.endTransaction();
}
return true;
}