Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit 6a465d3

Browse files
author
Clément Le Provost
committed
[refact] Rename BootstrapListener to BuildListener
1 parent abdc474 commit 6a465d3

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

algoliasearch/src/offline/java/com/algolia/search/saas/BootstrapListener.java renamed to algoliasearch/src/offline/java/com/algolia/search/saas/BuildListener.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,28 @@
2424
package com.algolia.search.saas;
2525

2626
import android.support.annotation.NonNull;
27+
import android.support.annotation.Nullable;
2728

2829
/**
2930
* Listener for events related to index bootstrapping.
3031
*
3132
* Notifications are sent on a per-index basis, but you may register the same listener for all indices.
3233
* Notifications are sent on the main thread.
3334
*/
34-
public interface BootstrapListener
35+
public interface BuildListener
3536
{
3637
/**
37-
* Bootstrapping has just started.
38+
* Build of the local index has just started.
3839
*
39-
* @param index The bootstrapping index.
40+
* @param index The index being built.
4041
*/
41-
public void bootstrapDidStart(@NonNull MirroredIndex index);
42+
public void buildDidStart(@NonNull MirroredIndex index);
4243

4344
/**
44-
* Bootstrapping has just finished.
45+
* Build of the local index has just finished.
4546
*
46-
* @param index The bootstrapping index.
47-
* @param error Null if success, otherwise indicates the error.
47+
* @param index The index having been built.
48+
* @param error `null` if success, otherwise indicates the error.
4849
*/
49-
public void bootstrapDidFinish(@NonNull MirroredIndex index, Throwable error);
50+
public void buildDidFinish(@NonNull MirroredIndex index, @Nullable Throwable error);
5051
}

algoliasearch/src/offline/java/com/algolia/search/saas/MirroredIndex.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public class MirroredIndex extends Index
169169
private SyncStats stats;
170170

171171
private Set<SyncListener> syncListeners = new HashSet<>();
172-
private Set<BootstrapListener> bootstrapListeners = new HashSet<>();
172+
private Set<BuildListener> buildListeners = new HashSet<>();
173173

174174
// ----------------------------------------------------------------------
175175
// Constants
@@ -728,19 +728,25 @@ private void _buildOfflineFromRawResources(@NonNull final Resources resources, @
728728
// Build the index.
729729
_buildOffline(settingsFile, objectFiles);
730730
} catch (IOException e) {
731-
Log.e(MirroredIndex.class.getSimpleName(), "Failed to write bootstrap resources to disk", e);
731+
Log.e(MirroredIndex.class.getSimpleName(), "Failed to write build resources to disk", e);
732732
} finally {
733733
// Delete temporary files.
734734
FileUtils.deleteRecursive(tmpDir);
735735
}
736736
}
737737

738+
/**
739+
* Build the local mirror (synchronously).
740+
*
741+
* @param settingsFile The file containing index settings.
742+
* @param objectFiles The files containing objects.
743+
*/
738744
private void _buildOffline(@NonNull File settingsFile, @NonNull File... objectFiles) {
739745
// Notify listeners.
740746
getClient().mainHandler.post(new Runnable() {
741747
@Override
742748
public void run() {
743-
fireBootstrapDidStart();
749+
fireBuildDidStart();
744750
}
745751
});
746752

@@ -759,7 +765,7 @@ public void run() {
759765
if (status != 200) {
760766
error = new AlgoliaException(String.format("Failed to build local mirror \"%s\"", MirroredIndex.this.getIndexName()), status);
761767
}
762-
fireBootstrapDidFinish(error);
768+
fireBuildDidFinish(error);
763769
}
764770
});
765771
}
@@ -1314,33 +1320,33 @@ private void fireSyncDidFinish()
13141320
}
13151321
}
13161322

1317-
// BootstrapListener
1323+
// BuildListener
13181324

13191325
/**
13201326
* Add a listener for bootstrapping events.
13211327
* @param listener The listener to add.
13221328
*/
1323-
public void addBootstrapListener(@NonNull BootstrapListener listener) {
1324-
bootstrapListeners.add(listener);
1329+
public void addBootstrapListener(@NonNull BuildListener listener) {
1330+
buildListeners.add(listener);
13251331
}
13261332

13271333
/**
13281334
* Remove a listener for bootstrapping events.
13291335
* @param listener The listener to remove.
13301336
*/
1331-
public void removeBootstrapListener(@NonNull BootstrapListener listener) {
1332-
bootstrapListeners.remove(listener);
1337+
public void removeBootstrapListener(@NonNull BuildListener listener) {
1338+
buildListeners.remove(listener);
13331339
}
13341340

1335-
private void fireBootstrapDidStart() {
1336-
for (BootstrapListener listener : bootstrapListeners) {
1337-
listener.bootstrapDidStart(this);
1341+
private void fireBuildDidStart() {
1342+
for (BuildListener listener : buildListeners) {
1343+
listener.buildDidStart(this);
13381344
}
13391345
}
13401346

1341-
private void fireBootstrapDidFinish(@Nullable Throwable error) {
1342-
for (BootstrapListener listener : bootstrapListeners) {
1343-
listener.bootstrapDidFinish(this, error);
1347+
private void fireBuildDidFinish(@Nullable Throwable error) {
1348+
for (BuildListener listener : buildListeners) {
1349+
listener.buildDidFinish(this, error);
13441350
}
13451351
}
13461352
}

0 commit comments

Comments
 (0)