diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-05-19 22:17:54 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-05-19 22:17:54 +0900 |
commit | d5bec3ed0dc5b215963ceece99bed6ed1d0d9d29 (patch) | |
tree | 4ae75b19847f19f7d9f4461610201d77f2347344 /app | |
parent | 99fd825ce94883ee17fcfac4489f8a07dbc9a210 (diff) | |
download | SmileEssence-d5bec3ed0dc5b215963ceece99bed6ed1d0d9d29.tar.gz |
StatusViewModel: optimize embedded statuses IDs extracting
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java | 16 |
1 files changed, 5 insertions, 11 deletions
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 abff50b3..44dc4c29 100644 --- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java @@ -342,24 +342,22 @@ public class StatusViewModel implements IViewModel { onClick(activity); } })); + final ViewGroup embeddedStatus = (ViewGroup) convertedView.findViewById(R.id.view_status_embedded_status); embeddedStatus.removeAllViews(); if (extendStatusURL) { - if (containsStatusURL()) { + List<Long> embeddedStatusIDs = getEmbeddedStatusIDs(); + if (embeddedStatusIDs.size() > 0) { embeddedStatus.setVisibility(View.VISIBLE); final Account account = ((MainActivity) activity).getCurrentAccount(); - List<Long> embeddedStatusIDs = getEmbeddedStatusIDs(); - for (int i = 0; i < embeddedStatusIDs.size(); i++) { - long id = embeddedStatusIDs.get(i); - final int index = i; - final View finalConvertedView = convertedView; + for (long id : embeddedStatusIDs) { TwitterUtils.tryGetStatus(account, id, new TwitterUtils.StatusCallback() { @Override public void success(Status status) { StatusViewModel viewModel = new StatusViewModel(status, account); View embeddedHolder = viewModel.getView(activity, inflater, null, false); embeddedStatus.addView(embeddedHolder); - finalConvertedView.invalidate(); + embeddedStatus.invalidate(); } @Override @@ -396,10 +394,6 @@ public class StatusViewModel implements IViewModel { return retweetedStatus != null && retweetedStatus.getUserID() == userID; } - private boolean containsStatusURL() { - return getEmbeddedStatusIDs().size() > 0; - } - private boolean isReadMorseEnabled(MainActivity activity) { return activity.getUserPreferenceHelper().getValue(R.string.key_setting_read_morse, true); } |