# How to avoid empty view in community screen during page loading

**URL:** <https://forum.social.plus/t/how-to-avoid-empty-view-in-community-screen-during-page-loading/548>\
**Category:** Android\
**Created:** [October 14, 2022, 5:48am UTC](https://forum.social.plus/t/how-to-avoid-empty-view-in-community-screen-during-page-loading/548 "2022-10-14T05:48:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![IMKalpataru](https://avatars.discourse-cdn.com/v4/letter/i/e56c9b/32.png) [@IMKalpataru](https://forum.social.plus/u/IMKalpataru)\
**Post date:** [October 14, 2022, 5:48am UTC](https://forum.social.plus/t/how-to-avoid-empty-view-in-community-screen-during-page-loading/548/1 "2022-10-14T05:48:26Z")

</div>

Hi @SocialPlus_Support , When we click on Profile or MyFeed or Community page if there is any post items available we are showing an empty view (Your Feed is Empty )for few seconds . If post data is available we don’t want to show the empty view anytime . The issue is that while retrieving data from observable the UI gets updated with empty view and then it gets updated with list of data.  
Could you please guide us how can we avoid this empty view. Please refer video.

Video Link:

> **[Screen Recording 2022-10-13 at 7.19.44 PM.mov](https://drive.google.com/file/d/1x7yrJYoEkn32KMRv5X39trqCB-NyEoJI/view?usp=sharing)**
>
> Google Drive file.

sample code for updating UI:  
fun setupFeedRecyclerview() {  
println("second time adapter count " + adapter.itemCount)  
adapter.addLoadStateListener { loadStates →   
when (val refreshState = loadStates.mediator?.refresh) {  
is LoadState.NotLoading → {  
if (loadStates.source.refresh is LoadState.NotLoading && loadStates.append.endOfPaginationReached)  
{ if(adapter.itemCount \< 1 )  
{  
isFirstLoad = false  
binding.emptyViewContainer.visibility = View.VISIBLE  
binding.recyclerViewFeed.visibility = View.GONE  
handleEmptyState(getEmptyView(getInflater()))  
}  
else{  
binding.emptyViewContainer.removeAllViews()  
handleLoadedState(adapter.itemCount)  
}  
}  
binding.progressBar.visibility = View.GONE  
}  
is LoadState.Error → {  
isFirstLoad = false  
binding.progressBar.visibility = View.GONE  
handleErrorState(AmityError.from(refreshState.error))  
}  
is LoadState.Loading → {  
handleLoadingState()  
}  
else → {}  
}  
}  
println(“check my data” + adapter.snapshot().items)  
binding.recyclerViewFeed.adapter = adapter  
binding.recyclerViewFeed.layoutManager = LinearLayoutManager(context)  
getItemDecorations().forEach { binding.recyclerViewFeed.addItemDecoration(it) }  
binding.recyclerViewFeed.addOnScrollListener(object : RecyclerView.OnScrollListener() {  
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {  
super.onScrollStateChanged(recyclerView, newState)  
if (newState == SCROLL\_STATE\_SETTLING) {  
getViewModel().sendPendingReactions()  
}  
}  
})  
adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {  
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {  
super.onItemRangeInserted(positionStart, itemCount)  
if (positionStart == 0) {  
binding.recyclerViewFeed.smoothScrollToPosition(0)  
}  
}  
})  
// if(adapter.snapshot().items.isEmpty()){  
// handleEmptyState(getEmptyView(getInflater()))  
// }else{  
// binding.emptyViewContainer.removeAllViews()  
// handleLoadedState(adapter.itemCount)  
// }  
}

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [October 14, 2022, 4:04pm UTC](https://forum.social.plus/t/how-to-avoid-empty-view-in-community-screen-during-page-loading/548/2 "2022-10-14T16:04:46Z")

</div>

Hi @IMKalpataru unfortunately, this is by design, I will help share this as a feedback to our engineering team.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [October 17, 2022, 1:25pm UTC](https://forum.social.plus/t/how-to-avoid-empty-view-in-community-screen-during-page-loading/548/3 "2022-10-17T13:25:27Z")

</div>

Hello @IMKalpataru I’ve just got updated from the team that they already released the enhancement for this empty view issue in our latest uikit version which should be version 2.26.1 🙏

---

<div class="post-metadata">

**Author:** ![IMKalpataru](https://avatars.discourse-cdn.com/v4/letter/i/e56c9b/32.png) [@IMKalpataru](https://forum.social.plus/u/IMKalpataru)\
**Post date:** [October 17, 2022, 1:30pm UTC](https://forum.social.plus/t/how-to-avoid-empty-view-in-community-screen-during-page-loading/548/4 "2022-10-17T13:30:58Z")

</div>

Yeah, I am using the same version, still I will check and update you @SocialPlus_Support. Thanks
