Commit b575b920 authored by Matheus Jardim's avatar Matheus Jardim

changes to AbstractRenderer.shouldHandle

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