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,6 +67,9 @@ @Override public int getRecycleViewItemType(int position) { if (!(getItem(position) instanceof PhoneCallQueryItem)) { return 1; } return 0; } VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/PhoneCallMng.java
@@ -3,6 +3,7 @@ import org.xutils.http.RequestParams; import org.xutils.x; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -14,6 +15,7 @@ import cn.com.basic.face.fragment.PhoneCallFragment; import cn.com.basic.face.util.AppApi; import cn.com.basic.face.service.vo.PhoneCallFragment.PhoneCallQueryItem; import cn.com.basic.face.util.CharacterParser; public class PhoneCallMng { @@ -29,7 +31,23 @@ public void success() { List<PhoneCallQueryItem> list = getList(PhoneCallQueryItem.class); sort(list, isSortByDept); PhoneCallFragment.getInstance().get_fragment_phone_call_left_list_view().show(isSortByDept, list); List allItems = new ArrayList(); String name = ""; String prev = ""; for (int i = 0; i < list.size(); i++) { PhoneCallQueryItem item = list.get(i); if (isSortByDept) { name = CharacterParser.getInstance().getSelling(item.getDeptName()).substring(0, 1); } else { name = CharacterParser.getInstance().getSelling(item.getName()).substring(0, 1); } if (!name.equals(prev)) { allItems.add(name); } allItems.add(item); prev = name; } PhoneCallFragment.getInstance().get_fragment_phone_call_left_list_view().show(isSortByDept, allItems); } }); } @@ -42,12 +60,16 @@ String dept1Name = t1.getDeptName()==null?"":t1.getDeptName(); String dept2Name = t2.getDeptName()==null?"":t2.getDeptName(); if(!dept1Name.equals(dept2Name)) { return dept1Name.compareTo(dept2Name); String dept1Name_a = CharacterParser.getInstance().getSelling(dept1Name).toLowerCase(); String dept1Name_b = CharacterParser.getInstance().getSelling(dept2Name).toLowerCase(); return dept1Name_a.compareTo(dept1Name_b); } } String name1 = t1.getName()==null?"":t1.getName(); String name2 = t2.getName()==null?"":t2.getName(); return name1.compareTo(name2); String dept1Name_a = CharacterParser.getInstance().getSelling(name1).toLowerCase(); String dept1Name_b = CharacterParser.getInstance().getSelling(name2).toLowerCase(); return dept1Name_a.compareTo(dept1Name_b); } }); } VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/CharacterParser.java
@@ -69,7 +69,7 @@ } /** * 汉字转成ASCII码 * * @param chs * @return */ private int getChsAscii(String chs) { public int getChsAscii(String chs) { int asc = 0; try { byte[] bytes = chs.getBytes("gb2312"); @@ -91,7 +91,7 @@ } /** * 单字解析 * * @param str * @return */ public String convert(String str) { public String convert(String str) { String result = null; int ascii = getChsAscii(str); if (ascii > 0 && ascii < 160) { VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/widget/phonecall/PhoneCallLeftListView.java
@@ -36,7 +36,7 @@ initView(); } public void show(boolean isSortByDept, List<PhoneCallFragment.PhoneCallQueryItem> list) { public void show(boolean isSortByDept, List list) { phoneCallLeftAdapter.setList(list); setAdapter(phoneCallLeftAdapter); phoneCallLeftAdapter.setSortByDept(isSortByDept); VisitFace/DemoForBsk/app/src/main/res/layout/fragment_phone_call_left_first_letter_row.xml
New file @@ -0,0 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fresco="http://schemas.android.com/apk/res-auto" android:id="@+id/fragment_phone_call_left_interviewee_row_linear_layout" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="20dp" android:paddingRight="20dp"> <RelativeLayout android:id="@+id/fragment_phone_call_left_row_relativeLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="12dp" android:paddingBottom="12dp"> <TextView android:id="@+id/fragment_phone_call_left_row_first_letter_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="A" android:layout_centerVertical="true" android:textSize="@dimen/text_size_big" android:textColor="@color/colorText_5"/> </RelativeLayout> </LinearLayout>