Skip to content

Commit 8a78d19

Browse files
committed
Fixed a bug with messages width
1 parent b860f99 commit 8a78d19

File tree

4 files changed

+22
-29
lines changed

4 files changed

+22
-29
lines changed

app/src/main/java/nie/translator/rtranslator/tools/gui/messages/MessagesAdapter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
7272
((ReceivedHolder) holder).sender.setText(message.getMessage().getSender().getName());
7373
}
7474
((MessageHolder) holder).setText(message.getMessage().getText());
75+
//holder.itemView.requestLayout();
7576
}
7677
}
7778

@@ -115,8 +116,7 @@ public void addMessage(GuiMessage message) {
115116

116117
public void setMessage(int index, GuiMessage message) {
117118
mResults.set(index, message);
118-
notifyDataSetChanged(); // not animation
119-
//notifyItemChanged(index); //animation
119+
notifyItemRangeChanged(0, getItemCount());
120120
}
121121

122122
public int getMessageIndex(long messageID){
@@ -153,12 +153,10 @@ public ArrayList<GuiMessage> getMessages() {
153153
/** The layout for each item in the RecicleView list*/
154154
private static class ReceivedHolder extends RecyclerView.ViewHolder implements MessageHolder {
155155
TextView text;
156-
157156
LinearLayout containerSender;
158157
TextView textSender;
159158
TextView sender;
160159

161-
162160
ReceivedHolder(LayoutInflater inflater, ViewGroup parent) {
163161
super(inflater.inflate(R.layout.component_message_received, parent, false));
164162
text = itemView.findViewById(R.id.text_content);

app/src/main/res/layout/component_message_received.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
app:layout_constraintHorizontal_bias="0"
8484
app:layout_constraintStart_toStartOf="parent"
8585
app:layout_constraintTop_toTopOf="parent"
86-
app:layout_constraintVertical_bias="0" />
86+
app:layout_constraintVertical_bias="0"
87+
tool:text="Alice"/>
8788

8889
<TextView
8990
android:id="@+id/text_content2"
@@ -101,7 +102,8 @@
101102
app:layout_constraintEnd_toEndOf="parent"
102103
app:layout_constraintHorizontal_bias="0"
103104
app:layout_constraintStart_toStartOf="parent"
104-
app:layout_constraintTop_toBottomOf="@+id/text_sender" />
105+
app:layout_constraintTop_toBottomOf="@+id/text_sender"
106+
tool:text="Ciao, come stai?"/>
105107
</LinearLayout>
106108
</androidx.cardview.widget.CardView>
107109
</RelativeLayout>

app/src/main/res/layout/fragment_voice_translation.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<androidx.constraintlayout.widget.ConstraintLayout
2626
android:layout_width="match_parent"
2727
android:layout_height="match_parent"
28-
android:animateLayoutChanges="true">
28+
android:animateLayoutChanges="false">
2929

3030
<androidx.recyclerview.widget.RecyclerView
3131
android:id="@+id/recycler_view"
Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
4-
android:layout_height="match_parent">
4+
android:layout_height="wrap_content"
5+
android:orientation="vertical">
56

6-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
7-
android:layout_width="match_parent"
8-
android:layout_height="wrap_content"
9-
android:orientation="vertical">
7+
<include layout="@layout/component_message_received" />
8+
<include layout="@layout/component_message_received" />
9+
<include layout="@layout/component_message_send" />
10+
<include layout="@layout/component_message_received" />
11+
<include layout="@layout/component_message_send" />
12+
<include layout="@layout/component_message_send" />
13+
<include layout="@layout/component_message_received" />
14+
<include layout="@layout/component_message_send" />
15+
<include layout="@layout/component_message_received" />
16+
<include layout="@layout/component_message_send" />
17+
<include layout="@layout/component_message_received" />
1018

11-
<include layout="@layout/component_message_received" />
12-
<include layout="@layout/component_message_received" />
13-
<include layout="@layout/component_message_send" />
14-
<include layout="@layout/component_message_received" />
15-
<include layout="@layout/component_message_send" />
16-
<include layout="@layout/component_message_send" />
17-
18-
<include layout="@layout/component_message_received" />
19-
<include layout="@layout/component_message_send" />
20-
<include layout="@layout/component_message_received" />
21-
<include layout="@layout/component_message_send" />
22-
<include layout="@layout/component_message_received" />
23-
24-
</LinearLayout>
25-
26-
</androidx.constraintlayout.widget.ConstraintLayout>
19+
</LinearLayout>

0 commit comments

Comments
 (0)