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


Java ActiveAndroid.setTransactionSuccessful方法代碼示例

本文整理匯總了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);
}
 
開發者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: 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);
}
 
開發者ID:Orange-OpenSource,項目名稱:ocara,代碼行數:22,代碼來源:ModelManagerImpl.java

示例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");
}
 
開發者ID:Orange-OpenSource,項目名稱:ocara,代碼行數:19,代碼來源:ModelManagerImpl.java

示例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);
}
 
開發者ID:Orange-OpenSource,項目名稱:ocara,代碼行數:17,代碼來源:ModelManagerImpl.java

示例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);
}
 
開發者ID:tech-team,項目名稱:decider-android,代碼行數:18,代碼來源:ImageUploadProcessor.java

示例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();

}
 
開發者ID:jvanhie,項目名稱:discogsscrobbler,代碼行數:23,代碼來源:Discogs.java

示例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();
        }
    }
}
 
開發者ID:twotoasters,項目名稱:multi-column-list-adapter,代碼行數:19,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:exmo,項目名稱:GameLivreNFC,代碼行數:24,代碼來源:Keynote.java

示例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;
    }
 
開發者ID:UWICompSociety,項目名稱:OurVLE,代碼行數:28,代碼來源:MemberSync.java

示例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;
    }
 
開發者ID:UWICompSociety,項目名稱:OurVLE,代碼行數:30,代碼來源:CourseSync.java

示例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;
    }
 
開發者ID:UWICompSociety,項目名稱:OurVLE,代碼行數:37,代碼來源:DiscussionSync.java

示例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;
    }
 
開發者ID:UWICompSociety,項目名稱:OurVLE,代碼行數:36,代碼來源:ForumSync.java


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