diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/service/workers/ArticleImagesFetcher.java b/app/src/main/java/fr/gaulupeau/apps/Poche/service/workers/ArticleImagesFetcher.java index 773278ef1..7ba3c4f36 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/service/workers/ArticleImagesFetcher.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/service/workers/ArticleImagesFetcher.java @@ -66,7 +66,7 @@ private void fetchImages(ActionRequest actionRequest) { QueryBuilder
queryBuilder = articleDao.queryBuilder() .where(ArticleDao.Properties.ArticleId.isNotNull()) .where(ArticleDao.Properties.ImagesDownloaded.eq(false)) - .orderAsc(ArticleDao.Properties.ArticleId); + .orderAsc(ArticleDao.Properties.CreationDate, ArticleDao.Properties.ArticleId); int totalNumber = (int) queryBuilder.count(); Log.d(TAG, "fetchImages() total number: " + totalNumber); diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/service/workers/DeletedArticleSweeper.java b/app/src/main/java/fr/gaulupeau/apps/Poche/service/workers/DeletedArticleSweeper.java index 2732e0e31..7c7b65da0 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/service/workers/DeletedArticleSweeper.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/service/workers/DeletedArticleSweeper.java @@ -145,7 +145,8 @@ private void performSweep(ArticlesChangedEvent event, ProgressListener progressL QueryBuilder
queryBuilder = articleDao.queryBuilder() .where(ArticleDao.Properties.ArticleId.isNotNull()) - .orderDesc(ArticleDao.Properties.ArticleId).limit(dbQuerySize); + .orderDesc(ArticleDao.Properties.CreationDate, ArticleDao.Properties.ArticleId) + .limit(dbQuerySize); List articlesToDelete = new ArrayList<>(); diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ArticleListFragment.java b/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ArticleListFragment.java index f6a52d40f..3d8ace6f4 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ArticleListFragment.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ArticleListFragment.java @@ -236,11 +236,11 @@ private QueryBuilder
getQueryBuilder() { switch (sortOrder) { case ASC: - qb.orderAsc(ArticleDao.Properties.ArticleId); + qb.orderAsc(ArticleDao.Properties.CreationDate, ArticleDao.Properties.ArticleId); break; case DESC: - qb.orderDesc(ArticleDao.Properties.ArticleId); + qb.orderDesc(ArticleDao.Properties.CreationDate, ArticleDao.Properties.ArticleId); break; default: diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ReadArticleActivity.java b/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ReadArticleActivity.java index 72646cf72..87fd4715a 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ReadArticleActivity.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ReadArticleActivity.java @@ -1340,14 +1340,15 @@ private Long getAdjacentArticle(boolean previous) { QueryBuilder
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())); + // possible problem: will skip articles with the same creation date + if (previous) qb.where(ArticleDao.Properties.CreationDate.gt(article.getCreationDate())); + else qb.where(ArticleDao.Properties.CreationDate.lt(article.getCreationDate())); 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); + if (previous) qb.orderAsc(ArticleDao.Properties.CreationDate); + else qb.orderDesc(ArticleDao.Properties.CreationDate); List
l = qb.limit(1).list(); if (!l.isEmpty()) {