Slide 8
Slide 8 text
public TrainingSpotsPresenter(TrainingSpotsMvp.View view, TrainingSpotsMvp.Model model,
NetworkManager networkManager,
FreeleticsTracking tracking,
ScreenTrackingDelegate screenTrackingDelegate,
EventBuildConfigInfo eventBuildConfigInfo) {
this.model = model;
this.view = view;
this.networkManager = networkManager;
this.tracking = tracking;
this.screenTrackingDelegate = screenTrackingDelegate;
this.eventBuildConfigInfo = eventBuildConfigInfo;
subscriptions = new CompositeDisposable();
}
@Override
public void setTrackingScreenName() {
screenTrackingDelegate.setScreenName(tracking, TrainingSpotsEvents.TRAINING_SPOT_LIST_PAGE_ID);
}
@Override
public void loadTrainingSpots() {
if (!networkManager.isOnline()) {
view.showNoInternetConnection();
return;
}
view.showProgress(true);
if (model.hasNoGpsPermissions()) {
loadDefaultTrainingSpots();
} else {
subscriptions.add(model.checkForHighAccuracy()
.subscribe(status -> loadDefaultTrainingSpots(),
throwable -> loadDefaultTrainingSpots(),
() -> subscriptions.add(
model.getNextTrainingSpots()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(trainingSpots -> {
view.showProgress(false);
view.showLocalTrainingSpots(trainingSpots, model.getNearbyTrainingSpotThreshold());
view.showShareNearbyTrainingSpotBanner(
model.shouldShowBanner(trainingSpots));
tracking.trackEvent(
TrainingSpotsEvents
.pageImpressionTrainingSpotsList(
eventBuildConfigInfo,
true,
trainingSpots));