@Test public void createWithNullThrows() { try { RxBroadcastReceiver.create(null, null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("context == null"); } }
@CheckResult @NonNull public static Observable<Intent> create(@NonNull final Context context, @NonNull final IntentFilter intentFilter) { checkNotNull(context, "context == null"); checkNotNull(intentFilter, "intentFilter == null"); return Observable.create(new Observable.OnSubscribe<Intent>() { @Override public void call(final Subscriber<? super Intent> subscriber) { final BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { subscriber.onNext(intent); } }; context.registerReceiver(receiver, intentFilter); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { context.unregisterReceiver(receiver); } })); } }); }
RxBroadcastReceiver { @CheckResult @NonNull public static Observable<Intent> create(@NonNull final Context context, @NonNull final IntentFilter intentFilter) { checkNotNull(context, "context == null"); checkNotNull(intentFilter, "intentFilter == null"); return Observable.create(new Observable.OnSubscribe<Intent>() { @Override public void call(final Subscriber<? super Intent> subscriber) { final BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { subscriber.onNext(intent); } }; context.registerReceiver(receiver, intentFilter); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { context.unregisterReceiver(receiver); } })); } }); } }
RxBroadcastReceiver { @CheckResult @NonNull public static Observable<Intent> create(@NonNull final Context context, @NonNull final IntentFilter intentFilter) { checkNotNull(context, "context == null"); checkNotNull(intentFilter, "intentFilter == null"); return Observable.create(new Observable.OnSubscribe<Intent>() { @Override public void call(final Subscriber<? super Intent> subscriber) { final BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { subscriber.onNext(intent); } }; context.registerReceiver(receiver, intentFilter); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { context.unregisterReceiver(receiver); } })); } }); } private  RxBroadcastReceiver(); }
RxBroadcastReceiver { @CheckResult @NonNull public static Observable<Intent> create(@NonNull final Context context, @NonNull final IntentFilter intentFilter) { checkNotNull(context, "context == null"); checkNotNull(intentFilter, "intentFilter == null"); return Observable.create(new Observable.OnSubscribe<Intent>() { @Override public void call(final Subscriber<? super Intent> subscriber) { final BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { subscriber.onNext(intent); } }; context.registerReceiver(receiver, intentFilter); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { context.unregisterReceiver(receiver); } })); } }); } private  RxBroadcastReceiver(); @CheckResult @NonNull // static Observable<Intent> create(@NonNull final Context context,
      @NonNull final IntentFilter intentFilter); }
RxBroadcastReceiver { @CheckResult @NonNull public static Observable<Intent> create(@NonNull final Context context, @NonNull final IntentFilter intentFilter) { checkNotNull(context, "context == null"); checkNotNull(intentFilter, "intentFilter == null"); return Observable.create(new Observable.OnSubscribe<Intent>() { @Override public void call(final Subscriber<? super Intent> subscriber) { final BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { subscriber.onNext(intent); } }; context.registerReceiver(receiver, intentFilter); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { context.unregisterReceiver(receiver); } })); } }); } private  RxBroadcastReceiver(); @CheckResult @NonNull // static Observable<Intent> create(@NonNull final Context context,
      @NonNull final IntentFilter intentFilter);  }