diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-09-22 16:20:53 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-09-22 16:20:53 +0900 |
commit | f44d5800abfee1fe45a4712d8674837b9f405e1a (patch) | |
tree | 6264ee249b47f30a4d5ffcc556b530d750950df3 /app | |
parent | b32e2d718fd48b5afa2f90146f87244fbda65f50 (diff) | |
download | SmileEssence-f44d5800abfee1fe45a4712d8674837b9f405e1a.tar.gz |
ツイートの表示がおかしかった(りぷらいかどうかわからない)のを直した(りぐれっしょん)
Diffstat (limited to 'app')
10 files changed, 69 insertions, 273 deletions
diff --git a/app/app.iml b/app/app.iml index 21ab5450..512f9daa 100644 --- a/app/app.iml +++ b/app/app.iml @@ -63,7 +63,6 @@ <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> - <excludeFolder url="file://$MODULE_DIR$/build/data-binding-info" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" /> @@ -88,11 +87,7 @@ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" /> - <excludeFolder url="file://$MODULE_DIR$/build/layout-info" /> <excludeFolder url="file://$MODULE_DIR$/build/outputs" /> - <excludeFolder url="file://$MODULE_DIR$/build/reports" /> - <excludeFolder url="file://$MODULE_DIR$/build/retrolambda" /> - <excludeFolder url="file://$MODULE_DIR$/build/test-results" /> <excludeFolder url="file://$MODULE_DIR$/build/tmp" /> </content> <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" /> diff --git a/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/EventViewModelTest.java b/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/EventViewModelTest.java index 922fd718..0c54eb5e 100644 --- a/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/EventViewModelTest.java +++ b/app/src/androidTest/java/net/lacolaco/smileessence/viewmodel/EventViewModelTest.java @@ -49,11 +49,11 @@ public class EventViewModelTest extends InstrumentationTestCase { Context context = getInstrumentation().getTargetContext(); Status status = mock.getReplyMock(); User source = mock.getUserMock(); - EventViewModel event = new EventViewModel(EnumEvent.FAVORITED, source, status); + EventViewModel event = new EventViewModel(EventViewModel.EnumEvent.FAVORITED, source, status); assertEquals(source.getId(), event.getSourceUserID()); assertEquals(status.getId(), event.getTargetStatusID()); assertEquals(context.getString(R.string.format_event_favorited, source.getScreenName()), event.getFormattedString(context)); - event = new EventViewModel(EnumEvent.RECEIVE_MESSAGE, source); + event = new EventViewModel(EventViewModel.EnumEvent.RECEIVE_MESSAGE, source); Configuration config = context.getResources().getConfiguration(); config.locale = Locale.ENGLISH; context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java b/app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java index c4e3fcd6..bc95414f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java @@ -33,7 +33,6 @@ import net.lacolaco.smileessence.entity.User; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.Notificator; import net.lacolaco.smileessence.preference.UserPreferenceHelper; -import net.lacolaco.smileessence.viewmodel.EnumEvent; import net.lacolaco.smileessence.viewmodel.EventViewModel; import net.lacolaco.smileessence.viewmodel.MessageViewModel; import net.lacolaco.smileessence.viewmodel.StatusViewModel; @@ -90,10 +89,10 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect StatusFilter.getInstance().filter(vm); if (tweet.isRetweet()) { if (tweet.getUser().getId() == account.getUserId()) { - addToHistory(new EventViewModel(EnumEvent.RETWEETED, tweet.getUser(), tweet)); + addToHistory(new EventViewModel(EventViewModel.EnumEvent.RETWEETED, tweet.getUser(), tweet)); } } else if (account.getCachedUser() != null && tweet.getMentions().contains(account.getCachedUser().getScreenName())) { - EventViewModel mentioned = new EventViewModel(EnumEvent.MENTIONED, tweet.getUser(), tweet); + EventViewModel mentioned = new EventViewModel(EventViewModel.EnumEvent.MENTIONED, tweet.getUser(), tweet); Notificator.getInstance().publish(mentioned.getFormattedString()); } } @@ -139,7 +138,7 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect public void onFavorite(twitter4j.User source, twitter4j.User target, Status favoritedStatus) { Tweet tweet = Tweet.fromTwitter(favoritedStatus, account.getUserId()); if (isMe(User.fromTwitter(target))) { - addToHistory(new EventViewModel(EnumEvent.FAVORITED, User.fromTwitter(source), tweet)); + addToHistory(new EventViewModel(EventViewModel.EnumEvent.FAVORITED, User.fromTwitter(source), tweet)); } // unneeded? // if (isMe(User.fromTwitter(source))) { @@ -152,7 +151,7 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect Tweet tweet = Tweet.fromTwitter(unfavoritedStatus, account.getUserId()); boolean unfavNoticeEnabled = UserPreferenceHelper.getInstance().get(R.string.key_setting_notify_on_unfavorited, true); if (unfavNoticeEnabled && isMe(User.fromTwitter(target))) { - addToHistory(new EventViewModel(EnumEvent.UNFAVORITED, User.fromTwitter(source), tweet)); + addToHistory(new EventViewModel(EventViewModel.EnumEvent.UNFAVORITED, User.fromTwitter(source), tweet)); } // unneeded? // if (isMe(User.fromTwitter(source))) { @@ -163,7 +162,7 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect @Override public void onFollow(twitter4j.User source, twitter4j.User followedUser) { if (isMe(User.fromTwitter(followedUser))) { - addToHistory(new EventViewModel(EnumEvent.FOLLOWED, User.fromTwitter(source))); + addToHistory(new EventViewModel(EventViewModel.EnumEvent.FOLLOWED, User.fromTwitter(source))); } } @@ -175,7 +174,7 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect public void onDirectMessage(twitter4j.DirectMessage directMessage) { DirectMessage message = DirectMessage.fromTwitter(directMessage); if (isMe(message.getRecipient())) { - addToHistory(new EventViewModel(EnumEvent.RECEIVE_MESSAGE, User.fromTwitter(directMessage.getSender()))); + addToHistory(new EventViewModel(EventViewModel.EnumEvent.RECEIVE_MESSAGE, User.fromTwitter(directMessage.getSender()))); } MessageViewModel vm = new MessageViewModel(message); StatusFilter.getInstance().filter(vm); @@ -228,14 +227,14 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect @Override public void onBlock(twitter4j.User source, twitter4j.User blockedUser) { if (isMe(User.fromTwitter(blockedUser))) { - addToHistory(new EventViewModel(EnumEvent.BLOCKED, User.fromTwitter(source))); + addToHistory(new EventViewModel(EventViewModel.EnumEvent.BLOCKED, User.fromTwitter(source))); } } @Override public void onUnblock(twitter4j.User source, twitter4j.User unblockedUser) { if (isMe(User.fromTwitter(unblockedUser))) { - addToHistory(new EventViewModel(EnumEvent.UNBLOCKED, User.fromTwitter(source))); + addToHistory(new EventViewModel(EventViewModel.EnumEvent.UNBLOCKED, User.fromTwitter(source))); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/util/NameStyles.java b/app/src/main/java/net/lacolaco/smileessence/util/NameStyles.java index 31c56324..7b02c535 100644 --- a/app/src/main/java/net/lacolaco/smileessence/util/NameStyles.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/NameStyles.java @@ -24,11 +24,16 @@ package net.lacolaco.smileessence.util; +import net.lacolaco.smileessence.entity.User; + public class NameStyles { // -------------------------- STATIC METHODS -------------------------- - public static String getNameString(int style, String screenName, String name) { + public static String getNameString(int style, User user) { + String screenName = user.getScreenName(); + String name = user.getName(); + switch (style) { case 1: { return String.format("%s / %s", name, screenName); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java index e71d5859..c9b3b07a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java @@ -129,7 +129,8 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen .onDoneUI(replyTo -> { adapter.addToTop(new StatusViewModel(replyTo)); adapter.updateForce(); - }); + }) + .execute(); } return new AlertDialog.Builder(getActivity()).setView(header).create(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/viewmodel/EnumEvent.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EnumEvent.java deleted file mode 100644 index a241c9bc..00000000 --- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/EnumEvent.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2012-2014 lacolaco.net - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package net.lacolaco.smileessence.viewmodel; - -import net.lacolaco.smileessence.R; - -public enum EnumEvent { - - FAVORITED(R.string.format_event_favorited), - UNFAVORITED(R.string.format_event_unfavorited), - RETWEETED(R.string.format_event_retweeted), - MENTIONED(R.string.format_event_mentioned), - FOLLOWED(R.string.format_event_followed), - BLOCKED(R.string.format_event_blocked), - UNBLOCKED(R.string.format_event_unblocked), - RECEIVE_MESSAGE(R.string.format_event_message); - - // ------------------------------ FIELDS ------------------------------ - - private int textFormatResourceID; - - // --------------------------- CONSTRUCTORS --------------------------- - - private EnumEvent(int textFormatResourceID) { - this.textFormatResourceID = textFormatResourceID; - } - - // --------------------- GETTER / SETTER METHODS --------------------- - - public int getTextFormatResourceID() { - return textFormatResourceID; - } -} diff --git a/app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java index c11ff890..03e41006 100644 --- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java @@ -25,7 +25,6 @@ package net.lacolaco.smileessence.viewmodel; import android.app.Activity; -import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; @@ -172,4 +171,32 @@ public class EventViewModel implements IViewModel { public String getFormattedString() { return Application.getContext().getString(event.getTextFormatResourceID(), sourceScreenName); } + + public enum EnumEvent { + + FAVORITED(R.string.format_event_favorited), + UNFAVORITED(R.string.format_event_unfavorited), + RETWEETED(R.string.format_event_retweeted), + MENTIONED(R.string.format_event_mentioned), + FOLLOWED(R.string.format_event_followed), + BLOCKED(R.string.format_event_blocked), + UNBLOCKED(R.string.format_event_unblocked), + RECEIVE_MESSAGE(R.string.format_event_message); + + // ------------------------------ FIELDS ------------------------------ + + private int textFormatResourceID; + + // --------------------------- CONSTRUCTORS --------------------------- + + EnumEvent(int textFormatResourceID) { + this.textFormatResourceID = textFormatResourceID; + } + + // --------------------- GETTER / SETTER METHODS --------------------- + + public int getTextFormatResourceID() { + return textFormatResourceID; + } + } } diff --git a/app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java index e2cfb9f1..29de779a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java @@ -51,14 +51,11 @@ public class MessageViewModel implements IViewModel { public static final String DETAIL_DIALOG = "messageDetail"; private final DirectMessage directMessage; - private final boolean myMessage; // --------------------------- CONSTRUCTORS --------------------------- public MessageViewModel(DirectMessage mes) { directMessage = mes; - //myMessage = isMyMessage(account); - myMessage = true; // :wTODO } // --------------------- GETTER / SETTER METHODS --------------------- @@ -67,18 +64,14 @@ public class MessageViewModel implements IViewModel { public DirectMessage getDirectMessage() { return directMessage; } - private String getFooterText() { + private String getFooterText(Account account) { String s = StringUtils.dateToString(directMessage.getCreatedAt()); - if (isMyMessage()) { + if (directMessage.getSender().getId() == account.getUserId()) { s = String.format("%s to @%s", s, directMessage.getRecipient().getScreenName()); } return s; } - public boolean isMyMessage() { - return myMessage; - } - // ------------------------ INTERFACE METHODS ------------------------ @@ -103,7 +96,7 @@ public class MessageViewModel implements IViewModel { header.setTextSize(textSize); int colorHeader = Themes.getStyledColor(activity, theme, R.attr.color_message_text_header, 0); header.setTextColor(colorHeader); - header.setText(getNameString(nameStyle)); + header.setText(NameStyles.getNameString(nameStyle, directMessage.getSender())); TextView content = (TextView) convertedView.findViewById(R.id.textview_status_text); content.setTextSize(textSize); int colorNormal = Themes.getStyledColor(activity, theme, R.attr.color_status_text_normal, 0); @@ -113,27 +106,16 @@ public class MessageViewModel implements IViewModel { footer.setTextSize(textSize - 2); int colorFooter = Themes.getStyledColor(activity, theme, R.attr.color_status_text_footer, 0); footer.setTextColor(colorFooter); - footer.setText(getFooterText()); + footer.setText(getFooterText(((MainActivity) activity).getCurrentAccount())); ImageView favorited = (ImageView) convertedView.findViewById(R.id.imageview_status_favorited); favorited.setVisibility(View.GONE); int colorBgMessage = Themes.getStyledColor(activity, theme, R.attr.color_message_bg_normal, 0); convertedView.setBackgroundColor(colorBgMessage); - convertedView.setOnClickListener(new ListItemClickListener(activity, new Runnable() { - @Override - public void run() { - MessageDetailDialogFragment dialogFragment = new MessageDetailDialogFragment(); - dialogFragment.setMessageID(directMessage.getId()); - DialogHelper.showDialog(activity, dialogFragment); - } + convertedView.setOnClickListener(new ListItemClickListener(activity, () -> { + MessageDetailDialogFragment dialogFragment = new MessageDetailDialogFragment(); + dialogFragment.setMessageID(directMessage.getId()); + DialogHelper.showDialog(activity, dialogFragment); })); return convertedView; } - - private String getNameString(int nameStyle) { - return NameStyles.getNameString(nameStyle, directMessage.getSender().getScreenName(), directMessage.getSender().getName()); - } - - private boolean isMyMessage(Account account) { - return directMessage.getSender().getId() == account.userID; - } } diff --git a/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java index 148bb287..5fd54bf8 100644 --- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java @@ -50,9 +50,6 @@ import java.util.List; public class StatusViewModel implements IViewModel { private Tweet tweet; - private boolean isMyStatus; - private boolean isMention; - private boolean isRetweetOfMe; private ArrayList<BackgroundTask> lastTasks = new ArrayList<>(); // internal @@ -85,44 +82,17 @@ public class StatusViewModel implements IViewModel { private String getFooterText() { StringBuilder builder = new StringBuilder(); if (tweet.isRetweet()) { - builder.append("(RT: ").append(tweet.getUser().getScreenName()).append(") "); + builder + .append("(RT: ") + .append(tweet.getUser().getScreenName()) + .append(") "); } - builder.append(StringUtils.dateToString(tweet.getCreatedAt())); + builder.append(StringUtils.dateToString(tweet.getOriginalTweet().getCreatedAt())); builder.append(" via "); - builder.append(Html.fromHtml(tweet.getSource())); + builder.append(Html.fromHtml(tweet.getOriginalTweet().getSource())); return builder.toString(); } - public boolean isMention() { - if (tweet.isRetweet()) { - return tweet.getRetweetedTweet() == null; - } - return isMention; - } - - public void setMention(boolean mention) { - isMention = mention; - } - - public boolean isMyStatus() { - if (tweet.isRetweet()) { - return tweet.getRetweetedTweet() == null; - } - return isMyStatus; - } - - public void setMyStatus(boolean myStatus) { - isMyStatus = myStatus; - } - - public boolean isRetweetOfMe() { - return isRetweetOfMe; - } - - public void setRetweetOfMe(boolean retweet) { - this.isRetweetOfMe = retweet; - } - // ------------------------ INTERFACE METHODS ------------------------ @@ -152,20 +122,20 @@ public class StatusViewModel implements IViewModel { int nameStyle = UserPreferenceHelper.getInstance().get(R.string.key_setting_namestyle, 0); int theme = ((MainActivity) activity).getThemeIndex(); NetworkImageView icon = (NetworkImageView) convertedView.findViewById(R.id.imageview_status_icon); - ImageCache.getInstance().setImageToView(tweet.getUser().getProfileImageUrl(), icon); + ImageCache.getInstance().setImageToView(tweet.getOriginalTweet().getUser().getProfileImageUrl(), icon); icon.setOnClickListener(v -> onIconClick(activity)); TextView header = (TextView) convertedView.findViewById(R.id.textview_status_header); header.setTextSize(textSize); int colorHeader = Themes.getStyledColor(activity, theme, R.attr.color_status_text_header, 0); int colorMineHeader = Themes.getStyledColor(activity, theme, R.attr.color_status_text_mine, 0); - header.setTextColor(isMyStatus() ? colorMineHeader : colorHeader); - header.setText(NameStyles.getNameString(nameStyle, tweet.getUser().getScreenName(), tweet.getUser().getName())); + header.setTextColor(tweet.getUser().getId() == account.getUserId() ? colorMineHeader : colorHeader); + header.setText(NameStyles.getNameString(nameStyle, tweet.getOriginalTweet().getUser())); TextView content = (TextView) convertedView.findViewById(R.id.textview_status_text); content.setTextSize(textSize); int colorNormal = Themes.getStyledColor(activity, theme, R.attr.color_status_text_normal, 0); content.setTextColor(colorNormal); - String rawText = tweet.getText(); - if (isReadMorseEnabled((MainActivity) activity) && Morse.isMorse(rawText)) { + String rawText = tweet.getOriginalTweet().getText(); + if (isReadMorseEnabled() && Morse.isMorse(rawText)) { content.setText(String.format("%s\n(%s)", rawText, Morse.morseToJa(rawText))); } else { content.setText(rawText); @@ -176,11 +146,11 @@ public class StatusViewModel implements IViewModel { footer.setTextColor(colorFooter); footer.setText(getFooterText()); ImageView favorited = (ImageView) convertedView.findViewById(R.id.imageview_status_favorited); - favorited.setVisibility(tweet.getOriginalTweet().isFavoritedBy(account.getUserId()) ? View.VISIBLE : View.GONE); + favorited.setVisibility(tweet.isFavoritedBy(account.getUserId()) ? View.VISIBLE : View.GONE); if (tweet.isRetweet()) { int colorBgRetweet = Themes.getStyledColor(activity, theme, R.attr.color_status_bg_retweet, 0); convertedView.setBackgroundColor(colorBgRetweet); - } else if (isMention()) { + } else if (account.getCachedUser() != null && tweet.getOriginalTweet().getMentions().contains(account.getCachedUser().getScreenName())) { int colorBgMention = Themes.getStyledColor(activity, theme, R.attr.color_status_bg_mention, 0); convertedView.setBackgroundColor(colorBgMention); } else { @@ -198,7 +168,7 @@ public class StatusViewModel implements IViewModel { for (long id : embeddedStatusIDs) { BackgroundTask task = account.fetchTweet(id, embeddedTweet -> { if (embeddedTweet != null) { - StatusViewModel viewModel = new StatusViewModel(tweet); + StatusViewModel viewModel = new StatusViewModel(embeddedTweet); View embeddedHolder = viewModel.getView(activity, inflater, null, false); embeddedStatus.addView(embeddedHolder); embeddedStatus.invalidate(); @@ -216,11 +186,7 @@ public class StatusViewModel implements IViewModel { return convertedView; } - public boolean isMention(String screenName) { - return tweet.getMentions().contains(screenName); - } - - private boolean isReadMorseEnabled(MainActivity activity) { + private boolean isReadMorseEnabled() { return UserPreferenceHelper.getInstance().get(R.string.key_setting_read_morse, true); } diff --git a/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java deleted file mode 100644 index 3c25bf31..00000000 --- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2012-2014 lacolaco.net - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package net.lacolaco.smileessence.viewmodel; - -import net.lacolaco.smileessence.entity.User; - -public class UserViewModel { - - // ------------------------------ FIELDS ------------------------------ - - private long id; - private String screenName; - private String name; - private String description; - private String location; - private String url; - private String iconURL; - private String bannerURL; - private int statusesCount; - private int friendsCount; - private int followersCount; - private int favoritesCount; - private boolean isProtected; - private boolean isVerified; - - // --------------------------- CONSTRUCTORS --------------------------- - - public UserViewModel(User user) { - id = user.getId(); - screenName = user.getScreenName(); - name = user.getName(); - description = user.getDescription(); - location = user.getLocation(); - url = user.getUrl(); - iconURL = user.getProfileImageUrlOriginal(); - bannerURL = user.getProfileBannerUrl(); - statusesCount = user.getStatusesCount(); - friendsCount = user.getFriendsCount(); - followersCount = user.getFollowersCount(); - favoritesCount = user.getFavoritesCount(); - isProtected = user.isProtected(); - isVerified = user.isVerified(); - } - - // --------------------- GETTER / SETTER METHODS --------------------- - - public String getBannerURL() { - return bannerURL; - } - - public String getDescription() { - return description; - } - - public int getFavoritesCount() { - return favoritesCount; - } - - public int getFollowersCount() { - return followersCount; - } - - public int getFriendsCount() { - return friendsCount; - } - - public String getIconURL() { - return iconURL; - } - - public long getID() { - return id; - } - - public String getLocation() { - return location; - } - - public String getName() { - return name; - } - - public String getScreenName() { - return screenName; - } - - public int getStatusesCount() { - return statusesCount; - } - - public String getURL() { - return url; - } - - public boolean isProtected() { - return isProtected; - } - - public boolean isVerified() { - return isVerified; - } -} |