<commit_before>package at.favre.lib.hood;

import android.app.Activity;
import android.content.Intent;
import android.support.annotation.NonNull;

import java.util.List;

import at.favre.lib.hood.interfaces.Config;
import at.favre.lib.hood.interfaces.HoodAPI;
import at.favre.lib.hood.interfaces.PageEntry;
import at.favre.lib.hood.interfaces.Pages;
import at.favre.lib.hood.interfaces.Section;
import at.favre.lib.hood.interfaces.actions.BoolConfigAction;
import at.favre.lib.hood.interfaces.actions.ButtonDefinition;
import at.favre.lib.hood.interfaces.actions.OnClickAction;
import at.favre.lib.hood.interfaces.actions.SingleSelectListConfigAction;
import at.favre.lib.hood.interfaces.values.DynamicValue;
import at.favre.lib.hood.noop.HoodNoop;
import at.favre.lib.hood.page.DebugPages;
import at.favre.lib.hood.page.DefaultSection;
import at.favre.lib.hood.page.entries.ActionEntry;
import at.favre.lib.hood.page.entries.ConfigBoolEntry;
import at.favre.lib.hood.page.entries.ConfigSpinnerEntry;
import at.favre.lib.hood.page.entries.HeaderEntry;
import at.favre.lib.hood.page.entries.KeyValueEntry;
import at.favre.lib.hood.page.entries.TextMessageEntry;
import timber.log.Timber;

/**
 * This is the main API. Use the factory methods instead of directly
 * instantiating the internal classes.
 */
public final class Hood {
    private static HoodAPI.Extension extensionInstance;
    private static HoodAPI instance;

    /**
     * This constructor will plant a {@link Timber} tree if none is set.
     */
    private Hood() {
        if (!BuildConfig.NO_OP && Timber.forest().isEmpty()) {
            Timber.plant(new Timber.DebugTree());
        }
    }

    /**
     * Gets the main API. See {@link HoodAPI}
     *
     * @return singleton instance
     */
    public static HoodAPI get() {
        if (instance == null) {
            if (BuildConfig.NO_OP) {
                instance = new HoodNoop();
            } else {
                instance = new HoodImpl();
            }
        }
        return instance;
    }

    /**
     * Gets the extension API. See {@link at.favre.lib.hood.interfaces.HoodAPI.Extension}
     *
     * @return singleton instance
     */
    public static HoodAPI.Extension ext() {
        if (extensionInstance == null) {
            if (BuildConfig.NO_OP) {
                extensionInstance = new HoodNoop.HoodExtensionNoop();
            } else {
                extensionInstance = new HoodExtensionImpl();
            }
        }
        return extensionInstance;
    }

    private static final class HoodImpl implements HoodAPI {
        private HoodImpl() {
        }

        @NonNull
        @Override
        public Pages createPages(@NonNull Config config) {
            return DebugPages.Factory.create(config);
        }

        @Override
        public PageEntry<?> createActionEntry(ButtonDefinition action) {
            return new ActionEntry(action);
        }

        @Override
        public PageEntry<?> createActionEntry(ButtonDefinition actionLeft, ButtonDefinition actionRight) {
            return new ActionEntry(actionLeft, actionRight);
        }

        @Override
        public PageEntry<?> createHeaderEntry(CharSequence header) {
            return new HeaderEntry(header);
        }

        @Override
        public PageEntry<?> createHeaderEntry(CharSequence header, boolean hideInLog) {
            return new HeaderEntry(header, hideInLog);
        }

        @Override
        public PageEntry<?> createMessageEntry(CharSequence message) {
            return new TextMessageEntry(message);<commit_msg>fixes bug where timber would not log<commit_after>package at.favre.lib.hood;

import android.app.Activity;
import android.content.Intent;
import android.support.annotation.NonNull;

import java.util.List;

import at.favre.lib.hood.interfaces.Config;
import at.favre.lib.hood.interfaces.HoodAPI;
import at.favre.lib.hood.interfaces.PageEntry;
import at.favre.lib.hood.interfaces.Pages;
import at.favre.lib.hood.interfaces.Section;
import at.favre.lib.hood.interfaces.actions.BoolConfigAction;
import at.favre.lib.hood.interfaces.actions.ButtonDefinition;
import at.favre.lib.hood.interfaces.actions.OnClickAction;
import at.favre.lib.hood.interfaces.actions.SingleSelectListConfigAction;
import at.favre.lib.hood.interfaces.values.DynamicValue;
import at.favre.lib.hood.noop.HoodNoop;
import at.favre.lib.hood.page.DebugPages;
import at.favre.lib.hood.page.DefaultSection;
import at.favre.lib.hood.page.entries.ActionEntry;
import at.favre.lib.hood.page.entries.ConfigBoolEntry;
import at.favre.lib.hood.page.entries.ConfigSpinnerEntry;
import at.favre.lib.hood.page.entries.HeaderEntry;
import at.favre.lib.hood.page.entries.KeyValueEntry;
import at.favre.lib.hood.page.entries.TextMessageEntry;
import timber.log.Timber;

/**
 * This is the main API. Use the factory methods instead of directly
 * instantiating the internal classes.
 */
public final class Hood {
    private static HoodAPI.Extension extensionInstance;
    private static HoodAPI instance;

    private Hood() {
    }

    /**
     * Gets the main API. See {@link HoodAPI}
     *
     * @return singleton instance
     */
    public static HoodAPI get() {
        if (instance == null) {
            if (BuildConfig.NO_OP) {
                instance = new HoodNoop();
            } else {
                instance = new HoodImpl();
            }
        }
        return instance;
    }

    /**
     * Gets the extension API. See {@link at.favre.lib.hood.interfaces.HoodAPI.Extension}
     *
     * @return singleton instance
     */
    public static HoodAPI.Extension ext() {
        if (extensionInstance == null) {
            if (BuildConfig.NO_OP) {
                extensionInstance = new HoodNoop.HoodExtensionNoop();
            } else {
                extensionInstance = new HoodExtensionImpl();
            }
        }
        return extensionInstance;
    }

    private static final class HoodImpl implements HoodAPI {
        /**
         * This constructor will plant a {@link Timber} tree if none is set.
         */
        private HoodImpl() {
            if (Timber.forest().isEmpty()) {
                Timber.plant(new Timber.DebugTree());
            }
        }

        @NonNull
        @Override
        public Pages createPages(@NonNull Config config) {
            return DebugPages.Factory.create(config);
        }

        @Override
        public PageEntry<?> createActionEntry(ButtonDefinition action) {
            return new ActionEntry(action);
        }

        @Override
        public PageEntry<?> createActionEntry(ButtonDefinition actionLeft, ButtonDefinition actionRight) {
            return new ActionEntry(actionLeft, actionRight);
        }

        @Override
        public PageEntry<?> createHeaderEntry(CharSequence header) {
            return new HeaderEntry(header);
        }

        @Override
        public PageEntry<?> createHeaderEntry(CharSequence header, boolean hideInLog) {
            return new HeaderEntry(header, hideInLog);
        }

        @Override
        public PageEntry<?> createMessageEntry(CharSequence message) {
            return new TextMessageEntry(message);
{'fraction_non_alphanumeric': 0.09865221620119494, 'fraction_numerical': 0.0, 'mean_word_length': 2.6026026026026026, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5038846', 'n_tokens_mistral': 2079, 'n_tokens_neox': 1980, 'n_words': 438}