Search in sources :

Example 1 with NetworkManager

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);
}
Also used : NetworkManager(com.frostwire.android.gui.NetworkManager) ConfigurationManager(com.frostwire.android.core.ConfigurationManager)

Example 2 with NetworkManager

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();
}
Also used : SwitchPreferenceCompat(android.support.v7.preference.SwitchPreferenceCompat) NetworkManager(com.frostwire.android.gui.NetworkManager) Engine(com.frostwire.android.gui.services.Engine)

Example 3 with NetworkManager

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();
            }
        }
    }
}
Also used : NetworkManager(com.frostwire.android.gui.NetworkManager) ConfigurationManager(com.frostwire.android.core.ConfigurationManager)

Aggregations

NetworkManager (com.frostwire.android.gui.NetworkManager)3 ConfigurationManager (com.frostwire.android.core.ConfigurationManager)2 SwitchPreferenceCompat (android.support.v7.preference.SwitchPreferenceCompat)1 Engine (com.frostwire.android.gui.services.Engine)1