【发布时间】:2016-08-04 14:01:37
【问题描述】:
我想要从 Azure 移动服务返回到我的 Android 应用程序的表中经常有超过 50 行,并且我创建了以下函数来下载整个表:
private void genericPagedLoad(final int count, final Query baseQuery, final MobileServiceSyncTable table) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
int takenCount = 0;
int top = 50;
while (takenCount < count) {
Query query = baseQuery.skip(takenCount).top(top);
try {
table.pull(query).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
takenCount += top;
}
return null;
}
}.execute();
}
我用它打电话
ListenableFuture<MobileServiceList<Level>> future = mClient.getTable(Level.class).where().includeInlineCount().execute();
Futures.addCallback(future, new FutureCallback<MobileServiceList<Level>>() {
@Override
public void onSuccess(MobileServiceList<Level> levels) {
int count = levels.getTotalCount();
Query q = mClient.getTable(Level.class).where();
genericPagedLoad(count, q, mLevelTable);
}
@Override
public void onFailure(Throwable throwable) {
}
});
但是,我想以大于 50 的块下载数据,但如果我将变量 top 更改为 ex。 100 它仍然只会下载 50 行然后跳过 100 行。根据this article,应该可以使用top() 函数指定行数(最多1000 行),但这显然不能正常工作。我正在使用 Azure Android SDK 2.0.1-beta。有什么方法可以让top() 函数按规定工作?
【问题讨论】:
-
您使用的是什么后端类型?您很可能应该看到:stackoverflow.com/questions/25678904/…
-
你说得对,这就解决了。我不知道该文档仅适用于 Node.js 后端
-
你能发布解决你问题的解决方案吗?我也打算写类似于你的 genericPagedLoad。仅仅通过前 50 名就解决了你的问题?
标签: android azure azure-mobile-services