Back to project page wifi-auto-forget.
The source code is released under:
GNU General Public License
If you think the Android project wifi-auto-forget listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.cebesius.wifiautoforget.mvp; // ww w . ja va2 s . c om import com.cebesius.wifiautoforget.domain.AutoForgetWifi; /** * Presenter for the Connectivity Change flow */ public class ConnectivityChangePresenter { private final ConnectivityChangeModel model; private final ConnectivityChangeView view; public ConnectivityChangePresenter(ConnectivityChangeModel model, ConnectivityChangeView view) { this.model = model; this.view = view; } public void present() { if (model.isConnectedWifi()) { onJoinWifi(); } else { onJoinOther(); } } private void onJoinWifi() { if (model.isConnectedWifiUnknown()) { AutoForgetWifi autoForgetWifi = model.buildNetwork(); ConnectivityChangeView.NotificationVerbosity notificationVerbosity = chooseNotificationVerbosity(); view.showUnknownWifiNotification(autoForgetWifi, notificationVerbosity); } else if (model.isConnectedWifiPermanentAutoForget()) { // no-op } model.autoForget(); } /** * Choose the appropriate notification verbosity * @return the NotificationVerbosity to be used when setting up the notification */ private ConnectivityChangeView.NotificationVerbosity chooseNotificationVerbosity() { int addWifiNotificationActionCount = model.getUsedAddWifiNotificationActionCount(); boolean usedAllAddWifiNotificationActionTypes = model.hasUsedAllAddWifiNotificationActionTypes(); return addWifiNotificationActionCount >= 10 || usedAllAddWifiNotificationActionTypes ? ConnectivityChangeView.NotificationVerbosity.BRIEF : ConnectivityChangeView.NotificationVerbosity.EXTENDED; } private void onJoinOther() { model.autoForget(); } }