use of com.frostwire.android.gui.services.Engine in project frostwire by frostwire.
the class ApplicationFragment method setupConnectSwitch.
private void setupConnectSwitch() {
SwitchPreferenceCompat preference = findPreference("frostwire.prefs.internal.connect_disconnect");
preference.setOnPreferenceChangeListener((preference1, newValue) -> {
boolean newStatus = (boolean) newValue;
Engine e = Engine.instance();
if (e.isStarted() && !newStatus) {
disconnect();
UIUtils.showShortMessage(getView(), R.string.toast_on_disconnect);
} else if (newStatus && (e.isStopped() || e.isDisconnected())) {
NetworkManager networkManager = NetworkManager.instance();
if (getPreferenceManager().getSharedPreferences().getBoolean(Constants.PREF_KEY_NETWORK_BITTORRENT_ON_VPN_ONLY, false) && !networkManager.isTunnelUp()) {
UIUtils.showShortMessage(getView(), R.string.cannot_start_engine_without_vpn);
return false;
} else if (getPreferenceManager().getSharedPreferences().getBoolean(Constants.PREF_KEY_NETWORK_USE_WIFI_ONLY, false) && networkManager.isDataMobileUp()) {
UIUtils.showShortMessage(getView(), R.string.wifi_network_unavailable);
return false;
} else {
connect();
}
}
return true;
});
updateConnectSwitchStatus();
}
use of com.frostwire.android.gui.services.Engine in project frostwire by frostwire.
the class ApplicationFragment method updateConnectSwitchStatus.
private void updateConnectSwitchStatus() {
SwitchPreferenceCompat preference = findPreference("frostwire.prefs.internal.connect_disconnect");
Engine e = Engine.instance();
if (e.isStarted()) {
setChecked(preference, true, false);
} else if (e.isStopped() || e.isDisconnected()) {
setChecked(preference, false, false);
}
}
Aggregations