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


Java Model類代碼示例

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


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

示例1: query

import com.activeandroid.Model; //導入依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
	final Class<? extends Model> type = getModelType(uri);
	final Cursor cursor = Cache.openDatabase().query(
			Cache.getTableName(type),
			projection,
			selection,
			selectionArgs,
			null,
			null,
			sortOrder);

	cursor.setNotificationUri(getContext().getContentResolver(), uri);

	return cursor;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:ContentProvider.java

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

示例3: testHashCode

import com.activeandroid.Model; //導入依賴的package包/類
/**
 * Tests hashcode for new instances.
 */	
public void testHashCode() {
	Set<Model> set = new HashSet<Model>();
	Model m1 = new MockModel();
	Model m2 = new MockModel();
	Model m3 = new AnotherMockModel();

	assertFalse(m1.hashCode() == m2.hashCode()); // hashes for unsaved models must not match
	set.add(m1);
	set.add(m2);
	assertEquals(2, set.size()); //try in a set

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

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

示例5: removeFeedRelativeItems

import com.activeandroid.Model; //導入依賴的package包/類
private void removeFeedRelativeItems() throws ClassNotFoundException {
    // 獲取所有緩存的Feed
    List<FeedItem> cacheFeedItems = new Select().from(FeedItem.class)
            .where("category='NORMAL'").execute();

    Class<? extends Model> feedLikeClass = refectModelClz("com.umeng.comm.core.beans.relation.FeedLike");
    Class<? extends Model> feedCommentClass = refectModelClz("com.umeng.comm.core.beans.relation.FeedComment");
    Class<? extends Model> feedTopicClass = refectModelClz("com.umeng.comm.core.beans.relation.FeedTopic");
    Class<? extends Model> feedCreatorClass = refectModelClz("com.umeng.comm.core.beans.relation.FeedCreator");
    Class<? extends Model> feedFriendClass = refectModelClz("com.umeng.comm.core.beans.relation.FeedFriends");

    for (FeedItem feedItem : cacheFeedItems) {
        // 移除like相關
        removeRelativeLike(feedItem.id, feedLikeClass);
        // 移除Feed相關的Comment
        removeRelativeComment(feedItem.id, feedCommentClass);
        new Delete().from(feedTopicClass).where("feed_id=?", feedItem.id)
                .execute();
        new Delete().from(feedCreatorClass).where("feed_id=?", feedItem.id)
                .execute();
        new Delete().from(feedFriendClass).where("feed_id=?", feedItem.id)
                .execute();
    }
}
 
開發者ID:umeng,項目名稱:umeng_community_android,代碼行數:25,代碼來源:FeedDBAPIImpl.java

示例6: deleteAuditObject

import com.activeandroid.Model; //導入依賴的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: deleteComment

import com.activeandroid.Model; //導入依賴的package包/類
@Override
public void deleteComment(Comment comment) {
    Timber.v("comment delete : %d", comment.getId());

    String attachment = comment.getAttachment();

    if (StringUtils.isNotBlank(attachment)) {
        File attachementFile = new File(attachment);
        FileUtils.deleteQuietly(attachementFile);
    }
    Audit audit = comment.getAudit();

    updateModificationDate(audit);
    Model.delete(Comment.class, comment.getId());

    Timber.v("comment deleted");
}
 
開發者ID:Orange-OpenSource,項目名稱:ocara,代碼行數:18,代碼來源:ModelManagerImpl.java

示例8: loadMatchScouting

import com.activeandroid.Model; //導入依賴的package包/類
public void loadMatchScouting() {
    AsyncExecutor.create().execute(new AsyncExecutor.RunnableEx() {
        @Override
        public void run() throws Exception {
            if (getScoutingId() != 0) {
                MatchScouting2015 scouting = Model.load(MatchScouting2015.class, getScoutingId());
                if(null!=scouting) {
                    EventBus.getDefault().post(new LoadMatchScouting(scouting));
                } else {
                    Timber.d("match scouting null " + getScoutingId());
                }
            } else {
                Timber.d("match scouting id 0 == "+getScoutingId());
            }
        }
    });
}
 
開發者ID:mechinn,項目名稱:our-alliance-android,代碼行數:18,代碼來源:MatchDetail2015.java

示例9: loadScouting

import com.activeandroid.Model; //導入依賴的package包/類
public void loadScouting() {
    AsyncExecutor.create().execute(new AsyncExecutor.RunnableEx() {
        @Override
        public void run() throws Exception {
            TeamScouting2014 scouting = null;
            int year = getPrefs().getYear();
            try {
                scouting = new Select().from(TeamScouting2014.class).where(TeamScouting2014.TEAM+"=?", getTeamId()).executeSingle();
            } catch(NullPointerException e) {
                Team team = Model.load(Team.class, getTeamId());
                scouting = (TeamScouting2014) new TeamScouting2014();
                scouting.setTeam(team);
            }
            if(null!=scouting) {
                EventBus.getDefault().post(new LoadScouting(scouting));
            }
        }
    });
}
 
開發者ID:mechinn,項目名稱:our-alliance-android,代碼行數:20,代碼來源:TeamDetail2014.java

示例10: loadMatchScouting

import com.activeandroid.Model; //導入依賴的package包/類
public void loadMatchScouting() {
    AsyncExecutor.create().execute(new AsyncExecutor.RunnableEx() {
        @Override
        public void run() throws Exception {
            if (getScoutingId() != 0) {
                MatchScouting2014 scouting = Model.load(MatchScouting2014.class, getScoutingId());
                if(null!=scouting) {
                    EventBus.getDefault().post(new LoadMatchScouting(scouting));
                } else {
                    Timber.d("match scouting null " + getScoutingId());
                }
            } else {
                Timber.d("match scouting id 0 == "+getScoutingId());
            }
        }
    });
}
 
開發者ID:mechinn,項目名稱:our-alliance-android,代碼行數:18,代碼來源:MatchDetail2014.java

示例11: isValid

import com.activeandroid.Model; //導入依賴的package包/類
/**
 * {@inheritDoc }
 */
@Override
public boolean isValid(IValueDescriptor<Object> value) {
	Model model = value.getModel();

	From from = new Select().from(model.getClass());
	Model existing;

	if (value.getValue() == null) {
		existing = from.where(value.getColumnName() + " IS NULL").executeSingle();
	} else {
		existing = from.where(value.getColumnName() + " = ?", value.getValue()).executeSingle();
	}

	return existing == null || existing.getId().equals(value.getModel().getId());
}
 
開發者ID:vsigler,項目名稱:ActiveAndroid-Validation,代碼行數:19,代碼來源:UniqueValidator.java

示例12: From

import com.activeandroid.Model; //導入依賴的package包/類
public From(Class<? extends Model> table, Sqlable queryBase) {
	mType = table;
	mJoins = new ArrayList<Join>();
	mQueryBase = queryBase;

	mJoins = new ArrayList<Join>();
	mArguments = new ArrayList<Object>();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:From.java

示例13: execute

import com.activeandroid.Model; //導入依賴的package包/類
public <T extends Model> List<T> execute() {
	if (mQueryBase instanceof Select) {
		return SQLiteUtils.rawQuery(mType, toSql(), getArguments());
		
	} else {
		SQLiteUtils.execSql(toSql(), getArguments());
		Cache.getContext().getContentResolver().notifyChange(ContentProvider.createUri(mType, null), null);
		return null;
		
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:From.java

示例14: executeSingle

import com.activeandroid.Model; //導入依賴的package包/類
public <T extends Model> T executeSingle() {
	if (mQueryBase instanceof Select) {
		limit(1);
		return (T) SQLiteUtils.rawQuerySingle(mType, toSql(), getArguments());
		
	} else {
		limit(1);
		SQLiteUtils.rawQuerySingle(mType, toSql(), getArguments()).delete();
		return null;
		
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:From.java

示例15: getType

import com.activeandroid.Model; //導入依賴的package包/類
@Override
public String getType(Uri uri) {
	final int match = URI_MATCHER.match(uri);

	String cachedMimeType = sMimeTypeCache.get(match);
	if (cachedMimeType != null) {
		return cachedMimeType;
	}

	final Class<? extends Model> type = getModelType(uri);
	final boolean single = ((match % 2) == 0);

	StringBuilder mimeType = new StringBuilder();
	mimeType.append("vnd");
	mimeType.append(".");
	mimeType.append(sAuthority);
	mimeType.append(".");
	mimeType.append(single ? "item" : "dir");
	mimeType.append("/");
	mimeType.append("vnd");
	mimeType.append(".");
	mimeType.append(sAuthority);
	mimeType.append(".");
	mimeType.append(Cache.getTableName(type));

	sMimeTypeCache.append(match, mimeType.toString());

	return mimeType.toString();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:30,代碼來源:ContentProvider.java


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