<commit_before>package com.github.karczews.rxbroadcastreceiver;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.annotation.NonNull;

import java.util.concurrent.atomic.AtomicBoolean;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

class RxBroadcastReceiver extends Observable <Intent> {

    @NonNull
    private final Context context;
    @NonNull
    private final IntentFilter intentFilter;

    public RxBroadcastReceiver(@NonNull final Context context, @NonNull final IntentFilter intentFilter) {
        this.context = context.getApplicationContext();
        this.intentFilter = intentFilter;
    }

    @Override
    protected void subscribeActual(final Observer <? super Intent> observer) {
        final ReceiverDisposable disposable = new ReceiverDisposable(context, observer);
        context.registerReceiver(disposable, intentFilter);
        observer.onSubscribe(disposable);
    }

    private static class ReceiverDisposable extends BroadcastReceiver implements Disposable {
        @NonNull
        private final AtomicBoolean disposed = new AtomicBoolean(false);
        @NonNull
        private final Observer <? super Intent> observer;
        @NonNull
        private final Context context;

        ReceiverDisposable(@NonNull final Context context, @NonNull final Observer <? super Intent> observer) {
            this.observer = observer;
            this.context = context;
        }
        @Override
        public void dispose() {
            if (disposed.compareAndSet(false, true)) {
                context.unregisterReceiver(ReceiverDisposable.this);
            }
        }

        @Override
        public boolean isDisposed() {
            return disposed.get();
        }

        @Override
        public void onReceive(final Context context, final Intent intent) {
            if (!disposed.get()) {
                observer.onNext(intent);
                if (isOrderedBroadcast()) {
                    setResultCode(Activity.RESULT_OK);
                }
            } else {
                if (isOrderedBroadcast()) {
                    abortBroadcast();
                }
            }
        }
    }
}<commit_msg>remove invalid ordered broadcast handling<commit_after>package com.github.karczews.rxbroadcastreceiver;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.annotation.NonNull;

import java.util.concurrent.atomic.AtomicBoolean;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

class RxBroadcastReceiver extends Observable <Intent> {

    @NonNull
    private final Context context;
    @NonNull
    private final IntentFilter intentFilter;

    public RxBroadcastReceiver(@NonNull final Context context, @NonNull final IntentFilter intentFilter) {
        this.context = context.getApplicationContext();
        this.intentFilter = intentFilter;
    }

    @Override
    protected void subscribeActual(final Observer <? super Intent> observer) {
        final ReceiverDisposable disposable = new ReceiverDisposable(context, observer);
        context.registerReceiver(disposable, intentFilter);
        observer.onSubscribe(disposable);
    }

    private static class ReceiverDisposable extends BroadcastReceiver implements Disposable {
        @NonNull
        private final AtomicBoolean disposed = new AtomicBoolean(false);
        @NonNull
        private final Observer <? super Intent> observer;
        @NonNull
        private final Context context;

        ReceiverDisposable(@NonNull final Context context, @NonNull final Observer <? super Intent> observer) {
            this.observer = observer;
            this.context = context;
        }
        @Override
        public void dispose() {
            if (disposed.compareAndSet(false, true)) {
                context.unregisterReceiver(ReceiverDisposable.this);
            }
        }

        @Override
        public boolean isDisposed() {
            return disposed.get();
        }

        @Override
        public void onReceive(final Context context, final Intent intent) {
            if (!isDisposed()) {
                observer.onNext(intent);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.0760053026955369, 'fraction_numerical': 0.0, 'mean_word_length': 2.674512987012987, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2281287', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1076, 'n_words': 279}