aboutsummaryrefslogtreecommitdiffstats
path: root/app/src
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-09-18 15:48:23 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-09-18 15:48:23 +0900
commita803c87d0c6a54bc5ef824dd5992997db07f601b (patch)
treec9a1a35c37a5230d2f0b118e74dbcbb378b935dd /app/src
parentb0c57a24c881607f26d1c43640552b24a574a8e4 (diff)
downloadSmileEssence-a803c87d0c6a54bc5ef824dd5992997db07f601b.tar.gz
Revert "com.android.databinding まだぴよぴよしてる..."
This reverts commit b0c57a24c881607f26d1c43640552b24a574a8e4.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java2
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java2
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandReview.java4
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTextQuote.java2
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/entity/Tweet.java18
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/entity/User.java89
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/util/NameStyles.java6
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java2
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java2
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java18
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java2
-rw-r--r--app/src/main/res/layout/list_item_status.xml116
12 files changed, 94 insertions, 169 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java
index 24299306..8b68b128 100644
--- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java
+++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java
@@ -61,7 +61,7 @@ public class StatusCommandCongratulate extends StatusCommand implements IConfirm
@Override
public boolean isEnabled() {
- return !getOriginalStatus().getUser().isTweetProtected();
+ return !getOriginalStatus().getUser().isProtected();
}
// -------------------------- OTHER METHODS --------------------------
diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java
index 9d7085ad..d8d9e4a8 100644
--- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java
+++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java
@@ -58,7 +58,7 @@ public class StatusCommandFavAndRT extends StatusCommand implements IConfirmable
@Override
public boolean isEnabled() {
User user = getOriginalStatus().getUser();
- return !user.isTweetProtected() && user.getId() != account.userID;
+ return !user.isProtected() && user.getId() != account.userID;
}
// -------------------------- OTHER METHODS --------------------------
diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandReview.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandReview.java
index 50614c0d..df5f6515 100644
--- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandReview.java
+++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandReview.java
@@ -31,6 +31,8 @@ import net.lacolaco.smileessence.entity.Tweet;
import net.lacolaco.smileessence.view.DialogHelper;
import net.lacolaco.smileessence.view.dialog.ReviewDialogFragment;
+import twitter4j.Status;
+
public class StatusCommandReview extends StatusCommand {
// --------------------------- CONSTRUCTORS ---------------------------
@@ -48,7 +50,7 @@ public class StatusCommandReview extends StatusCommand {
@Override
public boolean isEnabled() {
- return !getOriginalStatus().getUser().isTweetProtected();
+ return !getOriginalStatus().getUser().isProtected();
}
// -------------------------- OTHER METHODS --------------------------
diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTextQuote.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTextQuote.java
index 9b051ff7..534e7e1a 100644
--- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTextQuote.java
+++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTextQuote.java
@@ -49,7 +49,7 @@ public class StatusCommandTextQuote extends StatusCommand {
@Override
public boolean isEnabled() {
- return !getStatus().getUser().isTweetProtected();
+ return !getStatus().getUser().isProtected();
}
// -------------------------- OTHER METHODS --------------------------
diff --git a/app/src/main/java/net/lacolaco/smileessence/entity/Tweet.java b/app/src/main/java/net/lacolaco/smileessence/entity/Tweet.java
index 65323a9e..3d0cf8d3 100644
--- a/app/src/main/java/net/lacolaco/smileessence/entity/Tweet.java
+++ b/app/src/main/java/net/lacolaco/smileessence/entity/Tweet.java
@@ -1,10 +1,7 @@
package net.lacolaco.smileessence.entity;
-import android.databinding.BaseObservable;
-import android.databinding.Bindable;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
-import net.lacolaco.smileessence.BR;
import net.lacolaco.smileessence.twitter.util.TwitterUtils;
import net.lacolaco.smileessence.util.ListUtils;
import twitter4j.*;
@@ -13,7 +10,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-public class Tweet extends BaseObservable {
+public class Tweet {
// キャッシュ こっちは soft reference
private static Cache<Long, Tweet> storage = CacheBuilder.newBuilder().softValues().build();
@@ -67,14 +64,8 @@ public class Tweet extends BaseObservable {
text = TwitterUtils.replaceURLEntities(status.getText(), status.getURLEntities(), false);
createdAt = status.getCreatedAt();
source = status.getSource();
- if (status.getFavoriteCount() != status.getFavoriteCount()) {
- favoriteCount = status.getFavoriteCount();
- notifyPropertyChanged(BR.favoriteCount);
- }
- if (status.getRetweetCount() != status.getRetweetCount()) {
- retweetCount = status.getRetweetCount();
- notifyPropertyChanged(BR.retweetCount);
- }
+ favoriteCount = status.getFavoriteCount();
+ retweetCount = status.getRetweetCount();
mentions = status.getUserMentionEntities();
hashtags = status.getHashtagEntities();
@@ -89,7 +80,6 @@ public class Tweet extends BaseObservable {
}
}
- @Bindable
public String getTwitterUrl() {
return String.format("https://twitter.com/%s/status/%s", getOriginalTweet().getUser().getScreenName(), getOriginalTweet().getId());
}
@@ -130,12 +120,10 @@ public class Tweet extends BaseObservable {
}
}
- @Bindable
public int getFavoriteCount() {
return favoriteCount;
}
- @Bindable
public int getRetweetCount() {
return retweetCount;
}
diff --git a/app/src/main/java/net/lacolaco/smileessence/entity/User.java b/app/src/main/java/net/lacolaco/smileessence/entity/User.java
index 20e38878..73e94ae4 100644
--- a/app/src/main/java/net/lacolaco/smileessence/entity/User.java
+++ b/app/src/main/java/net/lacolaco/smileessence/entity/User.java
@@ -1,12 +1,9 @@
package net.lacolaco.smileessence.entity;
-import android.databinding.BaseObservable;
-import android.databinding.Bindable;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
-import net.lacolaco.smileessence.BR;
-public class User extends BaseObservable {
+public class User {
// 重複防止用キャッシュ こっちは weak reference
private static Cache<Long, User> storage = CacheBuilder.newBuilder().weakValues().build();
@@ -27,7 +24,7 @@ public class User extends BaseObservable {
// インスタンス
private long id;
- private boolean tweetProtected;
+ private boolean isProtected;
private String screenName;
private String name;
private String profileImageUrl;
@@ -47,80 +44,37 @@ public class User extends BaseObservable {
private void update(twitter4j.User user) {
id = user.getId();
- if (isTweetProtected() != user.isProtected()) {
- tweetProtected = user.isProtected();
- notifyPropertyChanged(BR.tweetProtected);
- }
- if (!getScreenName().equals(user.getScreenName())) {
- screenName = user.getScreenName();
- notifyPropertyChanged(BR.screenName);
- }
- if (!getName().equals(user.getName())) {
- name = user.getName();
- notifyPropertyChanged(BR.name);
- }
- if (!getProfileImageUrl().equals(user.getProfileBackgroundImageUrlHttps())) {
- profileImageUrl = user.getProfileImageURLHttps();
- notifyPropertyChanged(BR.profileImageUrl);
- }
- if (!getProfileBannerUrl().equals(user.getProfileBannerURL())) {
- profileBannerUrl = user.getProfileBannerURL();
- notifyPropertyChanged(BR.profileBannerUrl);
- }
- if (!getDescription().equals(user.getDescription())) {
- description = user.getDescription();
- notifyPropertyChanged(BR.description);
- }
- if (!getLocation().equals(user.getLocation())) {
- location = user.getLocation();
- notifyPropertyChanged(BR.location);
- }
- if (!getUrl().equals(user.getURL())) {
- url = user.getURL();
- notifyPropertyChanged(BR.url);
- }
- if (getFavoritesCount() != user.getFavouritesCount()) {
- favoritesCount = user.getFavouritesCount();
- notifyPropertyChanged(BR.favoritesCount);
- }
- if (getStatusesCount() != user.getStatusesCount()) {
- statusesCount = user.getStatusesCount();
- notifyPropertyChanged(BR.statusesCount);
- }
- if (getFriendsCount() != user.getFriendsCount()) {
- friendsCount = user.getFriendsCount();
- notifyPropertyChanged(BR.friendsCount);
- }
- if (getFollowersCount() != user.getFollowersCount()) {
- followersCount = user.getFollowersCount();
- notifyPropertyChanged(BR.followersCount);
- }
- if (isVerified() != user.isVerified()) {
- isVerified = user.isVerified();
- notifyPropertyChanged(BR.verified);
- }
+ isProtected = user.isProtected();
+ screenName = user.getScreenName();
+ name = user.getName();
+ profileImageUrl = user.getProfileImageURLHttps();
+ profileBannerUrl = user.getProfileBannerURL();
+ description = user.getDescription();
+ location = user.getLocation();
+ url = user.getURL();
+ favoritesCount = user.getFavouritesCount();
+ statusesCount = user.getStatusesCount();
+ friendsCount = user.getFriendsCount();
+ followersCount = user.getFollowersCount();
+ isVerified = user.isVerified();
}
public long getId() {
return id;
}
- @Bindable // TODO: workaround for bugs in com.android.databinding
- public boolean isTweetProtected() {
- return tweetProtected;
+ public boolean isProtected() {
+ return isProtected;
}
- @Bindable
public String getScreenName() {
return screenName;
}
- @Bindable
public String getName() {
return name;
}
- @Bindable
public String getProfileImageUrl() {
return profileImageUrl;
}
@@ -142,47 +96,38 @@ public class User extends BaseObservable {
return null;
}
- @Bindable
public String getProfileBannerUrl() {
return profileBannerUrl;
}
- @Bindable
public String getDescription() {
return description;
}
- @Bindable
public String getLocation() {
return location;
}
- @Bindable
public String getUrl() {
return url;
}
- @Bindable
public int getFavoritesCount() {
return favoritesCount;
}
- @Bindable
public int getStatusesCount() {
return statusesCount;
}
- @Bindable
public int getFriendsCount() {
return friendsCount;
}
- @Bindable
public int getFollowersCount() {
return followersCount;
}
- @Bindable
public boolean isVerified() {
return isVerified;
}
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 5657b4b0..31c56324 100644
--- a/app/src/main/java/net/lacolaco/smileessence/util/NameStyles.java
+++ b/app/src/main/java/net/lacolaco/smileessence/util/NameStyles.java
@@ -24,15 +24,11 @@
package net.lacolaco.smileessence.util;
-import net.lacolaco.smileessence.entity.User;
-
public class NameStyles {
// -------------------------- STATIC METHODS --------------------------
- public static String getNameString(int style, User user) {
- String name = user.getName();
- String screenName = user.getScreenName();
+ public static String getNameString(int style, String screenName, String name) {
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 fff25cdc..d21c67c7 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
@@ -252,7 +252,7 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen
private boolean isNotRetweetable(Account account, Tweet tweet) {
User user = tweet.getOriginalTweet().getUser();
- return user.isTweetProtected() || user.getId() == account.userID;
+ return user.isProtected() || user.getId() == account.userID;
}
private boolean isRetweetDeletable(Account account, Tweet tweet) {
diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java
index 7a4aa13c..cd8c935e 100644
--- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java
+++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java
@@ -318,7 +318,7 @@ public class UserDetailDialogFragment extends StackableDialogFragment implements
textViewFriendCount.setText(String.valueOf(user.getFriendsCount()));
textViewFollowerCount.setText(String.valueOf(user.getFollowersCount()));
textViewFavoriteCount.setText(String.valueOf(user.getFavoritesCount()));
- textViewProtected.setVisibility(user.isTweetProtected() ? View.VISIBLE : View.GONE);
+ textViewProtected.setVisibility(user.isProtected() ? View.VISIBLE : View.GONE);
String htmlDescription = getHtmlDescription(user.getDescription());
textViewDescription.setText(Html.fromHtml(htmlDescription));
textViewDescription.setMovementMethod(LinkMovementMethod.getInstance());
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 78f1025e..5680ccc7 100644
--- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java
+++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java
@@ -40,7 +40,6 @@ import net.lacolaco.smileessence.R;
import net.lacolaco.smileessence.activity.MainActivity;
import net.lacolaco.smileessence.data.FavoriteCache;
import net.lacolaco.smileessence.data.ImageCache;
-import net.lacolaco.smileessence.databinding.ListItemStatusBinding;
import net.lacolaco.smileessence.entity.Account;
import net.lacolaco.smileessence.entity.Tweet;
import net.lacolaco.smileessence.preference.UserPreferenceHelper;
@@ -160,26 +159,25 @@ public class StatusViewModel implements IViewModel {
lastTasks.clear();
if (convertedView == null) {
- ListItemStatusBinding binding = ListItemStatusBinding.inflate(inflater, null, false);
- convertedView = binding.getRoot();
- convertedView.setTag(binding);
+ convertedView = inflater.inflate(R.layout.list_item_status, null);
}
- ListItemStatusBinding binding = (ListItemStatusBinding) convertedView.getTag();
- binding.setTweet(getTweet());
- //return convertedView;
-
int textSize = UserPreferenceHelper.getInstance().get(R.string.key_setting_text_size, 10);
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);
- icon.setOnClickListener(v -> onIconClick(activity));
+ icon.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View 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()));
+ header.setText(NameStyles.getNameString(nameStyle, tweet.getUser().getScreenName(), tweet.getUser().getName()));
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);
diff --git a/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java
index 47c3f6fc..3c25bf31 100644
--- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java
+++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/UserViewModel.java
@@ -60,7 +60,7 @@ public class UserViewModel {
friendsCount = user.getFriendsCount();
followersCount = user.getFollowersCount();
favoritesCount = user.getFavoritesCount();
- isProtected = user.isTweetProtected();
+ isProtected = user.isProtected();
isVerified = user.isVerified();
}
diff --git a/app/src/main/res/layout/list_item_status.xml b/app/src/main/res/layout/list_item_status.xml
index b9477778..92905d47 100644
--- a/app/src/main/res/layout/list_item_status.xml
+++ b/app/src/main/res/layout/list_item_status.xml
@@ -23,69 +23,65 @@
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
-<layout xmlns:android="http://schemas.android.com/apk/res/android">
- <data>
- <variable name="tweet" type="net.lacolaco.smileessence.entity.Tweet" />
- </data>
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="5dp">
- <com.android.volley.toolbox.NetworkImageView
- android:id="@+id/imageview_status_icon"
- android:layout_width="36dp"
- android:layout_height="36dp"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true" />
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="5dp">
+
+ <com.android.volley.toolbox.NetworkImageView
+ android:id="@+id/imageview_status_icon"
+ android:layout_width="36dp"
+ android:layout_height="36dp"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true" />
- <TextView
- android:id="@+id/textview_status_header"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_marginLeft="5dp"
- android:layout_toRightOf="@+id/imageview_status_icon"
- android:gravity="top" />
+ <TextView
+ android:id="@+id/textview_status_header"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_marginLeft="5dp"
+ android:layout_toRightOf="@+id/imageview_status_icon"
+ android:gravity="top" />
- <TextView
- android:id="@+id/textview_status_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignLeft="@+id/textview_status_header"
- android:layout_alignParentRight="true"
- android:layout_below="@+id/textview_status_header"
- android:layout_marginBottom="3dp"
- android:layout_marginTop="1dp" />
+ <TextView
+ android:id="@+id/textview_status_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/textview_status_header"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/textview_status_header"
+ android:layout_marginBottom="3dp"
+ android:layout_marginTop="1dp" />
- <TextView
- android:id="@+id/textview_status_footer"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignLeft="@+id/textview_status_text"
- android:layout_below="@+id/textview_status_text"
- android:layout_marginRight="2dp" />
+ <TextView
+ android:id="@+id/textview_status_footer"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/textview_status_text"
+ android:layout_below="@+id/textview_status_text"
+ android:layout_marginRight="2dp" />
- <ImageView
- android:id="@+id/imageview_status_favorited"
- android:layout_width="30dp"
- android:layout_height="wrap_content"
- android:layout_alignBottom="@+id/textview_status_header"
- android:layout_alignParentRight="true"
- android:layout_alignParentTop="true"
- android:layout_alignTop="@+id/textview_status_header"
- android:contentDescription=""
- android:src="?attr/icon_status_favorite_on" />
+ <ImageView
+ android:id="@+id/imageview_status_favorited"
+ android:layout_width="30dp"
+ android:layout_height="wrap_content"
+ android:layout_alignBottom="@+id/textview_status_header"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentTop="true"
+ android:layout_alignTop="@+id/textview_status_header"
+ android:contentDescription=""
+ android:src="?attr/icon_status_favorite_on" />
- <LinearLayout
- android:id="@+id/view_status_embedded_status"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignLeft="@+id/textview_status_text"
- android:layout_below="@+id/textview_status_footer"
- android:layout_marginRight="1dp"
- android:layout_marginTop="3dp"
- android:orientation="vertical"
- android:visibility="gone" />
- </RelativeLayout>
-</layout> \ No newline at end of file
+ <LinearLayout
+ android:id="@+id/view_status_embedded_status"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/textview_status_text"
+ android:layout_below="@+id/textview_status_footer"
+ android:layout_marginRight="1dp"
+ android:layout_marginTop="3dp"
+ android:orientation="vertical"
+ android:visibility="gone" />
+</RelativeLayout> \ No newline at end of file