Add network connection established check on view side, check it from presenter

This commit is contained in:
neslihanturan 2019-05-17 18:50:19 +03:00
parent f8e8d13b78
commit 034a2e2f08
3 changed files with 12 additions and 0 deletions

View file

@ -13,6 +13,7 @@ public interface NearbyParentFragmentContract {
void showLocationPermissionDeniedErrorDialog(LocationServiceManager locationServiceManager); void showLocationPermissionDeniedErrorDialog(LocationServiceManager locationServiceManager);
void checkGps(LocationServiceManager locationServiceManager); void checkGps(LocationServiceManager locationServiceManager);
void checkLocationPermission(LocationServiceManager locationServiceManager); void checkLocationPermission(LocationServiceManager locationServiceManager);
boolean isNetworkConnectionEstablished();
} }
interface UserActions { interface UserActions {

View file

@ -31,6 +31,7 @@ import fr.free.nrw.commons.nearby.NearbyListFragment;
import fr.free.nrw.commons.nearby.NearbyMapFragment; import fr.free.nrw.commons.nearby.NearbyMapFragment;
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract; import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
import fr.free.nrw.commons.nearby.mvp.presenter.NearbyParentFragmentPresenter; import fr.free.nrw.commons.nearby.mvp.presenter.NearbyParentFragmentPresenter;
import fr.free.nrw.commons.utils.NetworkUtils;
import fr.free.nrw.commons.wikidata.WikidataEditListener; import fr.free.nrw.commons.wikidata.WikidataEditListener;
import timber.log.Timber; import timber.log.Timber;
@ -289,4 +290,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
nearbyParentFragmentPresenter.updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED); nearbyParentFragmentPresenter.updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED);
} }
} }
@Override
public boolean isNetworkConnectionEstablished() {
return NetworkUtils.isInternetConnectionEstablished(getActivity());
}
} }

View file

@ -74,6 +74,11 @@ public class NearbyParentFragmentPresenter
return; return;
} }
if (!nearbyParentFragmentView.isNetworkConnectionEstablished()) {
Timber.d("Network connection is not established");
return;
}
} }