コード例 #1
0
  private ContentValues[] getContentValuesForThings(ThingResponseGroup2 response) {
    ContentValues[] thingValues =
        new ContentValues
            [response.getThing().size() + response.getUnprocessedThingKeyInfo().size()];

    int idx = 0;

    for (Thing2 thing : response.getThing()) {
      ContentValues values = new ContentValues();

      values.put("thing_id", thing.getThingId().getValue());
      values.put("version_stamp", thing.getThingId().getVersionStamp());
      values.put("thing_xml", XmlSerializer.safeWrite(thing));

      thingValues[idx++] = values;
    }

    for (UnprocessedThingKeyInfo keys : response.getUnprocessedThingKeyInfo()) {
      ContentValues values = new ContentValues();

      values.put("thing_id", keys.getThingId().getValue());
      values.put("version_stamp", keys.getThingId().getVersionStamp());

      thingValues[idx++] = values;
    }

    return thingValues;
  }
コード例 #2
0
  public void synchronize() throws Exception {
    ThingResponseGroup2 response = getThings();
    updateContentStore(getContentValuesForThings(response));

    int batchSize = 200;
    List<UnprocessedThingKeyInfo> keys = response.getUnprocessedThingKeyInfo();
    for (int i = 0; i < keys.size(); i += batchSize) {
      updateContentStore(
          getContentValuesForThings(
              getThingsForKeys(keys.subList(i, Math.min(i + batchSize, keys.size())))));
    }

    lastSyncDate = new Date();
    updateView();
  }