File tree Expand file tree Collapse file tree 4 files changed +17
-20
lines changed
java/com/example/chattutorial Expand file tree Collapse file tree 4 files changed +17
-20
lines changed Original file line number Diff line number Diff line change @@ -78,19 +78,16 @@ class ChannelActivity3 : AppCompatActivity() {
7878
7979 // Custom typing info header bar
8080 val nobodyTyping = " nobody is typing"
81- binding.typingHeader.text = nobodyTyping
82-
83- // Asynchronously obtain a ChannelController
84- ChatDomain .instance().useCases.getChannelController(cid).enqueue {
85- val channelController = it.data()
86- // Get back to UI thread and observe typing users
87- runOnUiThread {
88- channelController.typing.observe(this ) { users ->
89- binding.typingHeader.text = when {
90- users.isNotEmpty() -> users.joinToString(prefix = " typing: " ) { user -> user.name }
91- else -> nobodyTyping
92- }
93- }
81+ binding.typingHeaderView.text = nobodyTyping
82+
83+ // Obtain a ChannelController
84+ val channelController = ChatDomain .instance().useCases.getChannelController(cid).execute().data()
85+
86+ // Observe typing users
87+ channelController.typing.observe(this ) { users ->
88+ binding.typingHeaderView.text = when {
89+ users.isNotEmpty() -> users.joinToString(prefix = " typing: " ) { user -> user.name }
90+ else -> nobodyTyping
9491 }
9592 }
9693 }
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ class ChannelActivity4 : AppCompatActivity() {
8181
8282 // Custom typing info header bar
8383 val nobodyTyping = " nobody is typing"
84- binding.typingHeader .text = nobodyTyping
84+ binding.typingHeaderView .text = nobodyTyping
8585
8686 val currentlyTyping = mutableSetOf<String >()
8787
@@ -96,7 +96,7 @@ class ChannelActivity4 : AppCompatActivity() {
9696 is TypingStopEvent -> currentlyTyping.remove(event.user.extraData[" name" ] as String )
9797 }
9898
99- binding.typingHeader .text = when {
99+ binding.typingHeaderView .text = when {
100100 currentlyTyping.isNotEmpty() -> currentlyTyping.joinToString(prefix = " typing: " )
101101 else -> nobodyTyping
102102 }
Original file line number Diff line number Diff line change 1414 app : layout_constraintTop_toTopOf =" parent" />
1515
1616 <TextView
17- android : id =" @+id/typingHeader "
17+ android : id =" @+id/typingHeaderView "
1818 android : layout_width =" match_parent"
1919 android : layout_height =" 31dp"
2020 android : background =" #CCCCCC"
3030 app : layout_constraintBottom_toTopOf =" @+id/messageInputView"
3131 app : layout_constraintEnd_toEndOf =" parent"
3232 app : layout_constraintStart_toStartOf =" parent"
33- app : layout_constraintTop_toBottomOf =" @+id/typingHeader "
33+ app : layout_constraintTop_toBottomOf =" @+id/typingHeaderView "
3434 android : clipToPadding =" false"
3535 android : paddingBottom =" 16dp"
3636 android : background =" #f3f5f8"
Original file line number Diff line number Diff line change 1414 app : layout_constraintTop_toTopOf =" parent" />
1515
1616 <TextView
17- android : id =" @+id/typingHeader "
17+ android : id =" @+id/typingHeaderView "
1818 android : layout_width =" match_parent"
1919 android : layout_height =" 31dp"
2020 android : background =" #CCCCCC"
3030 app : layout_constraintBottom_toTopOf =" @+id/messageInputView"
3131 app : layout_constraintEnd_toEndOf =" parent"
3232 app : layout_constraintStart_toStartOf =" parent"
33- app : layout_constraintTop_toBottomOf =" @+id/typingHeader "
33+ app : layout_constraintTop_toBottomOf =" @+id/typingHeaderView "
3434 android : clipToPadding =" false"
3535 android : paddingBottom =" 16dp"
3636 android : background =" #f3f5f8"
4848 app : layout_constraintEnd_toEndOf =" parent"
4949 app : layout_constraintStart_toStartOf =" parent" />
5050
51- </androidx .constraintlayout.widget.ConstraintLayout>
51+ </androidx .constraintlayout.widget.ConstraintLayout>
You can’t perform that action at this time.
0 commit comments