From 305ec470c8b8cfa321d7ef88d42d4c129ae73df8 Mon Sep 17 00:00:00 2001 From: Sowjanya Kota <101803542+sowjanyakch@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:07:48 +0100 Subject: [PATCH] format code and suppress KtLint CheckResult rule --- .../ConversationsListActivity.kt | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index c9825447f3..0aa943d055 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -198,7 +198,7 @@ class ConversationsListActivity : FilterConversationFragment.MENTION to false, FilterConversationFragment.UNREAD to false ) - val searchBehaviorSubject = BehaviorSubject.createDefault(false) + val searchBehaviorSubject = BehaviorSubject.createDefault(false) private val onBackPressedCallback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { @@ -222,7 +222,6 @@ class ConversationsListActivity : onBackPressedDispatcher.addCallback(this, onBackPressedCallback) } - override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) @@ -277,6 +276,7 @@ class ConversationsListActivity : showSearchOrToolbar() } + fun filterConversation() { val accountId = UserIdUtils.getIdForUser(userManager.currentUser.blockingGet()) filterState[FilterConversationFragment.UNREAD] = ( @@ -329,6 +329,7 @@ class ConversationsListActivity : ) && (conversation.unreadMessages > 0) ) + FilterConversationFragment.UNREAD -> result = result && (conversation.unreadMessages > 0) } } @@ -513,7 +514,7 @@ class ConversationsListActivity : // cancel any pending searches searchHelper!!.cancelSearch() binding?.swipeRefreshLayoutView?.isRefreshing = false - searchBehaviorSubject.onNext(false ) + searchBehaviorSubject.onNext(false) } binding?.swipeRefreshLayoutView?.isEnabled = true searchView!!.onActionViewCollapsed() @@ -605,6 +606,7 @@ class ConversationsListActivity : fun showSnackbar(text: String) { Snackbar.make(binding.root, text, Snackbar.LENGTH_LONG).show() } + fun fetchRooms() { val includeStatus = isUserStatusAvailable(userManager.currentUser.blockingGet()) @@ -649,8 +651,7 @@ class ConversationsListActivity : if (!filterState.containsValue(true)) filterableConversationItems = conversationItems filterConversation() adapter!!.updateDataSet(filterableConversationItems, false) - Handler().postDelayed({ checkToShowUnreadBubble() }, UNREAD_BUBBLE_DELAY - .toLong()) + Handler().postDelayed({ checkToShowUnreadBubble() }, UNREAD_BUBBLE_DELAY.toLong()) fetchOpenConversations(apiVersion) binding?.swipeRefreshLayoutView?.isRefreshing = false }, { throwable: Throwable -> @@ -826,9 +827,9 @@ class ConversationsListActivity : super.onScrollStateChanged(recyclerView, newState) if (newState == RecyclerView.SCROLL_STATE_IDLE) { val isSearchActive = searchBehaviorSubject.value - if(!isSearchActive!!){ - checkToShowUnreadBubble() - } + if (!isSearchActive!!) { + checkToShowUnreadBubble() + } } } }) @@ -877,7 +878,7 @@ class ConversationsListActivity : binding?.newMentionPopupBubble?.let { viewThemeUtils.material.colorMaterialButtonPrimaryFilled(it) } } - + @SuppressLint("CheckResult") @Suppress("Detekt.TooGenericExceptionCaught") private fun checkToShowUnreadBubble() { searchBehaviorSubject.subscribe { value -> @@ -904,12 +905,13 @@ class ConversationsListActivity : Log.d( TAG, "A NPE was caught when trying to show the unread popup bubble. This might happen when the " + - "user already left the conversations-list screen so the popup bubble is not available anymore.", + "user already left the conversations-list screen so the popup bubble is not available " + + "anymore.", e ) } } - } + } } private fun hasUnreadItems(conversation: Conversation) = @@ -923,7 +925,6 @@ class ConversationsListActivity : startActivity(intent) } - private fun dispose(disposable: Disposable?) { if (disposable != null && !disposable.isDisposed) { disposable.dispose()