admin
7 天以前 7f0825f8195a522ed7e8bcdb6347f3a719e06c74
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
package com.weikou.beibeivideo.ui.media;
 
import java.util.List;
 
import com.weikou.beibeivideo.R;
import com.weikou.beibeivideo.entity.CommentReply;
import com.weikou.beibeivideo.util.TimeUtils;
 
import androidx.fragment.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
 
public class VideoReplyAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    private List<CommentReply> list;
 
    public VideoReplyAdapter(FragmentActivity context, List<CommentReply> list) {
        this.list = list;
        inflater = LayoutInflater.from(context);
    }
 
    @Override
    public int getCount() {
        if (list != null) {
            return list.size();
        }
        return 0;
    }
 
    @Override
    public Object getItem(int position) {
        return list.get(position);
    }
 
    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }
 
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.item_reply, null);
            holder.reply_name = (TextView) convertView
                    .findViewById(R.id.reply_name);
            holder.reply_time = (TextView) convertView
                    .findViewById(R.id.reply_time);
            holder.reply_comment = (TextView) convertView
                    .findViewById(R.id.reply_comment);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        CommentReply info = list.get(position);
        holder.reply_name.setText(info.getUser().getNickname());
        holder.reply_time.setText(TimeUtils.millisToLifeString(Long
                .parseLong(info.getCreatetime())));
        holder.reply_comment.setText(info.getContent());
        return convertView;
    }
 
    class ViewHolder {
        TextView reply_name;
        TextView reply_time;
        TextView reply_comment;
    }
}