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