xuxiuxi
2017-04-07 93cd3d01a96876df00455e335b725388304b012b
VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/adapter/PhoneCallFragment.java
@@ -31,11 +31,16 @@
        @Override
        public int[] getItemLayouts() {
            return new int[]{R.layout.fragment_phone_call_left_row};
            return new int[]{R.layout.fragment_phone_call_left_row, R.layout.fragment_phone_call_left_first_letter_row};
        }
        @Override
        public void onBindRecycleViewHolder(EasyRecyclerViewHolder viewHolder, int position) {
            if (!(getItem(position) instanceof PhoneCallQueryItem)) {
                TextView fragment_phone_call_left_row_first_letter_name = viewHolder.findViewById(R.id.fragment_phone_call_left_row_first_letter_name);
                fragment_phone_call_left_row_first_letter_name.setText(getItem(position)+"".toUpperCase());
                return;
            }
            TextView fragment_phone_call_left_row_name = viewHolder.findViewById(R.id.fragment_phone_call_left_row_name);
            TextView fragment_phone_call_left_row_dept = viewHolder.findViewById(R.id.fragment_phone_call_left_interviewee_row_dept);
            if (isSortByDept) {
@@ -62,51 +67,14 @@
        @Override
        public int getRecycleViewItemType(int position) {
            if (!(getItem(position) instanceof PhoneCallQueryItem)) {
                return 1;
            }
            return 0;
        }
        public void setSortByDept(boolean isSortByDept) {
            this.isSortByDept = isSortByDept;
        }
    }
    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;
        }
    }