| | |
| | | package cn.com.basic.face.adapter;
|
| | |
|
| | | import android.content.Context;
|
| | | import android.view.View;
|
| | | import android.widget.ArrayAdapter;
|
| | | import android.widget.RelativeLayout;
|
| | | import android.widget.SectionIndexer;
|
| | | import android.widget.TextView;
|
| | |
|
| | | import com.bsk.zhangbo.demoforbsk.R;
|
| | |
| | | import com.camnter.easyrecyclerview.holder.EasyRecyclerViewHolder;
|
| | | import com.facebook.drawee.view.SimpleDraweeView;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
|
| | | import cn.com.basic.face.service.vo.PhoneCallFragment.PhoneCallQueryItem;
|
| | |
|
| | | import cn.com.basic.face.base.MainActivity;
|
| | | import cn.com.basic.face.discern.common.CommonVariables;
|
| | | import cn.com.basic.face.discern.query.item.PhoneCallQueryItem;
|
| | | import cn.com.basic.face.util.AppApi;
|
| | |
|
| | | public class PhoneCallFragment {
|
| | |
| | |
|
| | | @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,R.layout.load_more, R.layout.no_more, R.layout.reach_bottom};
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void onBindRecycleViewHolder(EasyRecyclerViewHolder viewHolder, int position) {
|
| | | if (getItem(position) instanceof Integer && ((int)getItem(position))== CommonVariables.Page.reachBottom) {
|
| | | return;
|
| | | }
|
| | | if (getItem(position) instanceof Integer && ((int)getItem(position))== CommonVariables.Page.noMorePage) {
|
| | | return;
|
| | | }
|
| | | if (getItem(position) instanceof Integer && ((int)getItem(position))== CommonVariables.Page.hasMorePages) {
|
| | | TextView load_more_text_view = viewHolder.findViewById(R.id.load_more_text_view);
|
| | | load_more_text_view.setOnClickListener(new View.OnClickListener() {
|
| | | @Override
|
| | | public void onClick(View v) {
|
| | | cn.com.basic.face.fragment.PhoneCallFragment.getInstance().addPageNum();
|
| | | cn.com.basic.face.fragment.PhoneCallFragment.getInstance().append();
|
| | | }
|
| | | });
|
| | | return;
|
| | | }
|
| | | 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);
|
| | | TextView fragment_phone_call_left_interviewee_row_dept = viewHolder.findViewById(R.id.fragment_phone_call_left_interviewee_row_dept);
|
| | | SimpleDraweeView fragment_phone_call_left_row_photo = viewHolder.findViewById(R.id.fragment_phone_call_left_row_photo);
|
| | |
|
| | | if (isSortByDept) {
|
| | | fragment_phone_call_left_row_name.setTextColor(MainActivity.getInstance().getResources().getColor(R.color.colorText_b));
|
| | | fragment_phone_call_left_row_dept.setTextColor(MainActivity.getInstance().getResources().getColor(R.color.colorText_5));
|
| | | fragment_phone_call_left_interviewee_row_dept.setTextColor(MainActivity.getInstance().getResources().getColor(R.color.colorText_5));
|
| | | } else {
|
| | | fragment_phone_call_left_row_name.setTextColor(MainActivity.getInstance().getResources().getColor(R.color.colorText_5));
|
| | | fragment_phone_call_left_row_dept.setTextColor(MainActivity.getInstance().getResources().getColor(R.color.colorText_b));
|
| | | fragment_phone_call_left_interviewee_row_dept.setTextColor(MainActivity.getInstance().getResources().getColor(R.color.colorText_b));
|
| | | }
|
| | | final PhoneCallQueryItem item = getItem(position);
|
| | | fragment_phone_call_left_row_name.setText(item.getName());
|
| | | fragment_phone_call_left_row_dept.setText(item.getDeptName());
|
| | | SimpleDraweeView fragment_phone_call_left_row_photo = viewHolder.findViewById(R.id.fragment_phone_call_left_row_photo);
|
| | | fragment_phone_call_left_row_photo.setImageURI(AppApi.IMAGEURL_BASE+item.getImagePath());
|
| | |
|
| | | fragment_phone_call_left_row_name.setText(item.getCallee());
|
| | | fragment_phone_call_left_interviewee_row_dept.setText(item.getCalleeDept());
|
| | |
|
| | | if (item.getCalleeImage() != null && !"".equals(item.getCalleeImage())) {
|
| | | fragment_phone_call_left_row_photo.setImageURI(AppApi.IMAGE_URL_BASE +item.getCalleeImage());
|
| | | } else {
|
| | | fragment_phone_call_left_row_photo.setImageResource(R.drawable.u68);
|
| | | }
|
| | |
|
| | | RelativeLayout fragment_phone_call_left_row_relativeLayout = viewHolder.findViewById(R.id.fragment_phone_call_left_row_relativeLayout);
|
| | | fragment_phone_call_left_row_relativeLayout.setOnClickListener(new View.OnClickListener(){
|
| | | @Override
|
| | | public void onClick(View v) {
|
| | | cn.com.basic.face.fragment.PhoneCallFragment.getInstance()
|
| | | .get_fragment_phone_call_right_interviewe_cell().setIntervieweeInfo(item);
|
| | | .get_fragment_phone_call_right_interviewee_cell().setIntervieweeInfo(item);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int getRecycleViewItemType(int position) {
|
| | | if (getItem(position) instanceof Integer && ((int)getItem(position))== CommonVariables.Page.reachBottom) {
|
| | | return 4;
|
| | | }
|
| | | if (getItem(position) instanceof Integer && ((int)getItem(position))== CommonVariables.Page.noMorePage) {
|
| | | return 3;
|
| | | }
|
| | | if (getItem(position) instanceof Integer && ((int)getItem(position))== CommonVariables.Page.hasMorePages) {
|
| | | return 2;
|
| | | }
|
| | | 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;
|
| | | }
|
| | | }
|
| | |
|