Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installer: add setter for HistoryChecker and VersionChecker. #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions gandalf/src/main/java/io/github/btkelly/gandalf/Gandalf.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.github.btkelly.gandalf.checker.DefaultVersionChecker;
import io.github.btkelly.gandalf.checker.GateKeeper;
import io.github.btkelly.gandalf.checker.HistoryChecker;
import io.github.btkelly.gandalf.checker.VersionChecker;
import io.github.btkelly.gandalf.holders.DialogStringsHolder;
import io.github.btkelly.gandalf.models.Alert;
import io.github.btkelly.gandalf.models.Bootstrap;
Expand Down Expand Up @@ -208,6 +209,8 @@ public static class Installer {

private DialogStringsHolder dialogStringsHolder;
private Executor callbackExecutor;
private HistoryChecker historyChecker;
private VersionChecker versionChecker;

public Installer setContext(Context context) {
this.context = context;
Expand Down Expand Up @@ -254,6 +257,16 @@ public Installer setCallbackExecutor(Executor callbackExecutor) {
return this;
}

public Installer setHistoryChecker(HistoryChecker historyChecker) {
this.historyChecker = historyChecker;
return this;
}

public Installer setVersionChecker(VersionChecker versionChecker) {
this.versionChecker = versionChecker;
return this;
}

public void install() {

synchronized (Gandalf.class) {
Expand Down Expand Up @@ -281,15 +294,21 @@ public void install() {
this.onUpdateSelectedListener = new PlayStoreUpdateListener(this.packageName);
}

HistoryChecker historyChecker = new DefaultHistoryChecker(this.context);
if (this.historyChecker == null) {
this.historyChecker = new DefaultHistoryChecker(this.context);
}

if (this.versionChecker == null) {
this.versionChecker = new DefaultVersionChecker();
}

LoggerUtil.setLogLevel(logLevel);

gandalfInstance = createInstance(
this.okHttpClient,
this.bootstrapUrl,
historyChecker,
new GateKeeper(this.context, new DefaultVersionChecker(), historyChecker),
this.historyChecker,
new GateKeeper(this.context, this.versionChecker, this.historyChecker),
this.onUpdateSelectedListener,
this.customDeserializer,
this.dialogStringsHolder,
Expand Down