Fix #2312: Prevent crash when internet connection is not available (#2320)

* Fixes crash when internet connection is not available

* Fixes crash when internet connection is not available

* Remove unused imports
This commit is contained in:
Shridhar Goel 2019-01-20 01:47:52 +05:30 committed by Vivek Maskara
parent 071eab6302
commit aac0b7c52f
2 changed files with 11 additions and 0 deletions

View file

@ -42,6 +42,8 @@ import fr.free.nrw.commons.explore.SearchActivity;
import fr.free.nrw.commons.kvstore.BasicKvStore;
import fr.free.nrw.commons.mwapi.MediaWikiApi;
import fr.free.nrw.commons.utils.ImageUtils;
import fr.free.nrw.commons.utils.NetworkUtils;
import fr.free.nrw.commons.utils.ViewUtil;
import timber.log.Timber;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
@ -176,6 +178,10 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
return true;
case R.id.menu_download_current_image:
// Download
if (!NetworkUtils.isInternetConnectionEstablished(getActivity())) {
ViewUtil.showShortSnackbar(getView(), R.string.no_internet);
return false;
}
downloadMedia(m);
return true;
case R.id.menu_set_as_wallpaper: