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


Java Model.load方法代碼示例

本文整理匯總了Java中com.activeandroid.Model.load方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.load方法的具體用法?Java Model.load怎麽用?Java Model.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.activeandroid.Model的用法示例。


在下文中一共展示了Model.load方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testEqualsDifferentRows

import com.activeandroid.Model; //導入方法依賴的package包/類
/**
 * Two different rows in a table should not be equal (different ids).
 */	
public void testEqualsDifferentRows() {
	MockModel model1 = new MockModel();
	MockModel model2 = new MockModel();
	MockModel model3;

	model1.save();
	model2.save();
	model3 = Model.load(MockModel.class, model1.getId());

       // Not equal to each other.
	assertFalse(model1.equals(model2));
	assertFalse(model2.equals(model1));

       // Equal to each other when loaded.
	assertTrue(model1.equals(model3));
	assertTrue(model1.equals(model3));

       // Loaded model is not equal to a different model.
	assertFalse(model3.equals(model2));
	assertFalse(model2.equals(model3));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:ModelTest.java

示例2: testHashCodeDifferentRows

import com.activeandroid.Model; //導入方法依賴的package包/類
/**
 * Two rows in a table should have different hashcodes.
 */
public void testHashCodeDifferentRows() {
	Set<Model> set = new HashSet<Model>();
	Model m1 = new MockModel();
	Model m2 = new MockModel();
	Model m3;

	m1.save();
	m2.save();
	m3 = Model.load(MockModel.class, m1.getId());

	assertEquals(m1.hashCode(), m3.hashCode());
	assertFalse(m1.hashCode() == m2.hashCode());
	set.add(m1);
	set.add(m2);
	set.add(m3);
	assertEquals(2, set.size());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:ModelTest.java

示例3: getSite

import com.activeandroid.Model; //導入方法依賴的package包/類
@Override
public Site getSite(Long siteId) {
    Timber.v("site retrieve : %d", siteId);

    Site site = Model.load(Site.class, siteId);

    Timber.v("site retrieved : %s", site);
    return site;
}
 
開發者ID:Orange-OpenSource,項目名稱:ocara,代碼行數:10,代碼來源:ModelManagerImpl.java

示例4: getAudit

import com.activeandroid.Model; //導入方法依賴的package包/類
@Override
public Audit getAudit(Long auditId) {
    Timber.v("audit retrieve : %d", auditId);

    Audit audit = Model.load(Audit.class, auditId);
    updateAuditRuleSet(audit);

    Timber.v("audit retrieved : %s", audit);
    return audit;
}
 
開發者ID:Orange-OpenSource,項目名稱:ocara,代碼行數:11,代碼來源:ModelManagerImpl.java

示例5: getAuditObject

import com.activeandroid.Model; //導入方法依賴的package包/類
@Override
public AuditObject getAuditObject(Long auditObjectId) {
    Timber.v("auditObject retrieve : %d", auditObjectId);

    AuditObject auditObject = Model.load(AuditObject.class, auditObjectId);
    updateAuditRuleSet(auditObject.getAudit());

    Timber.v("auditObject retrieved : %s", auditObjectId);
    return auditObject;
}
 
開發者ID:Orange-OpenSource,項目名稱:ocara,代碼行數:11,代碼來源:ModelManagerImpl.java

示例6: onCreate

import com.activeandroid.Model; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (isNewComment()) {
        this.comment = new Comment(commentType, "");
    } else {
        this.comment = Model.load(Comment.class, commentId);
    }

}
 
開發者ID:Orange-OpenSource,項目名稱:ocara,代碼行數:12,代碼來源:EditCommentActivity.java

示例7: loadOrCreateSurvey

import com.activeandroid.Model; //導入方法依賴的package包/類
public void loadOrCreateSurvey() {
    Long surveyId = getActivity().getIntent().getLongExtra(EXTRA_SURVEY_ID, -1);
    if (surveyId == -1) {
        mSurvey = new Survey();
        mSurvey.setInstrumentRemoteId(mInstrument.getRemoteId());
        mSurvey.setMetadata(mMetadata);
        mSurvey.setProjectId(mInstrument.getProjectId());
        mSurvey.setLanguage(Instrument.getDeviceLanguage());
        mSurvey.save();
    } else {
        mSurvey = Model.load(Survey.class, surveyId);
    }
}
 
開發者ID:DukeMobileTech,項目名稱:AndroidSurvey,代碼行數:14,代碼來源:SurveyFragment.java

示例8: onCreate

import com.activeandroid.Model; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    long sectionId = getActivity().getIntent().getExtras().getLong(SurveyFragment.EXTRA_SECTION_ID);
    long surveyId = getActivity().getIntent().getExtras().getLong(SurveyFragment.EXTRA_SURVEY_ID);
    mSection = Section.findByRemoteId(sectionId);
    mSurvey = Model.load(Survey.class, surveyId);
    getActivity().setTitle(mSection.getTitle());
}
 
開發者ID:DukeMobileTech,項目名稱:AndroidSurvey,代碼行數:10,代碼來源:SectionFragment.java

示例9: init

import com.activeandroid.Model; //導入方法依賴的package包/類
@Override
public void init() {
	long surveyId = getArguments().getLong(EXTRA_SURVEY_ID);
	if (surveyId != -1) {
		mSurvey = Model.load(Survey.class, surveyId);
           mQuestions = new ArrayList<>();
	}
}
 
開發者ID:DukeMobileTech,項目名稱:AndroidSurvey,代碼行數:9,代碼來源:GridFragment.java

示例10: onCreate

import com.activeandroid.Model; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Long scoreId = getActivity().getIntent().getLongExtra(EXTRA_SCORE_ID, -1);
    if (scoreId == -1) return;
    mScore = Model.load(Score.class, scoreId);
    setListAdapter(new ScoreUnitAdapter((ArrayList<ScoreUnit>) mScore.getScoreScheme()
            .scoreUnits()));
    getActivity().setTitle(mScore.getSurveyIdentifier());
}
 
開發者ID:DukeMobileTech,項目名稱:AndroidSurvey,代碼行數:11,代碼來源:ScoreUnitFragment.java

示例11: updateComment

import com.activeandroid.Model; //導入方法依賴的package包/類
@Background(serial = "serial")
void updateComment(Long commentId) {
    Comment comment = Model.load(Comment.class, commentId);
    entity.attachComment(comment);
    comment.save();
}
 
開發者ID:Orange-OpenSource,項目名稱:ocara,代碼行數:7,代碼來源:ListCommentActivity.java

示例12: run

import com.activeandroid.Model; //導入方法依賴的package包/類
@Override
public void run() throws Exception {
    ToastEvent.toast("Downloading event teams...",true);
    Event event = Model.load(Event.class,prefs.getComp());
    Timber.d("year: " + prefs.getYear());
    Timber.d( "Setting up teams");
    ActiveAndroid.beginTransaction();
    try {
        int year = prefs.getYear();
        List<Team> teams = TheBlueAlliance.getService().getEventTeams(year + event.getEventCode());
        List<EventTeam> ranks = new Select().from(EventTeam.class).where(EventTeam.EVENT + "=?", event.getId()).orderBy(EventTeam.RANK + " DESC").execute();
        int nextRank = 0;
        if(!ranks.isEmpty()) {
            nextRank = ranks.get(0).getRank()+1;
        }
        Collections.sort(teams);
        for(int teamRank=0;teamRank<teams.size();teamRank++) {
            EventTeam eventTeam = new EventTeam();
            eventTeam.setEvent(event);
            eventTeam.setTeam(teams.get(teamRank));
            eventTeam.setRank(nextRank);
            eventTeam.saveMod();
            if(-1!=eventTeam.getId()) {
                nextRank++;
            }
        }
        ActiveAndroid.setTransactionSuccessful();
        if(!teams.isEmpty()) {
            EventBus.getDefault().post(new Team());
            EventBus.getDefault().post(new EventTeam());
        }
        ToastEvent.toast("Finished downloading teams",false);
        prefs.setEventTeamsDownloaded(true);
    } catch (RetrofitError e) {
        Timber.e(e,"Error downloading event teams");
        if (e.getKind() == RetrofitError.Kind.NETWORK) {
            ToastEvent.toast("Unable to connect");
        } else if (e.getResponse().getStatus() != 200) {
            ToastEvent.toast("Error " + e.getResponse().getStatus() + " connecting");
        }
    } finally {
        ActiveAndroid.endTransaction();
    }
}
 
開發者ID:mechinn,項目名稱:our-alliance-android,代碼行數:45,代碼來源:GetEventTeams.java

示例13: run

import com.activeandroid.Model; //導入方法依賴的package包/類
public void run() throws IOException {
    Event event = Model.load(Event.class, getPrefs().getComp());
    setFileName(event.getEventCode());
    setTitle("Send match scouting csv for: "+event.getDisplayName());
    super.run();
}
 
開發者ID:mechinn,項目名稱:our-alliance-android,代碼行數:7,代碼來源:ExportCsvMatchScouting.java

示例14: run

import com.activeandroid.Model; //導入方法依賴的package包/類
public void run() throws IOException {
    Event event = Model.load(Event.class,getPrefs().getComp());
    setFileName(event.getEventCode());
    setTitle("Send team scouting csv for: "+event.getDisplayName());
    super.run();
}
 
開發者ID:mechinn,項目名稱:our-alliance-android,代碼行數:7,代碼來源:ExportCsvTeamScouting.java

示例15: loadModel

import com.activeandroid.Model; //導入方法依賴的package包/類
/**
 * Loads specified model from database and wraps the validating layer around it.
 *
 * @param <T>
 *					subclass of Model
 * @param modelClass
 *					model class
 * @param id
 *					id of the model to fetch
 * @return wrapped model
 */
public static <T extends Model> IModelSupport<T> loadModel(final Class<T> modelClass, final Long id) {
	T model = Model.load(modelClass, id);
	return model == null ? null : wrapModel(model);
}
 
開發者ID:vsigler,項目名稱:ActiveAndroid-Validation,代碼行數:16,代碼來源:ModelSupportFactory.java


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