Commit e814e74d authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update classes using the FrescoHelper and add placeholder to inline attachment/image.

parent f7c75a2f
...@@ -6,7 +6,7 @@ import android.os.Build; ...@@ -6,7 +6,7 @@ import android.os.Build;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import chat.rocket.android.widget.helper.FrescoAvatarHelper; import chat.rocket.android.widget.helper.FrescoHelper;
import com.facebook.drawee.view.SimpleDraweeView; import com.facebook.drawee.view.SimpleDraweeView;
public class RocketChatAvatar extends FrameLayout { public class RocketChatAvatar extends FrameLayout {
...@@ -41,13 +41,8 @@ public class RocketChatAvatar extends FrameLayout { ...@@ -41,13 +41,8 @@ public class RocketChatAvatar extends FrameLayout {
draweeView = findViewById(R.id.drawee_avatar); draweeView = findViewById(R.id.drawee_avatar);
} }
public void loadImage(String imageUrl) { public void loadImage(String imageUri) {
FrescoAvatarHelper FrescoHelper
.loadImage(draweeView, imageUrl); .loadImage(draweeView, imageUri);
}
public void showFailureImage() {
FrescoAvatarHelper
.showFailureImage(draweeView);
} }
} }
\ No newline at end of file
...@@ -14,9 +14,6 @@ import android.view.View; ...@@ -14,9 +14,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import java.util.List;
import chat.rocket.android.widget.AbsoluteUrl; import chat.rocket.android.widget.AbsoluteUrl;
import chat.rocket.android.widget.R; import chat.rocket.android.widget.R;
import chat.rocket.android.widget.helper.FrescoHelper; import chat.rocket.android.widget.helper.FrescoHelper;
...@@ -24,6 +21,8 @@ import chat.rocket.core.models.Attachment; ...@@ -24,6 +21,8 @@ import chat.rocket.core.models.Attachment;
import chat.rocket.core.models.AttachmentAuthor; import chat.rocket.core.models.AttachmentAuthor;
import chat.rocket.core.models.AttachmentField; import chat.rocket.core.models.AttachmentField;
import chat.rocket.core.models.AttachmentTitle; import chat.rocket.core.models.AttachmentTitle;
import com.facebook.drawee.view.SimpleDraweeView;
import java.util.List;
/** /**
*/ */
...@@ -120,8 +119,8 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout { ...@@ -120,8 +119,8 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
authorBox.setVisibility(VISIBLE); authorBox.setVisibility(VISIBLE);
FrescoHelper.setupDraweeAndLoadImage(absolutize(author.getIconUrl()), FrescoHelper
(SimpleDraweeView) attachmentView.findViewById(R.id.author_icon)); .loadImageWithCustomization((SimpleDraweeView) attachmentView.findViewById(R.id.author_icon), absolutize(author.getIconUrl()));
final TextView authorName = (TextView) attachmentView.findViewById(R.id.author_name); final TextView authorName = (TextView) attachmentView.findViewById(R.id.author_name);
authorName.setText(author.getName()); authorName.setText(author.getName());
...@@ -188,7 +187,8 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout { ...@@ -188,7 +187,8 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
thumbImage.setVisibility(GONE); thumbImage.setVisibility(GONE);
} else { } else {
thumbImage.setVisibility(VISIBLE); thumbImage.setVisibility(VISIBLE);
FrescoHelper.setupDraweeAndLoadImage(absolutize(thumbUrl), thumbImage); FrescoHelper
.loadImageWithCustomization(thumbImage, absolutize(thumbUrl));
} }
final TextView refText = (TextView) refBox.findViewById(R.id.text); final TextView refText = (TextView) refBox.findViewById(R.id.text);
...@@ -253,17 +253,18 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout { ...@@ -253,17 +253,18 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
boolean autoloadImage) { boolean autoloadImage) {
if (autoloadImage) { if (autoloadImage) {
load.setVisibility(GONE); load.setVisibility(GONE);
FrescoHelper.setupDraweeAndLoadImage(url, drawee); FrescoHelper
.loadImageWithCustomization(drawee, url);
return; return;
} }
FrescoHelper.setupDrawee(drawee);
load.setOnClickListener(new OnClickListener() { load.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
load.setVisibility(GONE); load.setVisibility(GONE);
load.setOnClickListener(null); load.setOnClickListener(null);
FrescoHelper.loadImage(url, drawee); FrescoHelper
.loadImageWithCustomization(drawee, url);
} }
}); });
} }
......
...@@ -11,12 +11,12 @@ import android.view.LayoutInflater; ...@@ -11,12 +11,12 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import chat.rocket.android.widget.helper.FrescoHelper;
import com.facebook.drawee.view.SimpleDraweeView; import com.facebook.drawee.view.SimpleDraweeView;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import chat.rocket.android.widget.R; import chat.rocket.android.widget.R;
import chat.rocket.android.widget.helper.FrescoHelper;
import chat.rocket.android.widget.helper.ImageFormat; import chat.rocket.android.widget.helper.ImageFormat;
import chat.rocket.core.models.WebContent; import chat.rocket.core.models.WebContent;
import chat.rocket.core.models.WebContentHeaders; import chat.rocket.core.models.WebContentHeaders;
...@@ -95,7 +95,8 @@ public class RocketChatMessageUrlsLayout extends LinearLayout { ...@@ -95,7 +95,8 @@ public class RocketChatMessageUrlsLayout extends LinearLayout {
if (TextUtils.isEmpty(imageURL)) { if (TextUtils.isEmpty(imageURL)) {
image.setVisibility(View.GONE); image.setVisibility(View.GONE);
} else { } else {
FrescoHelper.setupDraweeAndLoadImage(imageURL, image); FrescoHelper
.loadImageWithCustomization(image, imageURL);
image.setVisibility(View.VISIBLE); image.setVisibility(View.VISIBLE);
} }
...@@ -143,17 +144,18 @@ public class RocketChatMessageUrlsLayout extends LinearLayout { ...@@ -143,17 +144,18 @@ public class RocketChatMessageUrlsLayout extends LinearLayout {
boolean autoloadImage) { boolean autoloadImage) {
if (autoloadImage) { if (autoloadImage) {
load.setVisibility(GONE); load.setVisibility(GONE);
FrescoHelper.setupDraweeAndLoadImage(url, drawee); FrescoHelper
.loadImageWithCustomization(drawee, url);
return; return;
} }
FrescoHelper.setupDrawee(drawee);
load.setOnClickListener(new OnClickListener() { load.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
load.setVisibility(GONE); load.setVisibility(GONE);
load.setOnClickListener(null); load.setOnClickListener(null);
FrescoHelper.loadImage(url, drawee); FrescoHelper
.loadImageWithCustomization(drawee, url);
} }
}); });
} }
......
...@@ -106,6 +106,7 @@ ...@@ -106,6 +106,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="150dp" android:layout_height="150dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
fresco:placeholderImage="@drawable/image_dummy"
fresco:actualImageScaleType="fitStart" /> fresco:actualImageScaleType="fitStart" />
<TextView <TextView
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
android:id="@+id/message_inline_image" android:id="@+id/message_inline_image"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="150dp" android:layout_height="150dp"
fresco:placeholderImage="@drawable/image_dummy"
fresco:actualImageScaleType="fitStart" /> fresco:actualImageScaleType="fitStart" />
<TextView <TextView
......
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