Skip to content

Commit 637d8fb

Browse files
committed
low tech solution for fetching views
1 parent 00f7b44 commit 637d8fb

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

samplekotlin/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ android {
3737

3838
dependencies {
3939
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.10"
40-
implementation "com.github.getstream:stream-chat-android:4.4.0"
40+
implementation "com.github.getstream:stream-chat-android:4.4.1-alpha"
4141
implementation "io.coil-kt:coil:1.0.0"
4242

4343
implementation "androidx.lifecycle:lifecycle-viewmodel:2.3.0-beta1"

samplekotlin/src/main/java/com/example/chattutorial/ChannelActivity.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import android.os.Bundle
66
import androidx.activity.addCallback
77
import androidx.activity.viewModels
88
import androidx.appcompat.app.AppCompatActivity
9+
import com.getstream.sdk.chat.view.ChannelHeaderView
10+
import com.getstream.sdk.chat.view.MessageListView
911
import com.getstream.sdk.chat.viewmodel.ChannelHeaderViewModel
1012
import com.getstream.sdk.chat.viewmodel.MessageInputViewModel
1113
import com.getstream.sdk.chat.viewmodel.bindView
@@ -16,9 +18,7 @@ import com.getstream.sdk.chat.viewmodel.messages.MessageListViewModel.Mode.Threa
1618
import com.getstream.sdk.chat.viewmodel.messages.MessageListViewModel.State.NavigateUp
1719
import com.getstream.sdk.chat.viewmodel.messages.bindView
1820
import io.getstream.chat.android.client.models.Channel
19-
import kotlinx.android.synthetic.main.activity_channel.channelHeaderView
20-
import kotlinx.android.synthetic.main.activity_channel.messageInputView
21-
import kotlinx.android.synthetic.main.activity_channel.messageListView
21+
2222

2323
class ChannelActivity : AppCompatActivity(R.layout.activity_channel) {
2424

@@ -37,9 +37,11 @@ class ChannelActivity : AppCompatActivity(R.layout.activity_channel) {
3737
// TODO set custom AttachmentViewHolderFactory
3838

3939
// Step 2 - Bind the view and ViewModels, they are loosely coupled so it's easy to customize
40+
val channelHeaderView: ChannelHeaderView = findViewById(R.id.channelHeaderView)
41+
val messageListView: MessageListView = findViewById(R.id.messageListView)
4042
channelHeaderViewModel.bindView(channelHeaderView, this)
4143
messageListViewModel.bindView(messageListView, this)
42-
messageInputViewModel.bindView(messageInputView, this)
44+
messageInputViewModel.bindView(findViewById(R.id.messageInputView), this)
4345

4446
// Step 3 - Let the message input know when we open a thread
4547
messageListViewModel.mode.observe(this) { mode ->

samplekotlin/src/main/java/com/example/chattutorial/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import io.getstream.chat.android.client.logger.ChatLogLevel
1212
import io.getstream.chat.android.client.models.Filters
1313
import io.getstream.chat.android.client.models.User
1414
import io.getstream.chat.android.livedata.ChatDomain
15-
import kotlinx.android.synthetic.main.activity_main.channelsView
15+
1616

1717
class MainActivity : AppCompatActivity(R.layout.activity_main) {
1818
override fun onCreate(savedInstanceState: Bundle?) {
@@ -44,7 +44,7 @@ class MainActivity : AppCompatActivity(R.layout.activity_main) {
4444
val viewModel: ChannelsViewModel by viewModels {viewModelFactory}
4545

4646
// Step 4 - Connect the ChannelsViewModel to the ChannelsView, loose coupling makes it easy to customize
47-
viewModel.bindView(channelsView, this)
47+
viewModel.bindView(findViewById(R.id.channelsView), this)
4848
channelsView.setOnChannelClickListener { channel ->
4949
startActivity(ChannelActivity4.newIntent(this, channel))
5050
}

0 commit comments

Comments
 (0)