xuxiuxi
2017-04-05 39badcdcd8322af6b74406bf13fd5d7e5967520f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package cn.com.basic.face.adapter;
 
import android.content.Context;
import android.widget.ArrayAdapter;
import android.widget.SectionIndexer;
 
import com.bsk.zhangbo.demoforbsk.R;
import com.camnter.easyrecyclerview.adapter.EasyRecyclerViewAdapter;
import com.camnter.easyrecyclerview.holder.EasyRecyclerViewHolder;
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
 
public class PhoneCallFragment {
 
    public static class PhoneCallLeftAdapter extends EasyRecyclerViewAdapter {
 
        @Override
        public int[] getItemLayouts() {
            return new int[]{R.layout.fragment_phone_call_left_row};
        }
 
        @Override
        public void onBindRecycleViewHolder(EasyRecyclerViewHolder viewHolder, int position) {
 
        }
 
        @Override
        public int getRecycleViewItemType(int position) {
            return 0;
        }
 
    }
 
    public class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer
    {
        private HashMap<String, Integer> alphaIndexer;
        private String[] sections;
 
        public AlphabeticalAdapter(Context c, int resource, List<String> data)
        {
            super(c, resource, data);
            alphaIndexer = new HashMap<String, Integer>();
            for (int i = 0; i < data.size(); i++)
            {
                String s = data.get(i).substring(0, 1).toUpperCase();
                if (!alphaIndexer.containsKey(s))
                    alphaIndexer.put(s, i);
            }
 
            Set<String> sectionLetters = alphaIndexer.keySet();
            ArrayList<String> sectionList = new ArrayList<String>(sectionLetters);
            Collections.sort(sectionList);
            sections = new String[sectionList.size()];
            for (int i = 0; i < sectionList.size(); i++)
                sections[i] = sectionList.get(i);
        }
 
        public int getPositionForSection(int section)
        {
            return alphaIndexer.get(sections[section]);
        }
 
        public int getSectionForPosition(int position)
        {
            return 1;
        }
 
        public Object[] getSections()
        {
            return sections;
        }
    }
 
}