Loading indicator for message thumbnail view.

This commit is contained in:
Anton Chekulaev 2020-08-28 17:38:19 +10:00
parent 4b57114f25
commit f3bb40e024
2 changed files with 40 additions and 12 deletions

View File

@ -42,7 +42,18 @@
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/message_bubble_bottom_padding" android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
app:footer_text_color="@color/core_white" app:footer_text_color="@android:color/white"
app:footer_icon_color="@color/core_white"/> app:footer_icon_color="@android:color/white"/>
<ProgressBar
android:id="@+id/conversation_thumbnail_load_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxWidth="48dp"
android:maxHeight="48dp"
android:indeterminate="true"
android:visibility="gone"
tools:visibility="visible"/>
</merge> </merge>

View File

@ -3,15 +3,16 @@ package org.thoughtcrime.securesms.components;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.UiThread; import androidx.annotation.UiThread;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.ImageView;
import network.loki.messenger.R;
import org.thoughtcrime.securesms.attachments.Attachment; import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.mms.GlideRequests; import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.mms.Slide; import org.thoughtcrime.securesms.mms.Slide;
@ -21,12 +22,15 @@ import org.thoughtcrime.securesms.util.ThemeUtil;
import java.util.List; import java.util.List;
import network.loki.messenger.R;
public class ConversationItemThumbnail extends FrameLayout { public class ConversationItemThumbnail extends FrameLayout {
private ThumbnailView thumbnail; private ThumbnailView thumbnail;
private AlbumThumbnailView album; private AlbumThumbnailView album;
private ImageView shade; private ImageView shade;
private ConversationItemFooter footer; private ConversationItemFooter footer;
private ProgressBar loadIndicator;
private CornerMask cornerMask; private CornerMask cornerMask;
private Outliner outliner; private Outliner outliner;
private boolean borderless; private boolean borderless;
@ -53,6 +57,7 @@ public class ConversationItemThumbnail extends FrameLayout {
this.album = findViewById(R.id.conversation_thumbnail_album); this.album = findViewById(R.id.conversation_thumbnail_album);
this.shade = findViewById(R.id.conversation_thumbnail_shade); this.shade = findViewById(R.id.conversation_thumbnail_shade);
this.footer = findViewById(R.id.conversation_thumbnail_footer); this.footer = findViewById(R.id.conversation_thumbnail_footer);
this.loadIndicator = findViewById(R.id.conversation_thumbnail_load_indicator);
this.cornerMask = new CornerMask(this); this.cornerMask = new CornerMask(this);
this.outliner = new Outliner(); this.outliner = new Outliner();
@ -136,6 +141,18 @@ public class ConversationItemThumbnail extends FrameLayout {
album.setSlides(glideRequests, slides, showControls); album.setSlides(glideRequests, slides, showControls);
setTouchDelegate(album.getTouchDelegate()); setTouchDelegate(album.getTouchDelegate());
} }
// Display loading indicator if any attachment is in loading state.
{
boolean anyLoading = false;
for (int i = 0; i < slides.size(); i++) {
if (slides.get(i).asAttachment().isInProgress()) {
anyLoading = true;
break;
}
}
loadIndicator.setVisibility(anyLoading ? VISIBLE : GONE);
}
} }
public void setConversationColor(@ColorInt int color) { public void setConversationColor(@ColorInt int color) {