<commit_before>package com.morihacky.android.rxjava;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import java.util.List;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.functions.Func1;
import timber.log.Timber;

public class RotationPersistWorkerFragment
      extends Fragment {

    private Observable<Integer> _intsObservable;
    private IAmYourMaster _masterFrag;

    /**
     * hold a refernce to the activity -> caller fragment
     * this way when the worker frag kicks off
     * we can talk back to the master and send results
     */
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

        _masterFrag = (RotationPersistFragment) getActivity().getSupportFragmentManager()
              .findFragmentByTag(RotationPersistFragment.class.getName());

        List<Fragment> frags = ((MainActivity) activity).getSupportFragmentManager().getFragments();

        Timber.d("---- there are currently %d fragments attached", frags.size());

        for (Fragment f : frags) {
            if (f instanceof IAmYourMaster) {
                _masterFrag = (IAmYourMaster) f;
            }
        }

        if (_masterFrag == null) {
            throw new ClassCastException("We did not find a master who can understand us :( !");
        }
    }

    /**
     * This method will only be called once when the retained
     * Fragment is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Retain this fragment across configuration changes.
        setRetainInstance(true);


        if (_intsObservable != null) {
            return;
        }

        // Create and execute the "Hot" observable
        Timber.d("---- Creating a new ints observable");
        _intsObservable =//
              Observable.interval(1, TimeUnit.SECONDS)//
                    .map(new Func1<Long, Integer>() {
                        @Override
                        public Integer call(Long aLong) {
                            return aLong.intValue();
                        }
                    })//
                    .take(20)// cause i don't want this thing to run indefinitely
                    .share(); // we need a "hot" observable for demoing the example
    }
<commit_msg>fix:  makes the observable warm, not hot. so this is a hack to simulate heat<commit_after>package com.morihacky.android.rxjava;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import java.util.List;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.functions.Func1;
import timber.log.Timber;

public class RotationPersistWorkerFragment
      extends Fragment {

    private Observable<Integer> _intsObservable;
    private IAmYourMaster _masterFrag;

    /**
     * hold a reference to the activity -> caller fragment
     * this way when the worker frag kicks off
     * we can talk back to the master and send results
     */
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

        _masterFrag = (RotationPersistFragment) getActivity().getSupportFragmentManager()
              .findFragmentByTag(RotationPersistFragment.class.getName());

        List<Fragment> frags = ((MainActivity) activity).getSupportFragmentManager().getFragments();

        Timber.d("---- there are currently %d fragments attached", frags.size());

        for (Fragment f : frags) {
            if (f instanceof IAmYourMaster) {
                _masterFrag = (IAmYourMaster) f;
            }
        }

        if (_masterFrag == null) {
            throw new ClassCastException("We did not find a master who can understand us :( !");
        }
    }

    /**
     * This method will only be called once when the retained
     * Fragment is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Retain this fragment across configuration changes.
        setRetainInstance(true);

        if (_intsObservable != null) {
            return;
        }

        // Create and execute the "Hot" observable
        Timber.d("---- Creating a new ints observable");
        _intsObservable =//
              Observable.interval(1, TimeUnit.SECONDS)//
                    .map(new Func1<Long, Integer>() {
                        @Override
                        public Integer call(Long aLong) {
                            return aLong.intValue();
                        }
                    })//
                    .take(20);// cause i don't want this thing to run indefinitely

        // -----------------------------------------------------------------------------------
        // Making our observable "HOT" for the purpose of the demo.

        _intsObservable = _intsObservable.share();
        // Do not do this in production! (i blame <NAME> for giving me this clever idea)
        _intsObservable.subscribe();
    }

{'fraction_non_alphanumeric': 0.10549019607843137, 'fraction_numerical': 0.002352941176470588, 'mean_word_length': 1.9847864248098304, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 12, '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': '422395', 'n_tokens_mistral': 1343, 'n_tokens_neox': 1263, 'n_words': 390}