Commit 67b15ad9 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Coding style improvement

parent 24d4fd72
...@@ -86,10 +86,11 @@ public class Avatar { ...@@ -86,10 +86,11 @@ public class Avatar {
* render avatar into RocketChatAvatar. * render avatar into RocketChatAvatar.
*/ */
public void into(final RocketChatAvatar rocketChatAvatar, boolean showFailureImage) { public void into(final RocketChatAvatar rocketChatAvatar, boolean showFailureImage) {
if (showFailureImage) if (showFailureImage) {
rocketChatAvatar.showFailureImage(); rocketChatAvatar.showFailureImage();
else } else {
rocketChatAvatar.loadImage(getImageUrl()); rocketChatAvatar.loadImage(getImageUrl());
}
} }
public Drawable getTextDrawable(Context context) { public Drawable getTextDrawable(Context context) {
......
...@@ -39,10 +39,12 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe ...@@ -39,10 +39,12 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe
* bind the view model. * bind the view model.
*/ */
public final void bind(PairedMessage pairedMessage, boolean autoloadImages) { public final void bind(PairedMessage pairedMessage, boolean autoloadImages) {
if (pairedMessage.target.getSyncState() != SyncState.SYNCED) if (pairedMessage.target.getSyncState() != SyncState.SYNCED) {
itemView.setAlpha(0.6f); itemView.setAlpha(0.6f);
else }
else {
itemView.setAlpha(1.0f); itemView.setAlpha(1.0f);
}
bindMessage(pairedMessage, autoloadImages); bindMessage(pairedMessage, autoloadImages);
renderNewDayAndSequential(pairedMessage); renderNewDayAndSequential(pairedMessage);
......
...@@ -35,18 +35,20 @@ public class MessageRenderer extends AbstractRenderer<Message> { ...@@ -35,18 +35,20 @@ public class MessageRenderer extends AbstractRenderer<Message> {
* show Avatar image. * show Avatar image.
*/ */
public MessageRenderer avatarInto(RocketChatAvatar rocketChatAvatar, AbsoluteUrl absoluteUrl) { public MessageRenderer avatarInto(RocketChatAvatar rocketChatAvatar, AbsoluteUrl absoluteUrl) {
if (!shouldHandle(rocketChatAvatar)) if (!shouldHandle(rocketChatAvatar)) {
return this; return this;
}
switch (object.getSyncState()){ switch (object.getSyncState()){
case SyncState.FAILED: case SyncState.FAILED:
userRenderer.avatarInto(rocketChatAvatar, absoluteUrl, true); userRenderer.avatarInto(rocketChatAvatar, absoluteUrl, true);
break; break;
default: default:
if (TextUtils.isEmpty(object.getAvatar())) if (TextUtils.isEmpty(object.getAvatar())) {
userRenderer.avatarInto(rocketChatAvatar, absoluteUrl, false); userRenderer.avatarInto(rocketChatAvatar, absoluteUrl, false);
else } else {
rocketChatAvatar.loadImage(object.getAvatar()); rocketChatAvatar.loadImage(object.getAvatar());
}
break; break;
} }
return this; return this;
...@@ -58,10 +60,12 @@ public class MessageRenderer extends AbstractRenderer<Message> { ...@@ -58,10 +60,12 @@ public class MessageRenderer extends AbstractRenderer<Message> {
public MessageRenderer usernameInto(TextView usernameTextView, TextView subUsernameTextView) { public MessageRenderer usernameInto(TextView usernameTextView, TextView subUsernameTextView) {
if (TextUtils.isEmpty(object.getAlias())) { if (TextUtils.isEmpty(object.getAlias())) {
userRenderer.usernameInto(usernameTextView); userRenderer.usernameInto(usernameTextView);
if (subUsernameTextView != null) if (subUsernameTextView != null) {
subUsernameTextView.setVisibility(View.GONE); subUsernameTextView.setVisibility(View.GONE);
} else }
} else {
aliasAndUsernameInto(usernameTextView, subUsernameTextView); aliasAndUsernameInto(usernameTextView, subUsernameTextView);
}
return this; return this;
} }
...@@ -69,8 +73,9 @@ public class MessageRenderer extends AbstractRenderer<Message> { ...@@ -69,8 +73,9 @@ public class MessageRenderer extends AbstractRenderer<Message> {
* show timestamp in textView. * show timestamp in textView.
*/ */
public MessageRenderer timestampInto(TextView textView) { public MessageRenderer timestampInto(TextView textView) {
if (!shouldHandle(textView)) if (!shouldHandle(textView)) {
return this; return this;
}
switch (object.getSyncState()) { switch (object.getSyncState()) {
case SyncState.SYNCING: case SyncState.SYNCING:
...@@ -93,8 +98,9 @@ public class MessageRenderer extends AbstractRenderer<Message> { ...@@ -93,8 +98,9 @@ public class MessageRenderer extends AbstractRenderer<Message> {
* show body in RocketChatMessageLayout. * show body in RocketChatMessageLayout.
*/ */
public MessageRenderer bodyInto(RocketChatMessageLayout rocketChatMessageLayout) { public MessageRenderer bodyInto(RocketChatMessageLayout rocketChatMessageLayout) {
if (!shouldHandle(rocketChatMessageLayout)) if (!shouldHandle(rocketChatMessageLayout)) {
return this; return this;
}
rocketChatMessageLayout.setText(object.getMessage()); rocketChatMessageLayout.setText(object.getMessage());
return this; return this;
...@@ -104,13 +110,14 @@ public class MessageRenderer extends AbstractRenderer<Message> { ...@@ -104,13 +110,14 @@ public class MessageRenderer extends AbstractRenderer<Message> {
* show urls in RocketChatMessageUrlsLayout. * show urls in RocketChatMessageUrlsLayout.
*/ */
public MessageRenderer urlsInto(RocketChatMessageUrlsLayout urlsLayout) { public MessageRenderer urlsInto(RocketChatMessageUrlsLayout urlsLayout) {
if (!shouldHandle(urlsLayout)) if (!shouldHandle(urlsLayout)) {
return this; return this;
}
List<WebContent> webContents = object.getWebContents(); List<WebContent> webContents = object.getWebContents();
if (webContents == null || webContents.size() == 0) if (webContents == null || webContents.size() == 0) {
urlsLayout.setVisibility(View.GONE); urlsLayout.setVisibility(View.GONE);
else { } else {
urlsLayout.setVisibility(View.VISIBLE); urlsLayout.setVisibility(View.VISIBLE);
urlsLayout.setUrls(webContents, autoloadImages); urlsLayout.setUrls(webContents, autoloadImages);
} }
...@@ -125,9 +132,9 @@ public class MessageRenderer extends AbstractRenderer<Message> { ...@@ -125,9 +132,9 @@ public class MessageRenderer extends AbstractRenderer<Message> {
return this; return this;
List<Attachment> attachments = object.getAttachments(); List<Attachment> attachments = object.getAttachments();
if (attachments == null || attachments.size() == 0) if (attachments == null || attachments.size() == 0) {
attachmentsLayout.setVisibility(View.GONE); attachmentsLayout.setVisibility(View.GONE);
else { } else {
attachmentsLayout.setVisibility(View.VISIBLE); attachmentsLayout.setVisibility(View.VISIBLE);
attachmentsLayout.setAbsoluteUrl(absoluteUrl); attachmentsLayout.setAbsoluteUrl(absoluteUrl);
attachmentsLayout.setAttachments(attachments, autoloadImages); attachmentsLayout.setAttachments(attachments, autoloadImages);
...@@ -136,15 +143,17 @@ public class MessageRenderer extends AbstractRenderer<Message> { ...@@ -136,15 +143,17 @@ public class MessageRenderer extends AbstractRenderer<Message> {
} }
private void aliasAndUsernameInto(TextView aliasTextView, TextView usernameTextView) { private void aliasAndUsernameInto(TextView aliasTextView, TextView usernameTextView) {
if (shouldHandle(aliasTextView)) if (shouldHandle(aliasTextView)) {
aliasTextView.setText(object.getAlias()); aliasTextView.setText(object.getAlias());
}
if (shouldHandle(usernameTextView)) { if (shouldHandle(usernameTextView)) {
if (object.getUser() != null) { if (object.getUser() != null) {
usernameTextView.setText("@" + object.getUser().getUsername()); usernameTextView.setText("@" + object.getUser().getUsername());
usernameTextView.setVisibility(View.VISIBLE); usernameTextView.setVisibility(View.VISIBLE);
} else } else {
usernameTextView.setVisibility(View.GONE); usernameTextView.setVisibility(View.GONE);
}
} }
} }
......
...@@ -54,14 +54,17 @@ public class UserViewHolder extends AutocompleteViewHolder<UserItem> { ...@@ -54,14 +54,17 @@ public class UserViewHolder extends AutocompleteViewHolder<UserItem> {
final String suggestion = userItem.getSuggestion(); final String suggestion = userItem.getSuggestion();
if (titleTextView != null) if (titleTextView != null) {
titleTextView.setText(suggestion); titleTextView.setText(suggestion);
}
if (avatar != null) if (avatar != null) {
avatar.loadImage(getImageUrl(suggestion, userItem.getAbsoluteUrl())); avatar.loadImage(getImageUrl(suggestion, userItem.getAbsoluteUrl()));
}
if (status != null) if (status != null) {
status.setImageResource(userItem.getStatusResId()); status.setImageResource(userItem.getStatusResId());
}
} }
@Override @Override
......
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