mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
(Bug 45372) COMMIT to the database at lesser intervals
This commit is contained in:
parent
a23d81d25a
commit
fcd13c9a71
1 changed files with 16 additions and 4 deletions
|
|
@ -18,6 +18,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter {
|
public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||||
|
private static int COMMIT_THRESHOLD = 10;
|
||||||
public ContributionsSyncAdapter(Context context, boolean autoInitialize) {
|
public ContributionsSyncAdapter(Context context, boolean autoInitialize) {
|
||||||
super(context, autoInitialize);
|
super(context, autoInitialize);
|
||||||
}
|
}
|
||||||
|
|
@ -89,13 +90,24 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||||
Contribution contrib = new Contribution(null, thumbUrl, filename, "", -1, dateUpdated, dateUpdated, user, "");
|
Contribution contrib = new Contribution(null, thumbUrl, filename, "", -1, dateUpdated, dateUpdated, user, "");
|
||||||
contrib.setState(Contribution.STATE_COMPLETED);
|
contrib.setState(Contribution.STATE_COMPLETED);
|
||||||
imageValues.add(contrib.toContentValues());
|
imageValues.add(contrib.toContentValues());
|
||||||
}
|
|
||||||
|
|
||||||
|
if(imageValues.size() % COMMIT_THRESHOLD == 0) {
|
||||||
try {
|
try {
|
||||||
contentProviderClient.bulkInsert(ContributionsContentProvider.BASE_URI, imageValues.toArray(new ContentValues[]{}));
|
contentProviderClient.bulkInsert(ContributionsContentProvider.BASE_URI, imageValues.toArray(new ContentValues[]{}));
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
imageValues.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(imageValues.size() != 0) {
|
||||||
|
try {
|
||||||
|
contentProviderClient.bulkInsert(ContributionsContentProvider.BASE_URI, imageValues.toArray(new ContentValues[]{}));
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
queryContinue = result.getString("/api/query-continue/logevents/@lestart");
|
queryContinue = result.getString("/api/query-continue/logevents/@lestart");
|
||||||
if(TextUtils.isEmpty(queryContinue)) {
|
if(TextUtils.isEmpty(queryContinue)) {
|
||||||
done = true;
|
done = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue