Commit b575b920 authored by Matheus Jardim's avatar Matheus Jardim

changes to AbstractRenderer.shouldHandle

parent 9064f843
......@@ -79,7 +79,7 @@ ext {
playLibVersion = '10.2.6'
stethoVersion = '1.4.2'
rxbindingVersion = '2.0.0'
rxlifecycleVersion = '2.0.1'
rxlifecycleVersion = '2.1.0'
icepickVersion = '3.2.0'
permissionsdispatcherVersion = '2.4.0'
}
......
package chat.rocket.android.renderer;
import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import chat.rocket.android.renderer.optional.Condition;
......@@ -15,27 +16,28 @@ abstract class AbstractRenderer<T> {
this.object = object;
}
// TODO should we get rid of this simpler version of 'shouldHandle'?
protected boolean shouldHandle(View view) {
return object != null && view != null;
}
protected boolean shouldHandle(View target, Condition additionalCondition, Optional optional,
String key) {
if (target == null || object == null) {
if (optional != null) {
optional.onNoData(key);
}
protected boolean shouldHandle(View target,
@Nullable Condition additionalCondition,
Optional optional,
@Nullable String key) {
if (target == null) {
return false;
}
if (optional != null) {
if (!additionalCondition.isOK()) {
optional.onNoData(key);
return false;
} else {
if (object == null) {
optional.onNoData(key);
} else {
if (additionalCondition == null || additionalCondition.isOK()) {
optional.onDataExists(key);
return true;
} else {
optional.onNoData(key);
}
}
return true;
return false;
}
}
......@@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
......@@ -12,6 +13,7 @@ import com.amulyakhare.textdrawable.TextDrawable;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import chat.rocket.android.widget.AbsoluteUrl;
import chat.rocket.android.widget.R;
import chat.rocket.android.widget.RocketChatAvatar;
......@@ -81,6 +83,7 @@ public class UserViewHolder extends AutocompleteViewHolder<UserItem> {
//REMARK! this is often SVG image! (see: Rocket.Chat:server/startup/avatar.coffee)
try {
final String avatarUrl = "/avatar/" + URLEncoder.encode(username, "UTF-8") + ".jpg";
// TODO why absoluteUrl is nullable? By allowing that, the app tries to load non-existing images
if (absoluteUrl == null) {
return avatarUrl;
}
......
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