package com.tofly.ghrq_route.common.util;

import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.ForegroundColorSpan;

/**
 * Created by lihualong on 2017/5/27.
 */

public class TextUtilOfPatrol {


    public static final int NAME_HEAD = Color.parseColor("#FF393636");
    public static final int NAME_CONTENT = Color.parseColor("#CD626060");
    public static final int DOWNLOADING = Color.parseColor("#FE084986");
    public static final int CAN_DOWNLOAD = Color.parseColor("#D70C146B");

    public static final int TYPE_HEAD = Color.parseColor("#FEBF45D5");
    public static final int TYPE_CONTENT = Color.parseColor("#FF393636");
    public static final int SIZE_HEAD = Color.parseColor("#FEBF45D5");
    public static final int SIZE_CONTENT = Color.parseColor("#FF393636");
    public static final int TIME_HEAD = Color.parseColor("#FEBF45D5");
    public static final int TIME_CONTENT = Color.parseColor("#FF393636");





    public static Spannable toTurnStyle(String in, int headSize, int contentSize,int headColor,
                                        int contentColor) {
        int start = in.indexOf("：");
        int end = in.length();
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(in);
        spannableStringBuilder.setSpan(new AbsoluteSizeSpan(headSize), 0, start, Spanned
                .SPAN_INCLUSIVE_INCLUSIVE);
        spannableStringBuilder.setSpan(new ForegroundColorSpan(headColor), 0,
                start, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        spannableStringBuilder.setSpan(new ForegroundColorSpan(contentColor),
                start,
                end, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        spannableStringBuilder.setSpan(new AbsoluteSizeSpan(contentSize), start, end, Spanned
                .SPAN_INCLUSIVE_INCLUSIVE);
        return spannableStringBuilder;
    }

}
