[Problem/Question]
I am using uikit android. I am populating channel fragment in my activity. When i open this, it cause delay in rendering messages only. Channel header and input pannel is visible but there is 2 second delay in rendering my message list.
// If problem, please fill out the below. If question, please delete.
[UIKit Version]
3.17.0
[Reproduction Steps]
@AndroidEntryPoint
class CustomChannelActivity : AppCompatActivity() {
private var channelUrl: String = EMPTY_STRING
@Inject
lateinit var internalLinkManager: Lazy<InternalLinkManager>
private lateinit var channelViewModel: CustomChannelViewModel
private val viewModel: SendbirdUiKitViewModel by viewModels()
private lateinit var customMessageListAdapter: CustomMessageListAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sendbird_uikit_chat)
viewModel.loadChannel()
// To set customChannelViewmodel and its provider
ViewModelProviders.channel = ChannelViewModelProvider { owner, channelUrl, _, _ ->
channelViewModel = ViewModelProvider(
owner,
CustomChannelViewModelFactory(channelUrl,viewModel)
)[channelUrl, CustomChannelViewModel::class.java]
channelViewModel
}
channelUrl = intent.getStringExtra(CHANNEL_URL) ?: EMPTY_STRING
// To set custom message view for other user
SendbirdUIKit.setCustomParamsHandler(object : CustomParamsHandler {
override fun onBeforeSendUserMessage(params: UserMessageCreateParams) {
params.customType = CUSTOM_VIEW_TYPE_USER_MESSAGE_OTHER.toString()
}
})
// To set Custom message list adapter
AdapterProviders.messageList = MessageListAdapterProvider { channel, uiParams ->
customMessageListAdapter = CustomMessageListAdapter(channelViewModel.hasNext(), channel, uiParams) { deeplink ->
internalLinkManager.get().getIntentByUrl(deeplink)?.let {
if (deeplink.contains(PAYMENT)) {
it.putExtra(INSTANT_PARAM, true)
}
startActivity(it)
}
}
customMessageListAdapter
}
// To set custom channel header
setCustomChannelHeaderInputFooter(this ,viewModel.isTyping) {
hideSoftKeyboard()
onBackPressedDispatcher.onBackPressed()
}
handleIntent(intent)
setObserver()
}
private fun setObserver() {
viewModel.notifyMessageSend.observe(this) { value ->
if (value) {
customMessageListAdapter.refreshView()
}
}
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
intent?.let {
viewModel.resetData()
handleIntent(it)
}
}
private fun handleIntent(intent: Intent) {
val states = arrayOf(
intArrayOf(-android.R.attr.state_enabled),
intArrayOf()
)
val colors = intArrayOf(
ContextCompat.getColor(this, R.color.cool_grey),
ContextCompat.getColor(this, R.color.azure_2)
)
channelUrl = intent.getStringExtra(CHANNEL_URL) ?: EMPTY_STRING
val channelFragment = ChannelFragment.Builder(channelUrl)
.setUseInputLeftButton(false)
.setInputRightButtonIcon(R.drawable.icon_send, ColorStateList(states, colors))
.build()
supportFragmentManager.beginTransaction()
.add(R.id.fragment_container, channelFragment)
.commit()
}
override fun onDestroy() {
super.onDestroy()
SendbirdUIKit.disconnect {
AdapterProviders.resetToDefault()
FragmentProviders.resetToDefault()
ModuleProviders.resetToDefault()
ViewModelProviders.resetToDefault()
}
}
}
[Frequency]
every time i open channel