<commit_before>package com.braintreepayments.testutils;

import android.app.Activity;
import android.support.test.espresso.intent.Intents;
import android.support.test.rule.ActivityTestRule;

import static com.braintreepayments.testutils.SharedPreferencesHelper.getSharedPreferences;

public class BraintreeActivityTestRule<T extends Activity> extends ActivityTestRule<T> {

    public BraintreeActivityTestRule(Class<T> activityClass) {
        super(activityClass);
    }

    public BraintreeActivityTestRule(Class<T> activityClass, boolean initialTouchMode,
            boolean launchActivity) {
        super(activityClass, initialTouchMode, launchActivity);
    }

    @Override
    protected void beforeActivityLaunched() {
        super.beforeActivityLaunched();
        getSharedPreferences().edit().clear().commit();
    }

    @Override
    protected void afterActivityLaunched() {
        Intents.init();
        super.afterActivityLaunched();
    }

    @Override
    protected void afterActivityFinished() {
        super.afterActivityFinished();
        Intents.release();
        getSharedPreferences().edit().clear().commit();
    }
}<commit_msg>Ignore Espresso Intents exception when no activity launched<commit_after>package com.braintreepayments.testutils;

import android.app.Activity;
import android.support.test.espresso.intent.Intents;
import android.support.test.rule.ActivityTestRule;

import static com.braintreepayments.testutils.SharedPreferencesHelper.getSharedPreferences;

public class BraintreeActivityTestRule<T extends Activity> extends ActivityTestRule<T> {

    public BraintreeActivityTestRule(Class<T> activityClass) {
        super(activityClass);
    }

    public BraintreeActivityTestRule(Class<T> activityClass, boolean initialTouchMode,
            boolean launchActivity) {
        super(activityClass, initialTouchMode, launchActivity);
    }

    @Override
    protected void beforeActivityLaunched() {
        super.beforeActivityLaunched();
        getSharedPreferences().edit().clear().commit();
    }

    @Override
    protected void afterActivityLaunched() {
        Intents.init();
        super.afterActivityLaunched();
    }

    @Override
    protected void afterActivityFinished() {
        super.afterActivityFinished();

        try {
            Intents.release();
        } catch (IllegalStateException ignored) {}

        getSharedPreferences().edit().clear().commit();
    }
}
{'fraction_non_alphanumeric': 0.09422367882015567, 'fraction_numerical': 0.0, 'mean_word_length': 3.8356435643564355, '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': '5567315', 'n_tokens_mistral': 639, 'n_tokens_neox': 625, 'n_words': 113}