@@ -75,16 +75,17 @@ public void bindView(View view, Context context, Cursor cursor) {
CompositeMessage msg = CompositeMessage.fromCursor(context, cursor);

long previousTimestamp = -1;
int previousDirection = -1;
int previousItemType = -1;
String previousPeer = null;
if (cursor.moveToPrevious()) {
previousTimestamp = MessageUtils.getMessageTimestamp(cursor);
previousPeer = MessageUtils.getMessagePeer(cursor);
previousDirection = MessageUtils.getMessageDirection(cursor);
cursor.moveToNext();
previousItemType = getItemViewType(cursor);
}
cursor.moveToNext();

headerView.bind(context, msg, mHighlight, previousTimestamp, previousDirection, previousPeer, mAudioPlayerControl);
headerView.bind(context, msg, mHighlight, getItemViewType(cursor),
previousItemType, previousTimestamp, previousPeer, mAudioPlayerControl);
}

@Override
@@ -97,16 +98,20 @@ private boolean isEvent(Cursor cursor) {
return (GroupCommandComponent.supportsMimeType(mime));
}

@Override
public int getItemViewType(int position) {
Cursor c = (Cursor) getItem(position);
int type = c.getInt(CompositeMessage.COLUMN_DIRECTION);
private int getItemViewType(Cursor cursor) {
int type = cursor.getInt(CompositeMessage.COLUMN_DIRECTION);
// MyMessages.DIRECTION_* OR-ed with 2 for group events
if (isEvent(c))
if (isEvent(cursor))
type |= 2;
return type;
}

@Override
public int getItemViewType(int position) {
Cursor c = (Cursor) getItem(position);
return getItemViewType(c);
}

@Override
public int getViewTypeCount() {
// incoming (0), incoming event (2), outgoing (1), outgoing event (3)
@@ -177,8 +177,8 @@ public final void bind(Context context, final Conversation conv) {
}

// no matching resource or draft - hide status icon
boolean incoming = resId < 0 || mConversation.getDraft() != null;
if (incoming) {
boolean incoming = resId < 0;
if (incoming || draft != null) {
mErrorIndicator.setVisibility(GONE);

int unread = mConversation.getUnreadCount();
@@ -205,14 +205,14 @@ public final void bind(Context context, final Conversation conv) {
((Spannable) text).setSpan(STYLE_ITALIC, 0, text.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}
else {
String source = (draft != null) ? draft : conv.getSubject();
String subject = conv.getSubject();
String source = (draft != null) ? draft : subject;

if (source != null) {
if (GroupCommandComponent.supportsMimeType(conv.getMime())) {
String subject = conv.getSubject();
if (GroupCommandComponent.supportsMimeType(conv.getMime()) && draft == null) {
if (incoming) {
// content is in a special format
String[] parsed = MessagesProviderUtils.parseThreadContent(source);
String[] parsed = MessagesProviderUtils.parseThreadContent(subject);
subject = parsed[1];
}
text = new SpannableString(GroupCommandComponent.getTextContent(getContext(), subject, incoming));
@@ -221,7 +221,7 @@ public final void bind(Context context, final Conversation conv) {
else {
if (incoming && conv.isGroupChat()) {
// content is in a special format
String[] parsed = MessagesProviderUtils.parseThreadContent(source);
String[] parsed = MessagesProviderUtils.parseThreadContent(subject);
contact = parsed[0] != null ? Contact.findByUserId(context, parsed[0]) : null;
source = parsed[1];

@@ -101,8 +101,8 @@ public void afterInflate(int direction, boolean event) {
mBalloonTheme.inflate(stub);
}

public final void bind(Context context, final CompositeMessage msg,
final Pattern highlight, long previousTimestamp, int previousDirection, String previousPeer,
public final void bind(Context context, final CompositeMessage msg, final Pattern highlight,
int itemType, int previousItemType, long previousTimestamp, String previousPeer,
Object... args) {

mMessage = msg;
@@ -116,9 +116,8 @@ public final void bind(Context context, final CompositeMessage msg,
mDateHeader.setVisibility(View.GONE);
// same day, check if it's also same direction and user
// some themes will use this information to group messages together
int msgDirection = mMessage.getDirection();
String msgPeer = MessageUtils.getMessagePeer(mMessage);
sameMessageBlock = (msgDirection == previousDirection && msgPeer.equals(previousPeer));
sameMessageBlock = (itemType == previousItemType && msgPeer.equals(previousPeer));
}
else {
mDateHeader.setText(MessageUtils.formatDateString(context, msgTs));
@@ -24,11 +24,11 @@ allprojects {
appVersionName = "4.0.0-alpha8"
targetSdkVersion = 22
compileSdkVersion = 25
buildToolsVersion = '25.0.0'
buildToolsVersion = '25.0.1'
smackVersion = project(':client-common-java').smackVersion
spongyCastleVersion = '1.54.0.0'
appcompatVersion = '25.0.1'
googlePlayServicesVersion = '9.8.0'
googlePlayServicesVersion = '10.0.0'
}
}