<commit_before>package com.licaigc;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;

import com.licaigc.trace.Track;

import java.util.HashSet;
import java.util.Set;

import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.TagAliasCallback;

/**
 * Created by walfud on 2016/7/7.
 */
public class AndroidBaseLibrary {
    public static final String TAG = "AndroidBaseLibrary";

    /**
     * Should be application context
     */
    private static Context sContext;

    /**
     * Is host app in debug mode
     */
    private static boolean sIsDebug;

    /**
     * 极光推送初始化
     */
    private static final int MSG_JPUSH_ALIAS = 0x1000;

    private static Handler sHandler;

    /**
     * App Id
     */
    private static int sAppId;

    /**
     * Primary Color
     */
    private static int sPrimaryColor;

    /**
     *  主线程调用
     * @param context
     * @return
     */
    public static final boolean initialize(Context context) {
        return initialize(context, false);
    }
    public static final boolean initialize(Context context, boolean isDebug) {
        sContext = context.getApplicationContext();
        sIsDebug = isDebug;
        sHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                switch (msg.what) {
                    case MSG_JPUSH_ALIAS: {
                        String alias = Track.getRefId();
                        Set<String> tag = new HashSet<>();
                        tag.add(PackageUtils.getVersionName().replace(".", "_") + (sIsDebug ? "_test" : ""));   // 版本号
                        tag.add(ManifestUtils.getMeta("UMENG_CHANNEL"));            // 渠道
                        String pkgName = AndroidBaseLibrary.getContext().getPackageName();
                        if (Constants.PKG_TIMI.compareToIgnoreCase(pkgName) != 0
                                && PackageUtils.isTimiInstalled()) {                // 安装 timi 的用户
                            tag.add("Timi记账");
                        }
                        if (Constants.PKG_TALICAI.compareToIgnoreCase(pkgName) != 0
                                && PackageUtils.isTalicaiInstalled()) {             // 安装 timi 的用户
                            tag.add("她理财");
                        }
                        if (Constants.PKG_GUIHUA.compareToIgnoreCase(pkgName) != 0
                                && PackageUtils.isHaoguihuaInstalled()) {           // 安装 timi 的用户
                            tag.add("好规划");
                        }
                        if (Constants.PKG_JIJINDOU.compareToIgnoreCase(pkgName) != 0
                                && PackageUtils.isJijindouInstalled()) {            // 安装 timi 的用户
                            tag.add("基金豆");
                        }
                        JPushInterface.setAliasAndTags(sContext, alias, tag, sAliasCallback);
                        break;
                    }

                    default:
                        break;
                }
            }
        };

        String pkgName = AndroidBaseLibrary.getContext().getPackageName();
        if (false) {
            // Stub
        } else if (Constants.PKG_TALICAI.equals(pkgName)) {
            sAppId = Constants.APP_ID_TALICAI;
            sPrimaryColor = Constants.APP_PRIMARY_COLOR_TALICAI;
        } else if (Constants.PKG_GUIHUA.equals(pkgName)) {
            sAppId = Constants.APP_ID_GUIHUA;
            sPrimaryColor = Constants.APP_PRIMARY_COLOR_GUIHUA;
        } else if (Constants.PKG_TIMI.equals(pkgName)) {
            sAppId = Constants.APP_ID_TIMI;
            sPrimaryColor = Constants.APP_PRIMARY_COLOR_TIMI;
        } else if (Constants.PKG_JIJINDOU.equals(pkgName)) {
            sAppId = Constants.APP_ID_JIJINDOU;
            sPrimaryColor = Constants.APP_PRIMARY_COLOR_JIJINDOU;
        } else {
            sAppId = Constants.APP_ID_UNKNOWN;
            sPrimaryColor = Constants.APP_PRIMARY_COLOR_UNKNOWN;
        }

        // JPush
        JPushInterface.init(context); // 初始化 JPush
        JPushInterface.stopCrashHandler(context);
        sHandler.sendEmptyMessage(MSG_JPUSH_ALIAS);

        return true;
    }

    /**
     *
     * @return Application context
     */
    public static Context getContext() {
        return sContext;
    }

    public static boolean isDebug() {
        return sIsDebug;
    }

    public static int getAppId() {
        return sAppId;
    }

    public static int getPrimaryColor() {
        return sPrimaryColor;
    }

    //
    private static final TagAliasCallback sAliasCallback = new TagAliasCallback() {
        @Override
        public void gotResult(int code, String alias, Set<String> tags) {
            String logs ;
            switch (code) {<commit_msg>客服说先 stop 再 init...<commit_after>package com.licaigc;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;

import com.licaigc.trace.Track;

import java.util.HashSet;
import java.util.Set;

import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.TagAliasCallback;

/**
 * Created by walfud on 2016/7/7.
 */
public class AndroidBaseLibrary {
    public static final String TAG = "AndroidBaseLibrary";

    /**
     * Should be application context
     */
    private static Context sContext;

    /**
     * Is host app in debug mode
     */
    private static boolean sIsDebug;

    /**
     * 极光推送初始化
     */
    private static final int MSG_JPUSH_ALIAS = 0x1000;

    private static Handler sHandler;

    /**
     * App Id
     */
    private static int sAppId;

    /**
     * Primary Color
     */
    private static int sPrimaryColor;

    /**
     *  主线程调用
     * @param context
     * @return
     */
    public static final boolean initialize(Context context) {
        return initialize(context, false);
    }
    public static final boolean initialize(Context context, boolean isDebug) {
        sContext = context.getApplicationContext();
        sIsDebug = isDebug;
        sHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                switch (msg.what) {
                    case MSG_JPUSH_ALIAS: {
                        String alias = Track.getRefId();
                        Set<String> tag = new HashSet<>();
                        tag.add(PackageUtils.getVersionName().replace(".", "_") + (sIsDebug ? "_test" : ""));   // 版本号
                        tag.add(ManifestUtils.getMeta("UMENG_CHANNEL"));            // 渠道
                        String pkgName = AndroidBaseLibrary.getContext().getPackageName();
                        if (Constants.PKG_TIMI.compareToIgnoreCase(pkgName) != 0
                                && PackageUtils.isTimiInstalled()) {                // 安装 timi 的用户
                            tag.add("Timi记账");
                        }
                        if (Constants.PKG_TALICAI.compareToIgnoreCase(pkgName) != 0
                                && PackageUtils.isTalicaiInstalled()) {             // 安装 timi 的用户
                            tag.add("她理财");
                        }
                        if (Constants.PKG_GUIHUA.compareToIgnoreCase(pkgName) != 0
                                && PackageUtils.isHaoguihuaInstalled()) {           // 安装 timi 的用户
                            tag.add("好规划");
                        }
                        if (Constants.PKG_JIJINDOU.compareToIgnoreCase(pkgName) != 0
                                && PackageUtils.isJijindouInstalled()) {            // 安装 timi 的用户
                            tag.add("基金豆");
                        }
                        JPushInterface.setAliasAndTags(sContext, alias, tag, sAliasCallback);
                        break;
                    }

                    default:
                        break;
                }
            }
        };

        String pkgName = AndroidBaseLibrary.getContext().getPackageName();
        if (false) {
            // Stub
        } else if (Constants.PKG_TALICAI.equals(pkgName)) {
            sAppId = Constants.APP_ID_TALICAI;
            sPrimaryColor = Constants.APP_PRIMARY_COLOR_TALICAI;
        } else if (Constants.PKG_GUIHUA.equals(pkgName)) {
            sAppId = Constants.APP_ID_GUIHUA;
            sPrimaryColor = Constants.APP_PRIMARY_COLOR_GUIHUA;
        } else if (Constants.PKG_TIMI.equals(pkgName)) {
            sAppId = Constants.APP_ID_TIMI;
            sPrimaryColor = Constants.APP_PRIMARY_COLOR_TIMI;
        } else if (Constants.PKG_JIJINDOU.equals(pkgName)) {
            sAppId = Constants.APP_ID_JIJINDOU;
            sPrimaryColor = Constants.APP_PRIMARY_COLOR_JIJINDOU;
        } else {
            sAppId = Constants.APP_ID_UNKNOWN;
            sPrimaryColor = Constants.APP_PRIMARY_COLOR_UNKNOWN;
        }

        // JPush
        JPushInterface.stopCrashHandler(context);
        JPushInterface.init(context); // 初始化 JPush
        sHandler.sendEmptyMessage(MSG_JPUSH_ALIAS);

        return true;
    }

    /**
     *
     * @return Application context
     */
    public static Context getContext() {
        return sContext;
    }

    public static boolean isDebug() {
        return sIsDebug;
    }

    public static int getAppId() {
        return sAppId;
    }

    public static int getPrimaryColor() {
        return sPrimaryColor;
    }

    //
    private static final TagAliasCallback sAliasCallback = new TagAliasCallback() {
        @Override
        public void gotResult(int code, String alias, Set<String> tags) {
            String logs ;
            switch (code) {
{'fraction_non_alphanumeric': 0.09112389562358743, 'fraction_numerical': 0.003081980686254366, 'mean_word_length': 1.5911631620974183, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7317959', 'n_tokens_mistral': 2841, 'n_tokens_neox': 2733, 'n_words': 529}