@SuppressWarnings("ResourceType") @Test public void networkStateChanges() throws IllegalAccessException, InstantiationException { Application application = RuntimeEnvironment.application; TestSubscriber<NetworkStateChangedEvent> o = new TestSubscriber<>(); RxWifiManager.networkStateChanges(application).subscribe(o); o.assertValues(); NetworkInfo networkInfo1 = NetworkInfo.class.newInstance(); WifiInfo wifiInfo1 = WifiInfo.class.newInstance(); Intent intent1 = new Intent(NETWORK_STATE_CHANGED_ACTION) .putExtra(WifiManager.EXTRA_NETWORK_INFO, networkInfo1) .putExtra(WifiManager.EXTRA_BSSID, "foo") .putExtra(WifiManager.EXTRA_WIFI_INFO, wifiInfo1); application.sendBroadcast(intent1); NetworkStateChangedEvent event1 = NetworkStateChangedEvent.create(networkInfo1, "foo", wifiInfo1); o.assertValues(event1); NetworkInfo networkInfo2 = NetworkInfo.class.newInstance(); Intent intent2 = new Intent(NETWORK_STATE_CHANGED_ACTION) .putExtra(WifiManager.EXTRA_NETWORK_INFO, networkInfo2); application.sendBroadcast(intent2); NetworkStateChangedEvent event2 = NetworkStateChangedEvent.create(networkInfo2, null, null); o.assertValues(event1, event2); }
@CheckResult @NonNull public static Observable<NetworkStateChangedEvent> networkStateChanges(@NonNull final Context context) { checkNotNull(context, "context == null"); IntentFilter filter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION); return RxBroadcastReceiver.create(context, filter) .map(new Func1<Intent, NetworkStateChangedEvent>() { @Override public NetworkStateChangedEvent call(Intent intent) { NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); String bssid = intent.getStringExtra(WifiManager.EXTRA_BSSID); WifiInfo wifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO); return NetworkStateChangedEvent.create(networkInfo, bssid, wifiInfo); } }); }
RxWifiManager { @CheckResult @NonNull public static Observable<NetworkStateChangedEvent> networkStateChanges(@NonNull final Context context) { checkNotNull(context, "context == null"); IntentFilter filter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION); return RxBroadcastReceiver.create(context, filter) .map(new Func1<Intent, NetworkStateChangedEvent>() { @Override public NetworkStateChangedEvent call(Intent intent) { NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); String bssid = intent.getStringExtra(WifiManager.EXTRA_BSSID); WifiInfo wifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO); return NetworkStateChangedEvent.create(networkInfo, bssid, wifiInfo); } }); } }
RxWifiManager { @CheckResult @NonNull public static Observable<NetworkStateChangedEvent> networkStateChanges(@NonNull final Context context) { checkNotNull(context, "context == null"); IntentFilter filter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION); return RxBroadcastReceiver.create(context, filter) .map(new Func1<Intent, NetworkStateChangedEvent>() { @Override public NetworkStateChangedEvent call(Intent intent) { NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); String bssid = intent.getStringExtra(WifiManager.EXTRA_BSSID); WifiInfo wifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO); return NetworkStateChangedEvent.create(networkInfo, bssid, wifiInfo); } }); } private  RxWifiManager(); }
RxWifiManager { @CheckResult @NonNull public static Observable<NetworkStateChangedEvent> networkStateChanges(@NonNull final Context context) { checkNotNull(context, "context == null"); IntentFilter filter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION); return RxBroadcastReceiver.create(context, filter) .map(new Func1<Intent, NetworkStateChangedEvent>() { @Override public NetworkStateChangedEvent call(Intent intent) { NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); String bssid = intent.getStringExtra(WifiManager.EXTRA_BSSID); WifiInfo wifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO); return NetworkStateChangedEvent.create(networkInfo, bssid, wifiInfo); } }); } private  RxWifiManager(); @CheckResult @NonNull // static Observable<Integer> wifiStateChanges(@NonNull final Context context); @CheckResult @NonNull // static Action1<? super Boolean> wifiState(@NonNull final WifiManager wifiManager); @CheckResult @NonNull // static Observable<NetworkStateChangedEvent> networkStateChanges(@NonNull final Context context); @CheckResult @NonNull // static Observable<Boolean> supplicantConnectionChanges(@NonNull final Context context); @CheckResult @NonNull // static Observable<SupplicantStateChangedEvent> supplicantStateChanges(@NonNull final Context context); }
RxWifiManager { @CheckResult @NonNull public static Observable<NetworkStateChangedEvent> networkStateChanges(@NonNull final Context context) { checkNotNull(context, "context == null"); IntentFilter filter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION); return RxBroadcastReceiver.create(context, filter) .map(new Func1<Intent, NetworkStateChangedEvent>() { @Override public NetworkStateChangedEvent call(Intent intent) { NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); String bssid = intent.getStringExtra(WifiManager.EXTRA_BSSID); WifiInfo wifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO); return NetworkStateChangedEvent.create(networkInfo, bssid, wifiInfo); } }); } private  RxWifiManager(); @CheckResult @NonNull // static Observable<Integer> wifiStateChanges(@NonNull final Context context); @CheckResult @NonNull // static Action1<? super Boolean> wifiState(@NonNull final WifiManager wifiManager); @CheckResult @NonNull // static Observable<NetworkStateChangedEvent> networkStateChanges(@NonNull final Context context); @CheckResult @NonNull // static Observable<Boolean> supplicantConnectionChanges(@NonNull final Context context); @CheckResult @NonNull // static Observable<SupplicantStateChangedEvent> supplicantStateChanges(@NonNull final Context context);  }