use of com.frostwire.android.gui.NetworkManager in project frostwire by frostwire.
the class MainActivity method onResume.
@Override
protected void onResume() {
super.onResume();
localBroadcastReceiver.register(this);
setupDrawer();
ConfigurationManager CM = ConfigurationManager.instance();
if (CM.getBoolean(Constants.PREF_KEY_GUI_INITIAL_SETTINGS_COMPLETE)) {
mainResume();
Offers.initAdNetworks(this);
} else if (!isShutdown()) {
controller.startWizardActivity();
}
checkLastSeenVersionBuild();
registerMainBroadcastReceiver();
syncNavigationMenu();
updateNavigationMenu();
// UIUtils.showSocialLinksDialog(this, true, null, "");
if (CM.getBoolean(Constants.PREF_KEY_GUI_TOS_ACCEPTED)) {
checkExternalStoragePermissionsOrBindMusicService();
}
tryOnResumeInterstitial();
async(NetworkManager.instance(), NetworkManager::queryNetworkStatusBackground);
}
use of com.frostwire.android.gui.NetworkManager 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.NetworkManager in project frostwire by frostwire.
the class EngineBroadcastReceiver method handleConnectedNetwork.
private void handleConnectedNetwork(NetworkInfo networkInfo) {
PlayStore.getInstance().refresh();
NetworkManager networkManager = NetworkManager.instance();
if (networkManager.isDataUp()) {
ConfigurationManager CM = ConfigurationManager.instance();
boolean useTorrentsOnMobileData = !CM.getBoolean(Constants.PREF_KEY_NETWORK_USE_WIFI_ONLY);
if (!networkManager.isDataMobileUp() || useTorrentsOnMobileData) {
LOG.info("Connected to " + networkInfo.getTypeName());
if (Engine.instance().isDisconnected()) {
if (CM.getBoolean(Constants.PREF_KEY_NETWORK_BITTORRENT_ON_VPN_ONLY) && !(networkManager.isTunnelUp() || isNetworkVPN(networkInfo))) {
// don't start
return;
}
Engine.instance().startServices();
if (shouldStopSeeding()) {
TransferManager.instance().stopSeedingTorrents();
}
} else if (shouldStopSeeding()) {
TransferManager.instance().stopSeedingTorrents();
}
}
}
}
Aggregations