# ChannelFragment not refreshing list of messages

**URL:** <https://community.sendbird.com/t/channelfragment-not-refreshing-list-of-messages/2465>\
**Category:** Android\
**Created:** [June 15, 2021, 10:32am UTC](https://community.sendbird.com/t/channelfragment-not-refreshing-list-of-messages/2465 "2021-06-15T10:32:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertoestivill](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/robertoestivill/32/1225_2.png) [@robertoestivill](https://community.sendbird.com/u/robertoestivill)\
**Post date:** [June 15, 2021, 10:32am UTC](https://community.sendbird.com/t/channelfragment-not-refreshing-list-of-messages/2465/1 "2021-06-15T10:32:31Z")

</div>

I’m having issues with `ChannelFragment` not updating the messages list.

In my own fragment, I’m adding a ChannelFragment like so:

 ![1](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/d/d1241cbe8f88590ac424003af7f970901a037eff.png)

Once it’s being displayed in the foreground, I send messages from a different device/user and the `ChannelFragment` doesn’t refresh it’s content.

I’m seeing this in the logs in the screenshot however, which probably means that the message is correctly being delivered to the device, just not displayed on the UI.

It’s worth mentioning that if I re-enter this screen, all the messages are properly loaded and displayed, so it seems to be an issue of refreshing while it’s being displayed.

Should the `ChannelFragment` just work out of the box? Am I missing something here to make this work all the time?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Doo\_Rim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/doo_rim/32/239_2.png) [@Doo\_Rim](https://community.sendbird.com/u/Doo_Rim)\
**Post date:** [June 16, 2021, 12:16am UTC](https://community.sendbird.com/t/channelfragment-not-refreshing-list-of-messages/2465/2 "2021-06-16T00:16:44Z")

</div>

Hi, @robertoestivill  
I think you should debug your `conversationAdapter`.  
How did you implement it?

You should follow this link.

> **[Group channel | UIKit Android SDK | Sendbird Docs](https://sendbird.com/docs/uikit/v1/android/guides/group-channel#2-chat-in-a-channel-3-customize-the-message-list)**
>
> Learn about the key functions of group channels in UIKit.

and our UIKit is Open source. You can see the source code!

> **[sendbird/sendbird-uikit-android-sources](https://github.com/sendbird/sendbird-uikit-android-sources)**
>
> Build chat in minutes with Sendbird UIKit open source code and samples. - sendbird/sendbird-uikit-android-sources

---

<div class="post-metadata">

**Author:** ![robertoestivill](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/robertoestivill/32/1225_2.png) [@robertoestivill](https://community.sendbird.com/u/robertoestivill)\
**Post date:** [June 17, 2021, 7:04am UTC](https://community.sendbird.com/t/channelfragment-not-refreshing-list-of-messages/2465/3 "2021-06-17T07:04:36Z")

</div>

Thanks for the speedy reply @Doo_Rim.  
I have clone the uikit sources repo and actually used it as a based for my adapter.  
Below it’s an example of how the adapter is organized to support 3 custom types messages.  
I don’t think there’s nothing extremely complex about it, but maybe I’m missing something or miss-using some api.

```auto
package com.example.myapp

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import com.sendbird.android.GroupChannel
import com.sendbird.uikit.activities.adapter.MessageListAdapter
import com.sendbird.uikit.activities.viewholder.MessageViewHolder

class ExampleAdapter(
    private val context: Context,
    private val groupChannel: GroupChannel,
) : MessageListAdapter(groupChannel) {

    private val layoutInflater = LayoutInflater.from(context)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MessageViewHolder {
        return when (viewType) {
            VIEW_TYPE_CUSTOM_1 -> createViewHolderCustom1(parent)
            VIEW_TYPE_CUSTOM_2 -> createViewHolderCustom2(parent)
            VIEW_TYPE_CUSTOM_3 -> createViewHolderCustom3(parent)
            else -> super.onCreateViewHolder(parent, viewType)
        }
    }

    override fun getItemViewType(position: Int): Int {
        val message = getItem(position)
        return when (message.customType) {
            MESSAGE_CUSTOM_TYPE_1 -> VIEW_TYPE_CUSTOM_1
            MESSAGE_CUSTOM_TYPE_3 -> VIEW_TYPE_CUSTOM_3
            MESSAGE_CUSTOM_TYPE_2 -> VIEW_TYPE_CUSTOM_2
            else -> super.getItemViewType(position)
        }
    }

    private fun createViewHolderCustom1(parent: ViewGroup): MessageViewHolder {
        ...
    }

    private fun createViewHolderCustom2(parent: ViewGroup): MessageViewHolder {
        ...
    }

    private fun createViewHolderCustom3(parent: ViewGroup): MessageViewHolder {
        ...
    }

    companion object {
        private const val MESSAGE_CUSTOM_TYPE_1 = "custom_message_1"
        private const val MESSAGE_CUSTOM_TYPE_2 = "custom_message_2"
        private const val MESSAGE_CUSTOM_TYPE_3 = "custom_message_3"

        private const val VIEW_TYPE_CUSTOM_1 = 13235
        private const val VIEW_TYPE_CUSTOM_2 = 42395
        private const val VIEW_TYPE_CUSTOM_3 = 89543
    }
}

```

Again, note that most of the time everything works fine, however sometimes, it just doesn’t refresh the message list (almost like if there was no connectivity, but obviously there is as I see the log messages)

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![Doo\_Rim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/doo_rim/32/239_2.png) [@Doo\_Rim](https://community.sendbird.com/u/Doo_Rim)\
**Post date:** [June 17, 2021, 7:42am UTC](https://community.sendbird.com/t/channelfragment-not-refreshing-list-of-messages/2465/4 "2021-06-17T07:42:23Z")

</div>

Following your logs, `runnable=null` means your app is on the background.  
If your app comes back to the foreground, our UIKit retrieves the changelog of the message list.  
Could you give us the repeatable scenario?!

---

<div class="post-metadata">

**Author:** ![robertoestivill](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/robertoestivill/32/1225_2.png) [@robertoestivill](https://community.sendbird.com/u/robertoestivill)\
**Post date:** [June 17, 2021, 12:37pm UTC](https://community.sendbird.com/t/channelfragment-not-refreshing-list-of-messages/2465/5 "2021-06-17T12:37:19Z")

</div>

Well that’s interesting.  
The app was definitely in the foreground, as I was wondering why it wouldn’t update.  
I can not consistently reproduce it though, so I will make sure that I try to isolate the issue when I encounter it again.

---

<div class="post-metadata">

**Author:** ![Doo\_Rim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/doo_rim/32/239_2.png) [@Doo\_Rim](https://community.sendbird.com/u/Doo_Rim)\
**Post date:** [June 17, 2021, 11:05pm UTC](https://community.sendbird.com/t/channelfragment-not-refreshing-list-of-messages/2465/6 "2021-06-17T23:05:51Z")

</div>

Okay! Thank you! If you encounter it, let me know!
