aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui/adapter
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2016-02-04 18:02:03 +0100
committerChristian S <christian@pix-art.de>2016-02-04 18:02:03 +0100
commit14b688e0fbe62a0fef0fadcc20763faa21801d7a (patch)
tree37fc7b87aa21326b0ca7ba97fee84aaf0ea6d3c2 /src/main/java/eu/siacs/conversations/ui/adapter
parent9e96d80e31c5d0455c4b15984eef5709cf1071fc (diff)
parent91ec4839acef3e395e83815f211dd9771af1287e (diff)
Merge remote-tracking branch 'siacs/master' into development
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/adapter')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java42
1 files changed, 36 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 780094585..7755ef08c 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -430,6 +430,19 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.image.setOnLongClickListener(openContextMenu);
}
+ private void loadMoreMessages(Conversation conversation) {
+ conversation.setLastClearHistory(0);
+ conversation.setHasMessagesLeftOnServer(true);
+ conversation.setFirstMamReference(null);
+ long timestamp = conversation.getLastMessageTransmitted();
+ if (timestamp == 0) {
+ timestamp = System.currentTimeMillis();
+ }
+ activity.setMessagesLoaded();
+ activity.xmppConnectionService.getMessageArchiveService().query(conversation, 0, timestamp);
+ Toast.makeText(activity, R.string.fetching_history_from_server,Toast.LENGTH_LONG).show();
+ }
+
@Override
public View getView(int position, View view, ViewGroup parent) {
final Message message = getItem(position);
@@ -488,6 +501,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
view = activity.getLayoutInflater().inflate(R.layout.message_status, parent, false);
viewHolder.contact_picture = (ImageView) view.findViewById(R.id.message_photo);
viewHolder.status_message = (TextView) view.findViewById(R.id.status_message);
+ viewHolder.load_more_messages = (Button) view.findViewById(R.id.load_more_messages);
break;
default:
viewHolder = null;
@@ -504,16 +518,31 @@ public class MessageAdapter extends ArrayAdapter<Message> {
boolean darkBackground = (type == RECEIVED && (!isInValidSession || !mUseWhiteBackground));
if (type == STATUS) {
- if (conversation.getMode() == Conversation.MODE_SINGLE) {
- viewHolder.contact_picture.setImageBitmap(activity
- .avatarService().get(conversation.getContact(),
- activity.getPixel(32)));
- viewHolder.contact_picture.setAlpha(0.5f);
+ if ("LOAD_MORE".equals(message.getBody())) {
+ viewHolder.status_message.setVisibility(View.GONE);
+ viewHolder.contact_picture.setVisibility(View.GONE);
+ viewHolder.load_more_messages.setVisibility(View.VISIBLE);
+ viewHolder.load_more_messages.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ loadMoreMessages(message.getConversation());
+ }
+ });
+ } else {
+ viewHolder.status_message.setVisibility(View.VISIBLE);
+ viewHolder.contact_picture.setVisibility(View.VISIBLE);
+ viewHolder.load_more_messages.setVisibility(View.GONE);
+ if (conversation.getMode() == Conversation.MODE_SINGLE) {
+ viewHolder.contact_picture.setImageBitmap(activity
+ .avatarService().get(conversation.getContact(),
+ activity.getPixel(32)));
+ viewHolder.contact_picture.setAlpha(0.5f);
+ }
viewHolder.status_message.setText(message.getBody());
}
return view;
} else {
- loadAvatar(message,viewHolder.contact_picture);
+ loadAvatar(message, viewHolder.contact_picture);
}
viewHolder.contact_picture
@@ -676,6 +705,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
protected ImageView contact_picture;
protected TextView status_message;
protected TextView encryption;
+ public Button load_more_messages;
}
class BitmapWorkerTask extends AsyncTask<Message, Void, Bitmap> {