improve detekt score

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-08-18 23:39:20 +02:00
parent 9b4f391bab
commit d1ec786907
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
2 changed files with 22 additions and 20 deletions

View File

@ -389,16 +389,16 @@ class ConversationsListController(bundle: Bundle) :
binding.swipeRefreshLayoutView.isEnabled = true binding.swipeRefreshLayoutView.isEnabled = true
} }
searchView!!.onActionViewCollapsed() searchView!!.onActionViewCollapsed()
val activity = getActivity() as MainActivity? val mainActivity = getActivity() as MainActivity?
if (activity != null) { if (mainActivity != null) {
activity.binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator( mainActivity.binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
activity.binding.appBar.context, mainActivity.binding.appBar.context,
R.animator.appbar_elevation_off R.animator.appbar_elevation_off
) )
activity.binding.toolbar.visibility = View.GONE mainActivity.binding.toolbar.visibility = View.GONE
activity.binding.searchToolbar.visibility = View.VISIBLE mainActivity.binding.searchToolbar.visibility = View.VISIBLE
if (resources != null) { if (resources != null) {
viewThemeUtils.resetStatusBar(activity, activity.binding.searchToolbar) viewThemeUtils.resetStatusBar(mainActivity, mainActivity.binding.searchToolbar)
} }
} }
val layoutManager = binding.recyclerView.layoutManager as SmoothScrollLinearLayoutManager? val layoutManager = binding.recyclerView.layoutManager as SmoothScrollLinearLayoutManager?
@ -431,7 +431,6 @@ class ConversationsListController(bundle: Bundle) :
searchItem!!.expandActionView() searchItem!!.expandActionView()
} }
@SuppressLint("LongLogTag")
fun fetchData() { fun fetchData() {
if (isUserStatusAvailable(userManager.currentUser.blockingGet())) { if (isUserStatusAvailable(userManager.currentUser.blockingGet())) {
fetchUserStatusesAndRooms() fetchUserStatusesAndRooms()
@ -443,7 +442,9 @@ class ConversationsListController(bundle: Bundle) :
private fun fetchUserStatusesAndRooms() { private fun fetchUserStatusesAndRooms() {
ncApi.getUserStatuses(credentials, ApiUtils.getUrlForUserStatuses(currentUser!!.baseUrl)) ncApi.getUserStatuses(credentials, ApiUtils.getUrlForUserStatuses(currentUser!!.baseUrl))
.subscribe(object : Observer<StatusesOverall> { .subscribe(object : Observer<StatusesOverall> {
override fun onSubscribe(d: Disposable) {} override fun onSubscribe(d: Disposable) {
// unused atm
}
override fun onNext(statusesOverall: StatusesOverall) { override fun onNext(statusesOverall: StatusesOverall) {
for (status in statusesOverall.ocs!!.data!!) { for (status in statusesOverall.ocs!!.data!!) {
userStatuses[status.userId] = status userStatuses[status.userId] = status
@ -456,7 +457,9 @@ class ConversationsListController(bundle: Bundle) :
fetchRooms() fetchRooms()
} }
override fun onComplete() {} override fun onComplete() {
// unused atm
}
}) })
} }
@ -616,7 +619,7 @@ class ConversationsListController(bundle: Bundle) :
private fun handleHttpExceptions(throwable: Throwable) { private fun handleHttpExceptions(throwable: Throwable) {
if (throwable is HttpException) { if (throwable is HttpException) {
when (throwable.code()) { when (throwable.code()) {
401 -> if (parentController != null && parentController!!.router != null) { HTTP_UNAUTHORIZED -> if (parentController != null && parentController!!.router != null) {
Log.d(TAG, "Starting reauth webview via getParentController()") Log.d(TAG, "Starting reauth webview via getParentController()")
parentController!!.router.pushController( parentController!!.router.pushController(
RouterTransaction.with( RouterTransaction.with(
@ -693,6 +696,7 @@ class ConversationsListController(bundle: Bundle) :
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.newMentionPopupBubble) viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.newMentionPopupBubble)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun checkToShowUnreadBubble() { private fun checkToShowUnreadBubble() {
try { try {
val lastVisibleItem = layoutManager!!.findLastCompletelyVisibleItemPosition() val lastVisibleItem = layoutManager!!.findLastCompletelyVisibleItemPosition()
@ -906,7 +910,8 @@ class ConversationsListController(bundle: Bundle) :
} else if (filesToShare != null && filesToShare!!.isNotEmpty()) { } else if (filesToShare != null && filesToShare!!.isNotEmpty()) {
showSendFilesConfirmDialog() showSendFilesConfirmDialog()
} else { } else {
Toast.makeText(context, context.resources.getString(R.string.nc_common_error_sorry), Toast.LENGTH_LONG) Toast
.makeText(context, context.resources.getString(R.string.nc_common_error_sorry), Toast.LENGTH_LONG)
.show() .show()
} }
} }
@ -970,6 +975,7 @@ class ConversationsListController(bundle: Bundle) :
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun collectDataFromIntent() { private fun collectDataFromIntent() {
filesToShare = ArrayList() filesToShare = ArrayList()
if (activity != null && activity!!.intent != null) { if (activity != null && activity!!.intent != null) {
@ -1107,7 +1113,7 @@ class ConversationsListController(bundle: Bundle) :
if (conversationsListBottomDialog!!.isShowing) { if (conversationsListBottomDialog!!.isShowing) {
conversationsListBottomDialog!!.dismiss() conversationsListBottomDialog!!.dismiss()
} }
}, 2500) }, BOTTOM_SHEET_DELAY)
} }
override fun showDeleteConversationDialog(bundle: Bundle) { override fun showDeleteConversationDialog(bundle: Bundle) {
@ -1164,9 +1170,7 @@ class ConversationsListController(bundle: Bundle) :
onAttach(view!!) onAttach(view!!)
} else if (!otherUserExists) { } else if (!otherUserExists) {
router.setRoot( router.setRoot(
RouterTransaction.with( RouterTransaction.with(ServerSelectionController())
ServerSelectionController()
)
.pushChangeHandler(VerticalChangeHandler()) .pushChangeHandler(VerticalChangeHandler())
.popChangeHandler(VerticalChangeHandler()) .popChangeHandler(VerticalChangeHandler())
) )
@ -1277,9 +1281,11 @@ class ConversationsListController(bundle: Bundle) :
companion object { companion object {
const val TAG = "ConvListController" const val TAG = "ConvListController"
const val UNREAD_BUBBLE_DELAY = 2500 const val UNREAD_BUBBLE_DELAY = 2500
const val BOTTOM_SHEET_DELAY: Long = 2500
private const val KEY_SEARCH_QUERY = "ContactsController.searchQuery" private const val KEY_SEARCH_QUERY = "ContactsController.searchQuery"
const val SEARCH_DEBOUNCE_INTERVAL_MS = 300 const val SEARCH_DEBOUNCE_INTERVAL_MS = 300
const val SEARCH_MIN_CHARS = 2 const val SEARCH_MIN_CHARS = 2
const val HTTP_UNAUTHORIZED = 401
} }
init { init {

View File

@ -310,8 +310,4 @@ class ConversationsListBottomDialog(
val behavior = BottomSheetBehavior.from(bottomSheet as View) val behavior = BottomSheetBehavior.from(bottomSheet as View)
behavior.state = BottomSheetBehavior.STATE_COLLAPSED behavior.state = BottomSheetBehavior.STATE_COLLAPSED
} }
companion object {
private const val TAG = "ConversationOperationDialog"
}
} }