Skip to content

Commit 1f8a1e7

Browse files
committed
Update comments
1 parent 1a148af commit 1f8a1e7

File tree

10 files changed

+36
-23
lines changed

10 files changed

+36
-23
lines changed

samplejava/src/main/java/com/example/chattutorial/ChannelActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
4848
throw new IllegalStateException("Specifying a channel id is required when starting ChannelActivity");
4949
}
5050

51-
// Step 1 - Create 3 separate ViewModels for the views so it's easy to customize one of the components
51+
// Step 1 - Create three separate ViewModels for the views so it's easy
52+
// to customize them individually
5253
MessageListViewModelFactory factory = new MessageListViewModelFactory(cid);
5354
ViewModelProvider provider = new ViewModelProvider(this, factory);
5455
MessageListHeaderViewModel messageListHeaderViewModel = provider.get(MessageListHeaderViewModel.class);
@@ -62,7 +63,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
6263
MessageListViewModelBinding.bind(messageListViewModel, binding.messageListView, this);
6364
MessageInputViewModelBinding.bind(messageInputViewModel, binding.messageInputView, this);
6465

65-
// Step 3 - Let both message list header and message input know when we open a thread
66+
// Step 3 - Let both MessageListHeaderView and MessageInputView know when we open a thread
6667
messageListViewModel.getMode().observe(this, mode -> {
6768
if (mode instanceof Thread) {
6869
Message parentMessage = ((Thread) mode).getParentMessage();

samplejava/src/main/java/com/example/chattutorial/ChannelActivity2.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
4848
throw new IllegalStateException("Specifying a channel id is required when starting ChannelActivity2");
4949
}
5050

51-
// Step 1 - Create 3 separate ViewModels for the views so it's easy to customize one of the components
51+
// Step 1 - Create three separate ViewModels for the views so it's easy
52+
// to customize them individually
5253
MessageListViewModelFactory factory = new MessageListViewModelFactory(cid);
5354
ViewModelProvider provider = new ViewModelProvider(this, factory);
5455
MessageListHeaderViewModel messageListHeaderViewModel = provider.get(MessageListHeaderViewModel.class);
@@ -63,7 +64,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
6364
MessageListViewModelBinding.bind(messageListViewModel, binding.messageListView, this);
6465
MessageInputViewModelBinding.bind(messageInputViewModel, binding.messageInputView, this);
6566

66-
// Step 3 - Let both message list header and message input know when we open a thread
67+
// Step 3 - Let both MessageListHeaderView and MessageInputView know when we open a thread
6768
messageListViewModel.getMode().observe(this, mode -> {
6869
if (mode instanceof Thread) {
6970
Message parentMessage = ((Thread) mode).getParentMessage();

samplejava/src/main/java/com/example/chattutorial/ChannelActivity3.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5656
throw new IllegalStateException("Specifying a channel id is required when starting ChannelActivity3");
5757
}
5858

59-
// Step 1 - Create 3 separate ViewModels for the views so it's easy to customize one of the components
59+
// Step 1 - Create three separate ViewModels for the views so it's easy
60+
// to customize them individually
6061
MessageListViewModelFactory factory = new MessageListViewModelFactory(cid);
6162
ViewModelProvider provider = new ViewModelProvider(this, factory);
6263
MessageListHeaderViewModel messageListHeaderViewModel = provider.get(MessageListHeaderViewModel.class);
@@ -71,7 +72,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7172
MessageListViewModelBinding.bind(messageListViewModel, binding.messageListView, this);
7273
MessageInputViewModelBinding.bind(messageInputViewModel, binding.messageInputView, this);
7374

74-
// Step 3 - Let both message list header and message input know when we open a thread
75+
// Step 3 - Let both MessageListHeaderView and MessageInputView know when we open a thread
7576
messageListViewModel.getMode().observe(this, mode -> {
7677
if (mode instanceof Thread) {
7778
Message parentMessage = ((Thread) mode).getParentMessage();

samplejava/src/main/java/com/example/chattutorial/ChannelActivity4.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5757
throw new IllegalStateException("Specifying a channel id is required when starting ChannelActivity4");
5858
}
5959

60-
// Step 1 - Create 3 separate ViewModels for the views so it's easy to customize one of the components
60+
// Step 1 - Create three separate ViewModels for the views so it's easy
61+
// to customize them individually
6162
MessageListViewModelFactory factory = new MessageListViewModelFactory(cid);
6263
ViewModelProvider provider = new ViewModelProvider(this, factory);
6364
MessageListHeaderViewModel messageListHeaderViewModel = provider.get(MessageListHeaderViewModel.class);

samplejava/src/main/java/com/example/chattutorial/MainActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3030
ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
3131
setContentView(binding.getRoot());
3232

33-
// Step 1 - Set up the client for API calls, the domain for offline storage and the UI components
33+
// Step 1 - Set up the client for API calls, the domain for offline storage
34+
// and the UI components
3435
ChatClient client = new ChatClient.Builder("b67pax5b2wdq", getApplicationContext()).build();
3536
new ChatDomain.Builder(client, getApplicationContext()).build();
3637
new ChatUI.Builder(getApplicationContext()).build();
@@ -62,7 +63,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
6263
ChannelListViewModel channelsViewModel =
6364
new ViewModelProvider(this, factory).get(ChannelListViewModel.class);
6465

65-
// Step 4 - Connect the ChannelListViewModel to the ChannelListView, loose coupling makes it easy to customize
66+
// Step 4 - Connect the ChannelListViewModel to the ChannelListView, loose
67+
// coupling makes it easy to customize
6668
ChannelListViewModelBinding.bind(channelsViewModel, binding.channelListView, this);
6769
binding.channelListView.setChannelItemClickListener(channel -> {
6870
startActivity(ChannelActivity4.newIntent(this, channel));

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class ChannelActivity : AppCompatActivity() {
3434
"Specifying a channel id is required when starting ChannelActivity"
3535
}
3636

37-
// Step 1 - Create 3 separate ViewModels for the views so it's easy to customize one of the components
37+
// Step 1 - Create three separate ViewModels for the views so it's easy
38+
// to customize them individually
3839
val factory = MessageListViewModelFactory(cid)
3940
val messageListHeaderViewModel: MessageListHeaderViewModel by viewModels { factory }
4041
val messageListViewModel: MessageListViewModel by viewModels { factory }
@@ -47,8 +48,8 @@ class ChannelActivity : AppCompatActivity() {
4748
messageListViewModel.bindView(binding.messageListView, this)
4849
messageInputViewModel.bindView(binding.messageInputView, this)
4950

50-
// Step 3 - Let both message list header and message input know when we open a thread
51-
// Note: the .observe support was added in kotlin 1.4, upgrade kotlin to support this syntax
51+
// Step 3 - Let both MessageListHeaderView and MessageInputView know when we open a thread
52+
// Note: the observe syntax used here requires Kotlin 1.4
5253
messageListViewModel.mode.observe(this) { mode ->
5354
when (mode) {
5455
is Thread -> {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class ChannelActivity2 : AppCompatActivity() {
3434
"Specifying a channel id is required when starting ChannelActivity2"
3535
}
3636

37-
// Step 1 - Create 3 separate ViewModels for the views so it's easy to customize one of the components
37+
// Step 1 - Create three separate ViewModels for the views so it's easy
38+
// to customize them individually
3839
val factory = MessageListViewModelFactory(cid)
3940
val messageListHeaderViewModel: MessageListHeaderViewModel by viewModels { factory }
4041
val messageListViewModel: MessageListViewModel by viewModels { factory }
@@ -48,8 +49,8 @@ class ChannelActivity2 : AppCompatActivity() {
4849
messageListViewModel.bindView(binding.messageListView, this)
4950
messageInputViewModel.bindView(binding.messageInputView, this)
5051

51-
// Step 3 - Let both message list header and message input know when we open a thread
52-
// Note: the .observe support was added in kotlin 1.4, upgrade kotlin to support this syntax
52+
// Step 3 - Let both MessageListHeaderView and MessageInputView know when we open a thread
53+
// Note: the observe syntax used here requires Kotlin 1.4
5354
messageListViewModel.mode.observe(this) { mode ->
5455
when (mode) {
5556
is Thread -> {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class ChannelActivity3 : AppCompatActivity() {
3636
"Specifying a channel id is required when starting ChannelActivity3"
3737
}
3838

39-
// Step 1 - Create 3 separate ViewModels for the views so it's easy to customize one of the components
39+
// Step 1 - Create three separate ViewModels for the views so it's easy
40+
// to customize them individually
4041
val factory = MessageListViewModelFactory(cid)
4142
val messageListHeaderViewModel: MessageListHeaderViewModel by viewModels { factory }
4243
val messageListViewModel: MessageListViewModel by viewModels { factory }
@@ -50,8 +51,8 @@ class ChannelActivity3 : AppCompatActivity() {
5051
messageListViewModel.bindView(binding.messageListView, this)
5152
messageInputViewModel.bindView(binding.messageInputView, this)
5253

53-
// Step 3 - Let both message list header and message input know when we open a thread
54-
// Note: the .observe support was added in kotlin 1.4, upgrade kotlin to support this syntax
54+
// Step 3 - Let both MessageListHeaderView and MessageInputView know when we open a thread
55+
// Note: the observe syntax used here requires Kotlin 1.4
5556
messageListViewModel.mode.observe(this) { mode ->
5657
when (mode) {
5758
is Thread -> {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class ChannelActivity4 : AppCompatActivity() {
3939
"Specifying a channel id is required when starting ChannelActivity"
4040
}
4141

42-
// Step 1 - Create 3 separate ViewModels for the views so it's easy to customize one of the components
42+
// Step 1 - Create three separate ViewModels for the views so it's easy
43+
// to customize them individually
4344
val factory = MessageListViewModelFactory(cid)
4445
val messageListHeaderViewModel: MessageListHeaderViewModel by viewModels { factory }
4546
val messageListViewModel: MessageListViewModel by viewModels { factory }
@@ -53,8 +54,8 @@ class ChannelActivity4 : AppCompatActivity() {
5354
messageListViewModel.bindView(binding.messageListView, this)
5455
messageInputViewModel.bindView(binding.messageInputView, this)
5556

56-
// Step 3 - Let both message list header and message input know when we open a thread
57-
// Note: the .observe support was added in kotlin 1.4, upgrade kotlin to support this syntax
57+
// Step 3 - Let both MessageListHeaderView and MessageInputView know when we open a thread
58+
// Note: the observe syntax used here requires Kotlin 1.4
5859
messageListViewModel.mode.observe(this) { mode ->
5960
when (mode) {
6061
is Thread -> {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class MainActivity : AppCompatActivity() {
2525
binding = ActivityMainBinding.inflate(layoutInflater)
2626
setContentView(binding.root)
2727

28-
// Step 1 - Set up the client for API calls, the domain for offline storage and the UI components
28+
// Step 1 - Set up the client for API calls, the domain for offline storage
29+
// and the UI components
2930
val client = ChatClient.Builder("b67pax5b2wdq", applicationContext).build()
3031
ChatDomain.Builder(client, applicationContext).build()
3132
ChatUI.Builder(applicationContext).build()
@@ -53,7 +54,9 @@ class MainActivity : AppCompatActivity() {
5354
val viewModelFactory = ChannelListViewModelFactory(filter, ChannelListViewModel.DEFAULT_SORT)
5455
val viewModel: ChannelListViewModel by viewModels { viewModelFactory }
5556

56-
// Step 4 - Connect the ChannelListViewModel to the ChannelListView, loose coupling makes it easy to customize
57+
// Step 4 - Connect the ChannelListViewModel to the ChannelListView, loose
58+
// coupling makes it easy to customize
59+
// Note: the listener syntax used here requires Kotlin 1.4
5760
viewModel.bindView(binding.channelListView, this)
5861
binding.channelListView.setChannelItemClickListener { channel ->
5962
startActivity(ChannelActivity4.newIntent(this, channel))

0 commit comments

Comments
 (0)