示例#1
0
  private void indexGeoEntries(
      final IndexWriter indexWriter,
      final List<GeoEntry> geoEntryList,
      final ProgressCallback progressCallback)
      throws IOException {
    int progress = 0;
    int currentEntry = 0;
    final int numGeoEntries = geoEntryList.size();
    for (GeoEntry geoEntry : geoEntryList) {
      addDocument(indexWriter, geoEntry);
      if (currentEntry == (int) (numGeoEntries * (progress / 100.0f))) {
        if (progressCallback != null) {
          progressCallback.updateProgress(progress);
        }
        progress += 5;
      }

      ++currentEntry;
    }
    // Since we start counting the GeoEntries at 0, the progress callback won't be called in the
    // above loop when progress is 100. In any case, we need to give a progress update when
    // the work is complete.
    if (progressCallback != null) {
      progressCallback.updateProgress(100);
    }
  }