// Path: app/src/main/java/com/lqr/materialdesigndemo/utils/PinyinUtils.java
// public class PinyinUtils {
// 
//     /**
//      * 根据传入的字符串(包含汉字),得到拼音
//      * 沧晓 -> CANGXIAO
//      * 沧  晓*& -> CANGXIAO
//      * 沧晓f5 -> CANGXIAO
//      *
//      * @param str 字符串
//      * @return
//      */
//     public static String getPinyin(String str) {
// 
//         HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
//         format.setCaseType(HanyuPinyinCaseType.UPPERCASE);
//         format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
// 
//         StringBuilder sb = new StringBuilder();
// 
//         char[] charArray = str.toCharArray();
//         for (int i = 0; i < charArray.length; i++) {
//             char c = charArray[i];
//             // 如果是空格, 跳过
//             if (Character.isWhitespace(c)) {
//                 continue;
//             }
//             if (c >= -127 && c < 128 || !(c >= 0x4E00 && c <= 0x9FA5)) {
//                 // 肯定不是汉字
//                 sb.append(c);
//             } else {
//                 String s = "";
//                 try {
//                     // 通过char得到拼音集合. 单 -> dan, shan 
//                     s = PinyinHelper.toHanyuPinyinStringArray(c, format)[0];
//                     sb.append(s);
//                 } catch (BadHanyuPinyinOutputFormatCombination e) {
//                     e.printStackTrace();
//                     sb.append(s);
//                 }
//             }
//         }
// 
//         return sb.toString();
//     }
// 
// }


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;
import com.lqr.materialdesigndemo.utils.PinyinUtils;
import java.util.List;
package com.lqr.materialdesigndemo.decoration;





public class MyDecorationThree extends RecyclerView.ItemDecoration {

    Context mContext;
    List<String> mData;
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);


    public MyDecorationThree(Context context, List<String> data) {
        mContext = context;
        mData = data;
        paint.setTextSize(sp2px(16));
        paint.setColor(Color.RED);
    }

    @Override
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
        super.onDraw(c, parent, state);
        drawLetterToItemLeft(c, parent);
    }

    private void drawLetterToItemLeft(Canvas c, RecyclerView parent) {
        RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
        if (!(layoutManager instanceof LinearLayoutManager))
            return;
        int childCount = parent.getChildCount();
        for (int i = 0; i < childCount; i++) {
// Path: app/src/main/java/com/lqr/materialdesigndemo/utils/PinyinUtils.java
// public class PinyinUtils {
// 
//     /**
//      * 根据传入的字符串(包含汉字),得到拼音
//      * 沧晓 -> CANGXIAO
//      * 沧  晓*& -> CANGXIAO
//      * 沧晓f5 -> CANGXIAO
//      *
//      * @param str 字符串
//      * @return
//      */
//     public static String getPinyin(String str) {
// 
//         HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
//         format.setCaseType(HanyuPinyinCaseType.UPPERCASE);
//         format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
// 
//         StringBuilder sb = new StringBuilder();
// 
//         char[] charArray = str.toCharArray();
//         for (int i = 0; i < charArray.length; i++) {
//             char c = charArray[i];
//             // 如果是空格, 跳过
//             if (Character.isWhitespace(c)) {
//                 continue;
//             }
//             if (c >= -127 && c < 128 || !(c >= 0x4E00 && c <= 0x9FA5)) {
//                 // 肯定不是汉字
//                 sb.append(c);
//             } else {
//                 String s = "";
//                 try {
//                     // 通过char得到拼音集合. 单 -> dan, shan 
//                     s = PinyinHelper.toHanyuPinyinStringArray(c, format)[0];
//                     sb.append(s);
//                 } catch (BadHanyuPinyinOutputFormatCombination e) {
//                     e.printStackTrace();
//                     sb.append(s);
//                 }
//             }
//         }
// 
//         return sb.toString();
//     }
// 
// }


// Path: app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationThree.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;
import com.lqr.materialdesigndemo.utils.PinyinUtils;
import java.util.List;

package com.lqr.materialdesigndemo.decoration;





public class MyDecorationThree extends RecyclerView.ItemDecoration {

    Context mContext;
    List<String> mData;
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);


    public MyDecorationThree(Context context, List<String> data) {
        mContext = context;
        mData = data;
        paint.setTextSize(sp2px(16));
        paint.setColor(Color.RED);
    }

    @Override
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
        super.onDraw(c, parent, state);
        drawLetterToItemLeft(c, parent);
    }

    private void drawLetterToItemLeft(Canvas c, RecyclerView parent) {
        RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
        if (!(layoutManager instanceof LinearLayoutManager))
            return;
        int childCount = parent.getChildCount();
        for (int i = 0; i < childCount; i++) {
            int position = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition() + i;