Few fixes

This commit is contained in:
fba 2017-05-20 16:42:24 +02:00
parent dbbb4d1cdc
commit 58055acce3
3 changed files with 5 additions and 4 deletions

View File

@ -82,7 +82,7 @@ public class DownloadFragment extends Fragment {
} }
} }
public static void showNoWiFiWarning(Context context) { public static void showNoWiFiWarning(Context context, Runnable yesAction) {
new AlertDialog.Builder(context) new AlertDialog.Builder(context)
.setTitle(R.string.wifi_only_title) .setTitle(R.string.wifi_only_title)
.setMessage(R.string.wifi_only_msg) .setMessage(R.string.wifi_only_msg)
@ -92,6 +92,7 @@ public class DownloadFragment extends Fragment {
.putBoolean(KiwixSettingsActivity.PREF_WIFI_ONLY, false) .putBoolean(KiwixSettingsActivity.PREF_WIFI_ONLY, false)
.apply(); .apply();
KiwixMobileActivity.wifiOnly = false; KiwixMobileActivity.wifiOnly = false;
yesAction.run();
}) })
.setNegativeButton(R.string.no, (dialog, i) -> {}) .setNegativeButton(R.string.no, (dialog, i) -> {})
.show(); .show();
@ -208,7 +209,7 @@ public class DownloadFragment extends Fragment {
int newPlayPauseState = LibraryFragment.mService.downloadStatus.get(mKeys[position]) == DownloadService.PLAY ? DownloadService.PAUSE : DownloadService.PLAY; int newPlayPauseState = LibraryFragment.mService.downloadStatus.get(mKeys[position]) == DownloadService.PLAY ? DownloadService.PAUSE : DownloadService.PLAY;
if (newPlayPauseState == DownloadService.PLAY && KiwixMobileActivity.wifiOnly && !NetworkUtils.isWiFi(getContext())) { if (newPlayPauseState == DownloadService.PLAY && KiwixMobileActivity.wifiOnly && !NetworkUtils.isWiFi(getContext())) {
showNoWiFiWarning(getContext()); showNoWiFiWarning(getContext(), () -> {setPlayState(pause, position, newPlayPauseState);});
return; return;
} }

View File

@ -83,7 +83,7 @@ public class ZimManageActivity extends AppCompatActivity {
setUpToolbar(); setUpToolbar();
if (DownloadService.ACTION_NO_WIFI.equals(getIntent().getAction())) { if (DownloadService.ACTION_NO_WIFI.equals(getIntent().getAction())) {
DownloadFragment.showNoWiFiWarning(this); DownloadFragment.showNoWiFiWarning(this, () -> {});
} }
// Create the adapter that will return a fragment for each of the three // Create the adapter that will return a fragment for each of the three

View File

@ -261,7 +261,7 @@ public class LibraryFragment extends Fragment
} }
if (KiwixMobileActivity.wifiOnly && !NetworkUtils.isWiFi(getContext())) { if (KiwixMobileActivity.wifiOnly && !NetworkUtils.isWiFi(getContext())) {
DownloadFragment.showNoWiFiWarning(getContext()); DownloadFragment.showNoWiFiWarning(getContext(), () -> {downloadFile((Book) parent.getAdapter().getItem(position));});
} else { } else {
downloadFile((Book) parent.getAdapter().getItem(position)); downloadFile((Book) parent.getAdapter().getItem(position));
} }