Rongyun instant messaging SDK, set the avatar to round corner, the difference between 4. X and 5. X — tips for rongyun instant chat SDK

Time:2021-8-11

Rongyun instant messaging SDK, set the avatar to round corner, the difference between 4. X and 5. X — tips for rongyun instant chat SDK

Background:

Recently, the new app of the company needs to add instant messaging function. It is impossible to realize it quickly. (deadline also can’t resist wow). It is chosen from every mature SDK manufacturer. Each has its own advantages and disadvantages. Finally, the SDK will be selected by the point soldiers, who has the final say.

His official website and document address:
Official website:https://www.rongcloud.cn/
file:https://docs.rongcloud.cn/v4

Of course, this task still falls on me. I use their SDK with UI (they have two kinds of SDK with UI and without UI. The SDK without UI only has instant messaging capability. All UIs need to be implemented by developers. The SDK with UI encapsulates some basic interfaces, such as session list, Conversation interface for chatting with others). Recently, their family also iterated on the large version of imkit (4. X — > 5.0). I followed them to iterate, and directly upgraded the version 4.0.1.1 SDK used in the project to version 5.0

Knowledge points:

The UI in the rongyun SDK is a rectangular avatar, both in the session list and the session interface. However, our project needs a circular avatar, so I need to customize it again

4. X version

In version 4. X, I changed the XML layout file directly
This is the avatar of the conversation interface, and so is the avatar of the conversation list

In RC_ item_ Modify the value of rccornerradius = "3DP" configuration in the message.xml configuration file. Set the head fillet size.

Version 5.0

In version 5.0, rongyun changed the image library from imageloader to glide during this iteration, so this modification is more convenient and easier to read
You can set it directly in the code:

RongConfigCenter.featureConfig().setKitImageEngine(new GlideKitImageEngine() {
            @Override
            public void loadConversationListPortrait(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) {
                Glide.with(imageView).load(url)
                        .apply(RequestOptions.bitmapTransform(new CircleCrop()))
                        .into(imageView);
            }

            @Override
            public void loadConversationPortrait(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) {
                Glide.with(imageView).load(url)
                        .apply(RequestOptions.bitmapTransform(new CircleCrop()))
                        .into(imageView);
            }
        });