Przeglądaj źródła

improve detekt and format kotlin code

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 3 lat temu
rodzic
commit
f17e892acd

+ 2 - 2
app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

@@ -2722,12 +2722,12 @@ class ChatController(args: Bundle) :
     }
 
     fun updateAdapterAfterSendReaction(message: ChatMessage, emoji: String) {
-        if (message.reactions == null){
+        if (message.reactions == null) {
             message.reactions = HashMap()
         }
 
         var amount = message.reactions[emoji]
-        if (amount == null){
+        if (amount == null) {
             amount = 0
         }
         message.reactions[emoji] = amount + 1

+ 9 - 2
app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt

@@ -61,7 +61,6 @@ class MessageActionsDialog(
 
     private lateinit var popup: EmojiPopup
 
-    @SuppressLint("ClickableViewAccessibility")
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         dialogMessageActionsBinding = DialogMessageActionsBinding.inflate(layoutInflater)
@@ -87,6 +86,11 @@ class MessageActionsDialog(
                 BuildConfig.DEBUG
         )
 
+        initEmojiMore()
+    }
+
+    @SuppressLint("ClickableViewAccessibility")
+    private fun initEmojiMore() {
         dialogMessageActionsBinding.emojiMore.setOnTouchListener { v, event ->
             if (event.action == MotionEvent.ACTION_DOWN) {
                 if (popup.isShowing) {
@@ -247,11 +251,12 @@ class MessageActionsDialog(
             ?.observeOn(AndroidSchedulers.mainThread())
             ?.subscribe(object : Observer<GenericOverall> {
                 override fun onSubscribe(d: Disposable) {
+                    // unused atm
                 }
 
                 override fun onNext(@NonNull genericOverall: GenericOverall) {
                     val statusCode = genericOverall.ocs.meta.statusCode
-                    if (statusCode == 200 || statusCode == 201) {
+                    if (statusCode == HTTP_OK || statusCode == HTTP_CREATED) {
                         chatController.updateAdapterAfterSendReaction(message, emoji)
                     }
                 }
@@ -270,5 +275,7 @@ class MessageActionsDialog(
         private const val TAG = "MessageActionsDialog"
         private const val ACTOR_LENGTH = 6
         private const val NO_PREVIOUS_MESSAGE_ID: Int = -1
+        private const val HTTP_OK: Int = 200
+        private const val HTTP_CREATED: Int = 201
     }
 }

+ 2 - 0
app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt

@@ -138,6 +138,7 @@ class ShowReactionsDialog(
             ?.observeOn(AndroidSchedulers.mainThread())
             ?.subscribe(object : Observer<ReactionsOverall> {
                 override fun onSubscribe(d: Disposable) {
+                    // unused atm
                 }
 
                 override fun onNext(@NonNull reactionsOverall: ReactionsOverall) {
@@ -187,6 +188,7 @@ class ShowReactionsDialog(
             ?.observeOn(AndroidSchedulers.mainThread())
             ?.subscribe(object : Observer<GenericOverall> {
                 override fun onSubscribe(d: Disposable) {
+                    // unused atm
                 }
 
                 override fun onNext(@NonNull genericOverall: GenericOverall) {

+ 1 - 1
detekt.yml

@@ -1,5 +1,5 @@
 build:
-  maxIssues: 96
+  maxIssues: 95
   weights:
     # complexity: 2
     # LongParameterList: 1