From 605cd114f2e61d50569dfe7d6bbe64fa6ce4b1c7 Mon Sep 17 00:00:00 2001 From: xuexiangjys Date: Thu, 3 Sep 2020 22:38:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4api=E7=9A=84=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../xuexiang/xormlitedemo/fragment/PageQueryFragment.java | 2 +- .../src/main/java/com/xuexiang/xormlite/db/DBService.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index da20b35..8d39da8 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ DBService mDBService = InternalDataBaseRepository.getInstance().getData * queryForColumnFirst: 根据条件查询,返回第一个符合条件的对象。 * indistinctQueryForColumn: 根据条件模糊查询,返回一个对象集合。 * queryDataBySql: 根据sql语句查询,返回对象的集合。 -* pageQuery: 根据某个字段进行分页查询 +* queryPage: 根据某个字段排序进行分页查询 #### 更新 diff --git a/app/src/main/java/com/xuexiang/xormlitedemo/fragment/PageQueryFragment.java b/app/src/main/java/com/xuexiang/xormlitedemo/fragment/PageQueryFragment.java index bdb669b..e7a8dc4 100644 --- a/app/src/main/java/com/xuexiang/xormlitedemo/fragment/PageQueryFragment.java +++ b/app/src/main/java/com/xuexiang/xormlitedemo/fragment/PageQueryFragment.java @@ -102,7 +102,7 @@ public void run() { private List pageQuery(int pageIndex) { try { - return mDBService.pageQuery("Id", true, pageIndex, 50); + return mDBService.queryPage(pageIndex, 50, "Id", true); } catch (SQLException e) { e.printStackTrace(); } diff --git a/xormlite-runtime/src/main/java/com/xuexiang/xormlite/db/DBService.java b/xormlite-runtime/src/main/java/com/xuexiang/xormlite/db/DBService.java index e81a498..b207500 100644 --- a/xormlite-runtime/src/main/java/com/xuexiang/xormlite/db/DBService.java +++ b/xormlite-runtime/src/main/java/com/xuexiang/xormlite/db/DBService.java @@ -198,14 +198,14 @@ public List queryAndOrderBy(String fieldName, Object value, String columnName /** * 根据某个字段进行分页查询 * + * @param pageIndex 页面的索引 + * @param pageSize 一页的数据大小 * @param columnName 排序的列名 * @param ascending true:升序,false:降序 - * @param pageIndex 页面的索引 - * @param pageSize 一页的数据大小 * @return * @throws SQLException */ - public List pageQuery(String columnName, boolean ascending, long pageIndex, long pageSize) throws SQLException { + public List queryPage(long pageIndex, long pageSize, String columnName, boolean ascending) throws SQLException { QueryBuilder query = mDao.queryBuilder(); query.limit(pageSize); query.offset(pageIndex * pageSize);