summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorwangqi <wangqi@google.com>2018-03-08 12:41:47 -0800
committerCopybara-Service <copybara-piper@google.com>2018-03-08 17:03:33 -0800
commitdb30a13b91ff62021a3a14b30c6b2c1b2f1d5e3d (patch)
tree5c4416b80a0f3136a377ec0e72b335401e2c5674 /java
parent683fdb16ae2f304587bc4ec0ff49e05343483d2c (diff)
Refactor array of RttChatMessage to List.
Bug: 67596257 Test: RttChatMessageTest PiperOrigin-RevId: 188373256 Change-Id: I0f0798a5310225456619757dcca5bbd5df372b91
Diffstat (limited to 'java')
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatAdapter.java16
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatMessage.java4
2 files changed, 10 insertions, 10 deletions
diff --git a/java/com/android/incallui/rtt/impl/RttChatAdapter.java b/java/com/android/incallui/rtt/impl/RttChatAdapter.java
index 69837188a..42bd2c60c 100644
--- a/java/com/android/incallui/rtt/impl/RttChatAdapter.java
+++ b/java/com/android/incallui/rtt/impl/RttChatAdapter.java
@@ -24,7 +24,6 @@ import android.view.View;
import android.view.ViewGroup;
import com.android.dialer.common.LogUtil;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
/** Adapter class for holding RTT chat data. */
@@ -76,21 +75,22 @@ public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolde
if (lastIndexOfRemoteMessage >= 0) {
rttChatMessage = rttMessages.get(lastIndexOfRemoteMessage);
}
- RttChatMessage[] newMessages = RttChatMessage.getRemoteRttChatMessage(rttChatMessage, newText);
+ List<RttChatMessage> newMessages =
+ RttChatMessage.getRemoteRttChatMessage(rttChatMessage, newText);
if (rttChatMessage == null) {
lastIndexOfRemoteMessage = rttMessages.size();
- rttMessages.add(lastIndexOfRemoteMessage, newMessages[0]);
- rttMessages.addAll(Arrays.asList(newMessages).subList(1, newMessages.length));
- notifyItemRangeInserted(lastIndexOfRemoteMessage, newMessages.length);
+ rttMessages.add(lastIndexOfRemoteMessage, newMessages.get(0));
+ rttMessages.addAll(newMessages.subList(1, newMessages.size()));
+ notifyItemRangeInserted(lastIndexOfRemoteMessage, newMessages.size());
lastIndexOfRemoteMessage = rttMessages.size() - 1;
} else {
- rttMessages.set(lastIndexOfRemoteMessage, newMessages[0]);
+ rttMessages.set(lastIndexOfRemoteMessage, newMessages.get(0));
int lastIndex = rttMessages.size();
- rttMessages.addAll(Arrays.asList(newMessages).subList(1, newMessages.length));
+ rttMessages.addAll(newMessages.subList(1, newMessages.size()));
notifyItemChanged(lastIndexOfRemoteMessage);
- notifyItemRangeInserted(lastIndex, newMessages.length);
+ notifyItemRangeInserted(lastIndex, newMessages.size());
}
if (rttMessages.get(lastIndexOfRemoteMessage).isFinished()) {
lastIndexOfRemoteMessage = -1;
diff --git a/java/com/android/incallui/rtt/impl/RttChatMessage.java b/java/com/android/incallui/rtt/impl/RttChatMessage.java
index b2974ef97..fe30364b8 100644
--- a/java/com/android/incallui/rtt/impl/RttChatMessage.java
+++ b/java/com/android/incallui/rtt/impl/RttChatMessage.java
@@ -87,7 +87,7 @@ final class RttChatMessage {
}
/** Convert remote input text into an array of {@code RttChatMessage}. */
- static RttChatMessage[] getRemoteRttChatMessage(
+ static List<RttChatMessage> getRemoteRttChatMessage(
@Nullable RttChatMessage currentMessage, @NonNull String text) {
Iterator<String> splitText = SPLITTER.split(text).iterator();
List<RttChatMessage> messageList = new ArrayList<>();
@@ -118,6 +118,6 @@ final class RttChatMessage {
messageList.add(message);
}
- return messageList.toArray(new RttChatMessage[0]);
+ return messageList;
}
}