Blame view

C5/other/com/sunvote/xpadapp/adapter/DocumentAdapter.java 2.5 KB
fac86401   孙向锦   初始化C5 Vote
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
79
80
81
82
83
84
  package com.sunvote.xpadapp.adapter;
  
  import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.TextView;
  
  import com.sunvote.xpadapp.R;
  import com.sunvote.xpadapp.bean.Bills;
  
  import java.util.List;
  
  /**
   * Created by Elvis on 2017/11/30 15:03
   * Email:Eluis@psunsky.com
   * 版权所有:长沙中天电子设计开发有限公司
   * Description: 人大通用版XPadAppRD重构
   */
  public class DocumentAdapter extends BaseAdapter {
      private LayoutInflater mInflater;
      private List<Bills> billInfos = null;
  
      public DocumentAdapter(Context context,List<Bills> datas) {
          this.mInflater = LayoutInflater.from(context);
          billInfos = datas;
      }
  
      @Override
      public int getCount() {
          return billInfos.size();
      }
  
      @Override
      public Object getItem(int position) {
          return billInfos.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public boolean isEnabled(int position) {
          return super.isEnabled(position);
      }
  
      @Override
      public View getView(final int position, View convertView, ViewGroup parent) {
          ViewHolder holder;
          if (convertView == null) {
              convertView = mInflater.inflate(R.layout.list_document_list_item, null);
              holder = new ViewHolder();
              holder.tvNum =  convertView.findViewById(R.id.list_document_item_num);
              holder.tvContent =  convertView.findViewById(R.id.list_document_item_content);
              holder.tvDetail = convertView.findViewById(R.id.list_document_item_detail);
              convertView.setTag(holder);
          } else {
              holder = (ViewHolder) convertView.getTag();
          }
  
          Bills it = billInfos.get(position);
          String number = String.valueOf(it.getBillNo());
          if(it.getSubType() > 0){
              number += "." + it.getSubType() ;
          }
          holder.tvNum.setText(number);
          holder.tvContent.setText(it.getTitle());
          if (it.getBillFile()!=null && it.getBillFile().length() > 0 || it.getBillType() == 20 || it.getBillType() == 999) {
              holder.tvDetail.setVisibility(View.VISIBLE);
          } else {
              holder.tvDetail.setVisibility(View.INVISIBLE);
          }
          return convertView;
      }
  
      public final class ViewHolder {
          public TextView tvNum;
          public TextView tvContent;
          public TextView tvDetail;
      }
  }