Skip to content

Commit

Permalink
Added 2.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rimdoo committed Dec 21, 2021
1 parent 4b34216 commit 7688166
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

### v2.2.2 (Dec 21, 2021) with Core SDK `v3.1.3`
* Improved stability.

### v2.2.1 (Dec 10, 2021) with Core SDK `v3.1.1`
* Improved stability.

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enablerD8=true

UIKIT_VERSION = 2.2.1
UIKIT_VERSION = 2.2.2
UIKIT_VERSION_CODE = 1

2 changes: 1 addition & 1 deletion uikit-custom-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
// implementation project(":uikit")
implementation "com.sendbird.sdk:uikit:2.2.1"
implementation "com.sendbird.sdk:uikit:2.2.2"

implementation "androidx.multidex:multidex:2.0.1"
implementation 'com.google.firebase:firebase-messaging:21.0.0'
Expand Down
2 changes: 1 addition & 1 deletion uikit-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation project(":uikit")
implementation "com.sendbird.sdk:uikit:2.2.1"
implementation "com.sendbird.sdk:uikit:2.2.2"

implementation "androidx.multidex:multidex:2.0.1"
implementation 'com.google.firebase:firebase-messaging:21.0.0'
Expand Down
2 changes: 1 addition & 1 deletion uikit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Sendbird
api 'com.sendbird.sdk:sendbird-android-sdk:3.1.1'
api 'com.sendbird.sdk:sendbird-android-sdk:3.1.3'

implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,30 +163,33 @@ public MessageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewT
entry.getValue().setOnClickListener(v -> {
int messagePosition = viewHolder.getAdapterPosition();
if (messagePosition != NO_POSITION) {
if (listItemClickListener != null) {
listItemClickListener.onIdentifiableItemClick(v, identifier, messagePosition, getItem(messagePosition));
}

// for backward compatibilities
if (listener != null && identifier.equals(ClickableViewIdentifier.Chat.name())) {
listener.onItemClick(v, messagePosition, getItem(messagePosition));
return;
}
if (profileClickListener != null && identifier.equals(ClickableViewIdentifier.Profile.name())) {
profileClickListener.onItemClick(v, messagePosition, getItem(messagePosition));
return;
}

if (listItemClickListener != null) {
listItemClickListener.onIdentifiableItemClick(v, identifier, messagePosition, getItem(messagePosition));
}
}
});

entry.getValue().setOnLongClickListener(v -> {
int messagePosition = viewHolder.getAdapterPosition();
if (messagePosition != NO_POSITION) {
if (listItemLongClickListener != null) {
listItemLongClickListener.onIdentifiableItemLongClick(v, identifier, messagePosition, getItem(messagePosition));
}

// for backward compatibilities
if (longClickListener != null && identifier.equals(ClickableViewIdentifier.Chat.name())) {
longClickListener.onItemLongClick(v, messagePosition, getItem(messagePosition));
return true;
}

if (listItemLongClickListener != null) {
listItemLongClickListener.onIdentifiableItemLongClick(v, identifier, messagePosition, getItem(messagePosition));
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.sendbird.uikit.model;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.sendbird.android.BaseMessage;
import com.sendbird.android.MessageListParams;
import com.sendbird.android.log.Logger;
import com.sendbird.uikit.utils.DateUtils;

Expand All @@ -22,6 +22,7 @@ enum Order {
}

private final Order order;
@NonNull
private final TreeSet<BaseMessage> messages;
private final Map<String, BaseMessage> timelineMap = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -197,14 +198,18 @@ public void updateAll(@NonNull List<BaseMessage> messages) {
/**
* @return the latest message.
*/
@Nullable
public BaseMessage getLatestMessage() {
if (messages.isEmpty()) return null;
return order == Order.DESC ? messages.first() : messages.last();
}

/**
* @return the oldest message.
*/
@Nullable
public BaseMessage getOldestMessage() {
if (messages.isEmpty()) return null;
return order == Order.DESC ? messages.last() : messages.first();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,12 @@ public void setMessageCollectionHandler(@Nullable MessageCollectionHandler handl
this.handler = handler;
}

@Nullable
public BaseMessage getOldestMessage() {
return cachedMessages.getOldestMessage();
}

@Nullable
public BaseMessage getLatestMessage() {
return cachedMessages.getLatestMessage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ private void notifyDataSetChanged() {
private void requestChangeLogs(@NonNull BaseChannel channel) {
String channelUrl = channel.getUrl();
int cacheMessageSize = messageCollection.size();
long lastSyncTs = cacheMessageSize > 0 ? messageCollection.getLatestMessage().getCreatedAt() : 0;
BaseMessage lastMessage = messageCollection.getLatestMessage();
long lastSyncTs = cacheMessageSize > 0 && lastMessage != null ? lastMessage.getCreatedAt() : 0;
Logger.dev("++ change logs channel url = %s, lastSyncTs = %s", channelUrl, lastSyncTs);

if (lastSyncTs > 0) {
Expand Down Expand Up @@ -564,7 +565,8 @@ public List<BaseMessage> loadPrevious() throws Exception {
try {
messageLoadState.postValue(MessageLoadState.LOAD_STARTED);
int cacheMessageSize = messageCollection.size();
long ts = cacheMessageSize > 0 ? messageCollection.getOldestMessage().getCreatedAt() : Long.MAX_VALUE;
BaseMessage oldMessage = messageCollection.getOldestMessage();
long ts = cacheMessageSize > 0 && oldMessage != null ? oldMessage.getCreatedAt() : Long.MAX_VALUE;
newMessageList = loadPrevious(ts);
Logger.i("++ load previous message list : " + newMessageList);
messageCollection.addAll(newMessageList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,28 @@ private ImageView pollOrNewImageView(Queue<ImageView> prevImageViews) {
protected void dispatchDraw(Canvas canvas) {
int width = getWidth();
int height = getHeight();

if (isInEditMode()) {
Paint debugPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
debugPaint.setColor(getResources().getColor(R.color.background_400));
canvas.drawRoundRect(new RectF(0, 0, width, height), ROUNDING_RADIUS, ROUNDING_RADIUS, debugPaint);
return;
}

if (tempBitmap == null || tempBitmap.isRecycled() || (tempBitmap.getWidth() != getWidth() || tempBitmap.getHeight() != getHeight())) {
if (width == 0 || height == 0) {
super.dispatchDraw(canvas);
return;
}

if (tempBitmap == null || tempBitmap.isRecycled() || (tempBitmap.getWidth() != width || tempBitmap.getHeight() != height)) {
if (tempBitmap != null) {
tempBitmap.recycle();
}

try {
tempBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
tempBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
} catch (OutOfMemoryError e) {
tempBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565);
tempBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
}
} else {
tempBitmap.eraseColor(Color.TRANSPARENT);
Expand Down

0 comments on commit 7688166

Please sign in to comment.