Java Code Examples for org.greenrobot.greendao.query.QueryBuilder#orderDesc()
The following examples show how to use
org.greenrobot.greendao.query.QueryBuilder#orderDesc() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalRepository.java From NovelReader with MIT License | 6 votes |
public Single<List<BookReviewBean>> getBookReviews(String sort, String bookType, int start, int limited, String distillate){ QueryBuilder<BookReviewBean> queryBuilder = mSession.getBookReviewBeanDao() .queryBuilder() .where(BookReviewBeanDao.Properties.State.eq(distillate)) .limit(limited) .offset(start); //多表关联 Join bookJoin = queryBuilder.join(BookReviewBeanDao.Properties.BookId,ReviewBookBean.class) .where(ReviewBookBeanDao.Properties.Type.eq(bookType)); queryBuilder.join(bookJoin,BookReviewBeanDao.Properties._id, BookHelpfulBean.class,BookHelpsBeanDao.Properties._id); //排序 if (sort.equals(BookSort.HELPFUL.getDbName())){ queryBuilder.orderDesc(BookHelpfulBeanDao.Properties.Yes); } else { queryOrderBy(queryBuilder,BookReviewBeanDao.class,sort); } return queryToRx(queryBuilder); }
Example 2
Source File: ReadArticleActivity.java From android-app with GNU General Public License v3.0 | 6 votes |
private Long getAdjacentArticle(boolean previous) { QueryBuilder<Article> qb = articleDao.queryBuilder() .where(ArticleDao.Properties.ArticleId.isNotNull()); if (previous) qb.where(ArticleDao.Properties.ArticleId.gt(article.getArticleId())); else qb.where(ArticleDao.Properties.ArticleId.lt(article.getArticleId())); if (contextFavorites != null) qb.where(ArticleDao.Properties.Favorite.eq(contextFavorites)); if (contextArchived != null) qb.where(ArticleDao.Properties.Archive.eq(contextArchived)); if (previous) qb.orderAsc(ArticleDao.Properties.ArticleId); else qb.orderDesc(ArticleDao.Properties.ArticleId); List<Article> l = qb.limit(1).list(); if (!l.isEmpty()) { return l.get(0).getId(); } return null; }
Example 3
Source File: TagListFragment.java From android-app with GNU General Public License v3.0 | 6 votes |
private QueryBuilder<Tag> getQueryBuilder() { QueryBuilder<Tag> qb = tagDao.queryBuilder(); if (!TextUtils.isEmpty(searchQuery)) { qb.where(TagDao.Properties.Label.like("%" + searchQuery + "%")); } switch (sortOrder) { case ASC: qb.orderAsc(TagDao.Properties.Label); break; case DESC: qb.orderDesc(TagDao.Properties.Label); break; default: throw new IllegalStateException("Sort order not implemented: " + sortOrder); } return qb; }
Example 4
Source File: X8AiLinePointInfoHelper.java From FimiX8-RE with MIT License | 5 votes |
public List<X8AiLinePointInfo> getLastItem(int count, int mapType, boolean isFavorites) { QueryBuilder<X8AiLinePointInfo> qb = this.lineDao.queryBuilder(); if (isFavorites) { WhereCondition where = Properties.MapType.eq(Integer.valueOf(mapType)); WhereCondition where1 = Properties.SaveFlag.eq(Integer.valueOf(1)); qb.where(where, where1).build(); } else { qb.where(Properties.MapType.eq(Integer.valueOf(mapType)), new WhereCondition[0]); } qb.orderDesc(Properties.Id); qb.limit(count); return qb.list(); }
Example 5
Source File: LocalKinoRepository.java From CineLog with GNU General Public License v3.0 | 5 votes |
private List<LocalKino> queryOrderBy(boolean asc, Property property) { QueryBuilder<LocalKino> localKinoQueryBuilder = dao.queryBuilder(); if (asc) { localKinoQueryBuilder = localKinoQueryBuilder .orderAsc(property); } else { localKinoQueryBuilder = localKinoQueryBuilder .orderDesc(property); } return localKinoQueryBuilder.build().list(); }
Example 6
Source File: X8AiLinePointInfoHelper.java From FimiX8-RE with MIT License | 4 votes |
public X8AiLinePointInfo getLineInfoById(long lineId) { QueryBuilder<X8AiLinePointInfo> qb = this.lineDao.queryBuilder(); qb.where(Properties.Id.eq(Long.valueOf(lineId)), new WhereCondition[0]); qb.orderDesc(Properties.Id); return (X8AiLinePointInfo) qb.list().get(0); }
Example 7
Source File: ArticleListFragment.java From android-app with GNU General Public License v3.0 | 4 votes |
private QueryBuilder<Article> getQueryBuilder() { QueryBuilder<Article> qb = articleDao.queryBuilder() .where(ArticleDao.Properties.ArticleId.isNotNull()); if (untagged) { qb.where(new WhereCondition.StringCondition(UNTAGGED_WHERE)); } else if (tagIDs != null && !tagIDs.isEmpty()) { // TODO: try subquery qb.join(ArticleTagsJoin.class, ArticleTagsJoinDao.Properties.ArticleId) .where(ArticleTagsJoinDao.Properties.TagId.in(tagIDs)); } switch (listType) { case LIST_TYPE_ARCHIVED: qb.where(ArticleDao.Properties.Archive.eq(true)); break; case LIST_TYPE_FAVORITES: qb.where(ArticleDao.Properties.Favorite.eq(true)); break; default: qb.where(ArticleDao.Properties.Archive.eq(false)); break; } if (!TextUtils.isEmpty(searchQuery)) { qb.where(new WhereCondition.StringCondition(ArticleDao.Properties.Id.columnName + " IN (" + FtsDao.getQueryString() + DatabaseUtils.sqlEscapeString(searchQuery) + ")")); } switch (sortOrder) { case ASC: qb.orderAsc(ArticleDao.Properties.ArticleId); break; case DESC: qb.orderDesc(ArticleDao.Properties.ArticleId); break; default: throw new IllegalStateException("Sort order not implemented: " + sortOrder); } return qb; }