blob: d66d4f014caaa64a89bccb7bda93001af07be092 (
plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
|
package de.thedevstack.conversationsplus.ui.adapter;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import de.thedevstack.conversationsplus.R;
import de.thedevstack.conversationsplus.utils.ui.TextViewUtil;
import de.thedevstack.conversationsplus.utils.ui.ViewUtil;
/**
*/
class MessageViewHolder {
static final int SENT = 0;
static final int RECEIVED = 1;
static final int STATUS = 2;
static final int ME_COMMAND = 3;
View view;
LinearLayout message_box;
Button download_button;
ImageView image;
ImageView indicator;
ImageView indicatorReceived;
TextView time;
TextView messageBody;
ImageView contact_picture;
TextView status_message;
TextView encryption;
TextView remoteFileStatus;
boolean darkBackground;
MessageViewHolder(Activity activity, int type, ViewGroup parent) {
int viewResId = this.resolveViewId(type, parent);
this.view = activity.getLayoutInflater().inflate(viewResId, parent, false);
this.initializeViewElements(type);
}
private int resolveViewId(int type, ViewGroup parent) {
Integer viewResId = null;
switch (type) {
case SENT:
viewResId = R.layout.message_sent;
break;
case RECEIVED:
viewResId = R.layout.message_received;
break;
case STATUS:
viewResId = R.layout.message_status;
break;
case ME_COMMAND:
viewResId = R.layout.message_mecmd;
break;
}
return viewResId;
}
private void initializeViewElements(int type) {
if (SENT == type
|| RECEIVED == type
|| ME_COMMAND == type) {
this.message_box = ViewUtil.visible(view, R.id.message_box);
this.indicator = (ImageView) view.findViewById(R.id.security_indicator);
this.messageBody = (TextView) view.findViewById(R.id.message_body);
this.time = (TextView) view.findViewById(R.id.message_time);
this.indicatorReceived = (ImageView) view.findViewById(R.id.indicator_received);
}
if ((SENT == type
|| RECEIVED == type)) {
this.download_button = (Button) view.findViewById(R.id.download_button);
this.image = (ImageView) view.findViewById(R.id.message_image);
}
if (ME_COMMAND == type
|| (RECEIVED == type)) { // && message.getConversation().getMode() == Conversation.MODE_MULTI --> only muc received msgs
this.contact_picture = ViewUtil.visible(view, R.id.message_photo);
}
if (RECEIVED == type) {
this.encryption = (TextView) view.findViewById(R.id.message_encryption);
}
if (STATUS == type) {
this.contact_picture = ViewUtil.visible(view, R.id.message_photo);
this.status_message = TextViewUtil.visible(view, R.id.status_message);
}
if (SENT == type) { // This field is only useful for sent messages -> because of deletion of own files -> maybe a use case for recvd possible
this.remoteFileStatus = TextViewUtil.gone(view, R.id.remote_file_status);
}
view.setTag(this);
}
}
|