Commit 2884d2dc authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Better SyncState.FAILED handling.

parent 9b8ae5be
......@@ -43,11 +43,9 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe
*/
public final void bind(PairedMessage pairedMessage, boolean autoloadImages) {
if (pairedMessage.target.getSyncState() == SyncState.FAILED) {
avatar.setVisibility(View.GONE);
errorImageView.setVisibility(View.VISIBLE);
} else {
errorImageView.setVisibility(View.GONE);
avatar.setVisibility(View.VISIBLE);
}
bindMessage(pairedMessage, autoloadImages);
......@@ -73,10 +71,11 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe
private void setSequential(boolean sequential) {
if (avatar != null) {
if (sequential)
if (sequential) {
avatar.setVisibility(View.GONE);
else
} else {
avatar.setVisibility(View.VISIBLE);
}
}
if (userAndTimeContainer != null) {
......
......@@ -38,13 +38,11 @@ public class MessageRenderer extends AbstractRenderer<Message> {
return this;
}
if(object.getSyncState() != SyncState.FAILED) {
if (TextUtils.isEmpty(object.getAvatar())) {
userRenderer.avatarInto(rocketChatAvatar, absoluteUrl);
// Avatar from oauth providers
} else {
rocketChatAvatar.loadImage(object.getAvatar());
}
if (TextUtils.isEmpty(object.getAvatar())) {
userRenderer.avatarInto(rocketChatAvatar, absoluteUrl);
// Avatar from oauth providers
} else {
rocketChatAvatar.loadImage(object.getAvatar());
}
return this;
}
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:theme="@style/AppTheme">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:theme="@style/AppTheme">
<include layout="@layout/list_item_message_newday" />
<include layout="@layout/list_item_message_newday" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp">
<chat.rocket.android.widget.RocketChatAvatar
android:id="@+id/user_avatar"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="8dp" />
<chat.rocket.android.widget.RocketChatAvatar
android:id="@+id/user_avatar"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="8dp" />
<ImageView
android:id="@+id/errorImageView"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="8dp"
android:tint="@color/colorAccent"
app:srcCompat="@drawable/ic_error_black_24dp"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="48dp"
android:orientation="vertical"
android:layout_marginRight="8dp"
android:layout_marginLeft="48dp">
<LinearLayout
android:id="@+id/user_and_timestamp_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="48dp"
android:orientation="vertical"
android:layout_marginRight="8dp"
android:layout_marginLeft="48dp">
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.RocketChat.Message.Username"
tools:text="John Doe" />
<LinearLayout
android:id="@+id/user_and_timestamp_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Space
android:layout_width="4dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.RocketChat.Message.Username"
tools:text="John Doe" />
<TextView
android:id="@+id/sub_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.RocketChat.Message.SubUsername"
tools:text="\@John Doe" />
<Space
android:layout_width="4dp"
android:layout_height="wrap_content" />
<Space
android:layout_width="@dimen/margin_8"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/sub_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.RocketChat.Message.SubUsername"
tools:text="\@John Doe" />
<TextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
tools:text="12:34" />
<Space
android:layout_width="@dimen/margin_8"
android:layout_height="wrap_content" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
tools:text="12:34" />
</LinearLayout>
<ImageView
android:id="@+id/errorImageView"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:layout_gravity="end"
android:gravity="end"
android:tint="@color/colorRed400"
app:srcCompat="@drawable/ic_error_black_24dp"
android:visibility="gone" />
</LinearLayout>
<chat.rocket.android.widget.message.RocketChatMessageLayout
android:id="@+id/message_body"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<chat.rocket.android.widget.message.RocketChatMessageLayout
android:id="@+id/message_body"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<chat.rocket.android.widget.message.RocketChatMessageUrlsLayout
android:id="@+id/message_urls"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<chat.rocket.android.widget.message.RocketChatMessageUrlsLayout
android:id="@+id/message_urls"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<chat.rocket.android.widget.message.RocketChatMessageAttachmentsLayout
android:id="@+id/message_attachments"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</FrameLayout>
<chat.rocket.android.widget.message.RocketChatMessageAttachmentsLayout
android:id="@+id/message_attachments"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:theme="@style/AppTheme">
<include layout="@layout/list_item_message_newday" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<chat.rocket.android.widget.RocketChatAvatar
android:id="@+id/user_avatar"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="8dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="48dp"
android:orientation="vertical"
android:layout_marginRight="8dp"
android:layout_marginLeft="48dp">
<LinearLayout
android:id="@+id/user_and_timestamp_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:theme="@style/AppTheme">
android:orientation="horizontal">
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.RocketChat.Message.Username"
tools:text="John Doe" />
<include layout="@layout/list_item_message_newday" />
<Space
android:layout_width="@dimen/margin_8"
android:layout_height="wrap_content" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
tools:text="12:34" />
<chat.rocket.android.widget.RocketChatAvatar
android:id="@+id/user_avatar"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="8dp" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<ImageView
android:id="@+id/errorImageView"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="8dp"
android:tint="@color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:layout_gravity="end"
android:gravity="end"
android:tint="@color/colorRed400"
app:srcCompat="@drawable/ic_error_black_24dp"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="48dp"
android:orientation="vertical"
android:layout_marginRight="8dp"
android:layout_marginLeft="48dp">
<LinearLayout
android:id="@+id/user_and_timestamp_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.RocketChat.Message.Username"
tools:text="John Doe" />
<Space
android:layout_width="@dimen/margin_8"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
tools:text="12:34" />
</LinearLayout>
<TextView
android:id="@+id/message_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textStyle="italic"
android:enabled="false" />
</LinearLayout>
</FrameLayout>
<TextView
android:id="@+id/message_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textStyle="italic"
android:enabled="false" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment