use of org.edx.mobile.module.prefs.PrefManager in project edx-app-android by edx.
the class DownloadEntry method getBestEncodingUrl.
public String getBestEncodingUrl(Context context) {
PrefManager prefs = new PrefManager(context, PrefManager.Pref.WIFI);
float kbs = prefs.getFloat(PrefManager.Key.SPEED_TEST_KBPS, 0.0f);
float thresholdKps = (float) context.getResources().getInteger(R.integer.threshold_kbps_for_video);
EncodingsModel.EncodingLevel level = kbs > thresholdKps ? EncodingsModel.EncodingLevel.HIGH : EncodingsModel.EncodingLevel.LOW;
switch(level) {
case HIGH:
if (!TextUtils.isEmpty(url_high_quality)) {
return url_high_quality;
}
break;
case LOW:
if (!TextUtils.isEmpty(url_low_quality)) {
return url_low_quality;
}
break;
}
return getVideoUrl();
}
use of org.edx.mobile.module.prefs.PrefManager in project edx-app-android by edx.
the class DownloadSpeedService method setCurrentDownloadSpeed.
private void setCurrentDownloadSpeed(float downloadSpeedKps) {
PrefManager manager = new PrefManager(this, PrefManager.Pref.WIFI);
manager.put(PrefManager.Key.SPEED_TEST_KBPS, downloadSpeedKps);
}
use of org.edx.mobile.module.prefs.PrefManager in project edx-app-android by edx.
the class SettingsFragment method updateWifiSwitch.
private void updateWifiSwitch() {
final PrefManager wifiPrefManager = new PrefManager(getActivity().getBaseContext(), PrefManager.Pref.WIFI);
wifiSwitch.setOnCheckedChangeListener(null);
wifiSwitch.setChecked(wifiPrefManager.getBoolean(PrefManager.Key.DOWNLOAD_ONLY_ON_WIFI, true));
wifiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
wifiPrefManager.put(PrefManager.Key.DOWNLOAD_ONLY_ON_WIFI, true);
wifiPrefManager.put(PrefManager.Key.DOWNLOAD_OFF_WIFI_SHOW_DIALOG_FLAG, true);
} else {
showWifiDialog();
}
}
});
}
use of org.edx.mobile.module.prefs.PrefManager in project edx-app-android by edx.
the class SettingsFragment method showWifiDialog.
protected void showWifiDialog() {
final NetworkCheckDialogFragment newFragment = NetworkCheckDialogFragment.newInstance(getString(R.string.wifi_dialog_title_help), getString(R.string.wifi_dialog_message_help), new IDialogCallback() {
@Override
public void onPositiveClicked() {
try {
PrefManager wifiPrefManager = new PrefManager(getActivity().getBaseContext(), PrefManager.Pref.WIFI);
wifiPrefManager.put(PrefManager.Key.DOWNLOAD_ONLY_ON_WIFI, false);
updateWifiSwitch();
} catch (Exception ex) {
logger.error(ex);
}
}
@Override
public void onNegativeClicked() {
try {
PrefManager wifiPrefManager = new PrefManager(getActivity().getBaseContext(), PrefManager.Pref.WIFI);
wifiPrefManager.put(PrefManager.Key.DOWNLOAD_ONLY_ON_WIFI, true);
wifiPrefManager.put(PrefManager.Key.DOWNLOAD_OFF_WIFI_SHOW_DIALOG_FLAG, true);
updateWifiSwitch();
} catch (Exception ex) {
logger.error(ex);
}
}
});
newFragment.setCancelable(false);
newFragment.show(getActivity().getSupportFragmentManager(), "dialog");
}
Aggregations