package com.itant.shiwushu.tool;

import android.content.Context;
import android.graphics.Color;

import com.itant.shiwushu.R;
import com.itant.shiwushu.manager.ThemeManager;

/**
 * Created by Jason on 2018/10/6.
 */

public class ColorTool {
    /**
     * 获取资源文件的颜色十六进制字符串
     * @param context
     * @param id
     * @return
     */
    public static String getColorHexString(Context context, int id) {
        return context.getResources().getString(id);
    }

    public static int getColorPrimary(Context context) {
        int themeMode = ThemeManager.getInstance().getInt(ThemeManager.KEY_THEME_MODE, ThemeManager.THEME_MODE_DEFAULT);
        if (themeMode == ThemeManager.THEME_MODE_DEFAULT) {
            return Color.parseColor(getColorHexString(context, R.color.colorPrimary));
        } else if (themeMode == ThemeManager.THEME_MODE_RED) {
            return Color.parseColor(getColorHexString(context, R.color.red_2));
        } else {
            return Color.parseColor(getColorHexString(context, R.color.blue_alipay));
        }
    }
}
