Skip to content

Update tutorial to latest SDK version #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions samplejava/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ android {

dependencies {
// Add new dependencies
implementation "io.getstream:stream-chat-android-ui-components:5.4.0"
implementation "io.getstream:stream-chat-android-ui-components:5.6.1"
implementation "com.google.android.material:material:1.6.1"
implementation "androidx.activity:activity-ktx:1.4.0"
implementation "androidx.activity:activity-ktx:1.5.1"
implementation "io.coil-kt:coil:2.1.0"

// We use the ktx dependency for transforming StateFlow into LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

// Step 1 - Create three separate ViewModels for the views so it's easy
// to customize them individually
MessageListViewModelFactory factory = new MessageListViewModelFactory(cid);
ViewModelProvider.Factory factory = new MessageListViewModelFactory.Builder()
.cid(cid)
.build();
ViewModelProvider provider = new ViewModelProvider(this, factory);
MessageListHeaderViewModel messageListHeaderViewModel = provider.get(MessageListHeaderViewModel.class);
MessageListViewModel messageListViewModel = provider.get(MessageListViewModel.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

// Step 1 - Create three separate ViewModels for the views so it's easy
// to customize them individually
MessageListViewModelFactory factory = new MessageListViewModelFactory(cid);
ViewModelProvider.Factory factory = new MessageListViewModelFactory.Builder()
.cid(cid)
.build();
ViewModelProvider provider = new ViewModelProvider(this, factory);
MessageListHeaderViewModel messageListHeaderViewModel = provider.get(MessageListHeaderViewModel.class);
MessageListViewModel messageListViewModel = provider.get(MessageListViewModel.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.FlowLiveDataConversions;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Transformations;
import androidx.lifecycle.ViewModelProvider;
Expand All @@ -24,6 +23,7 @@
import java.util.List;

import io.getstream.chat.android.client.ChatClient;
import io.getstream.chat.android.client.extensions.FlowExtensions;
import io.getstream.chat.android.client.models.Channel;
import io.getstream.chat.android.client.models.Message;
import io.getstream.chat.android.client.models.TypingEvent;
Expand All @@ -36,9 +36,7 @@
import io.getstream.chat.android.ui.message.list.header.viewmodel.MessageListHeaderViewModelBinding;
import io.getstream.chat.android.ui.message.list.viewmodel.MessageListViewModelBinding;
import io.getstream.chat.android.ui.message.list.viewmodel.factory.MessageListViewModelFactory;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.flow.Flow;
import kotlinx.coroutines.flow.FlowKt;

public class ChannelActivity3 extends AppCompatActivity {

Expand All @@ -65,7 +63,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

// Step 1 - Create three separate ViewModels for the views so it's easy
// to customize them individually
MessageListViewModelFactory factory = new MessageListViewModelFactory(cid);
ViewModelProvider.Factory factory = new MessageListViewModelFactory.Builder()
.cid(cid)
.build();
ViewModelProvider provider = new ViewModelProvider(this, factory);
MessageListHeaderViewModel messageListHeaderViewModel = provider.get(MessageListHeaderViewModel.class);
MessageListViewModel messageListViewModel = provider.get(MessageListViewModel.class);
Expand Down Expand Up @@ -126,8 +126,8 @@ public void handleOnBackPressed() {
// Observe typing events and update typing header depending on its state.
Flow<ChannelState> channelStateFlow = ChatClientExtensions.watchChannelAsState(ChatClient.instance(), cid, 30);
LiveData<TypingEvent> typingEventLiveData = Transformations.switchMap(
FlowLiveDataConversions.asLiveData(channelStateFlow),
channelState -> FlowLiveDataConversions.asLiveData(channelState.getTyping())
FlowExtensions.asLiveData(channelStateFlow),
channelState -> FlowExtensions.asLiveData(channelState.getTyping())
);

typingEventLiveData.observe(this, typingEvent -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

// Step 1 - Create three separate ViewModels for the views so it's easy
// to customize them individually
MessageListViewModelFactory factory = new MessageListViewModelFactory(cid);
ViewModelProvider.Factory factory = new MessageListViewModelFactory.Builder()
.cid(cid)
.build();
ViewModelProvider provider = new ViewModelProvider(this, factory);
MessageListHeaderViewModel messageListHeaderViewModel = provider.get(MessageListHeaderViewModel.class);
MessageListViewModel messageListViewModel = provider.get(MessageListViewModel.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
Filters.in("members", singletonList(user.getId()))
);

ChannelListViewModelFactory factory = new ChannelListViewModelFactory(
filter,
ChannelListViewModel.DEFAULT_SORT
);
ViewModelProvider.Factory factory = new ChannelListViewModelFactory.Builder()
.filter(filter)
.sort(ChannelListViewModel.DEFAULT_SORT)
.build();

ChannelListViewModel channelsViewModel =
new ViewModelProvider(this, factory).get(ChannelListViewModel.class);
Expand Down
6 changes: 3 additions & 3 deletions samplekotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ android {

dependencies {
// Add new dependencies
implementation "io.getstream:stream-chat-android-ui-components:5.4.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.1"
implementation "io.getstream:stream-chat-android-ui-components:5.6.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
implementation "com.google.android.material:material:1.6.1"
implementation "androidx.activity:activity-ktx:1.4.0"
implementation "androidx.activity:activity-ktx:1.5.1"
implementation "io.coil-kt:coil:2.1.0"
}