diff options
author | Maxime Biais <maxime.biais@gmail.com> | 2015-03-03 08:56:34 +0100 |
---|---|---|
committer | Maxime Biais <maxime.biais@gmail.com> | 2015-03-03 08:56:34 +0100 |
commit | 42852fe4026f2a0e8cf800e48ca8015b99d9cad4 (patch) | |
tree | cceb28acbe861e4108682e16504af3feadea7996 /WordPress/src/main/java/org | |
parent | 0d8e9bcfa7e58a4249c4f6cdc85de2aa726235c9 (diff) | |
parent | edda5cb1c4ba3a54adb6bd7b29852a9cfe2c674b (diff) | |
download | gradle-perf-android-medium-42852fe4026f2a0e8cf800e48ca8015b99d9cad4.tar.gz |
Merge branch 'develop' of github.com:wordpress-mobile/WordPress-Android into develop
Diffstat (limited to 'WordPress/src/main/java/org')
6 files changed, 48 insertions, 4 deletions
diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java index 0a1231c81..e9ea6801d 100644 --- a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java +++ b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java @@ -383,6 +383,20 @@ public class ReaderPostTable { } /* + * returns the id of the newest post with the passed tag + */ + public static long getNewestPostIdWithTag(final ReaderTag tag) { + if (tag == null) { + return 0; + } + String sql = "SELECT tbl_posts.post_id FROM tbl_posts, tbl_post_tags" + + " WHERE tbl_posts.post_id = tbl_post_tags.post_id AND tbl_posts.blog_id = tbl_post_tags.blog_id" + + " AND tbl_post_tags.tag_name=? AND tbl_post_tags.tag_type=?" + + " ORDER BY published DESC LIMIT 1"; + String[] args = {tag.getTagName(), Integer.toString(tag.tagType.toInt())}; + return SqlUtils.longForQuery(ReaderDatabase.getReadableDb(), sql, args); + } + /* * returns the iso8601 published date of the oldest post with the passed tag */ public static String getOldestPubDateWithTag(final ReaderTag tag) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java index a18cc7455..ce27fd41d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.notifications.blocks; import android.content.Context; +import android.text.Html; import android.text.TextUtils; import android.view.View; import android.widget.TextView; @@ -54,7 +55,7 @@ public class CommentUserNoteBlock extends UserNoteBlock { public View configureView(View view) { final CommentUserNoteBlockHolder noteBlockHolder = (CommentUserNoteBlockHolder)view.getTag(); - noteBlockHolder.nameTextView.setText(getNoteText().toString()); + noteBlockHolder.nameTextView.setText(Html.fromHtml("<strong>" + getNoteText().toString() + "</strong>")); noteBlockHolder.agoTextView.setText(DateTimeUtils.timestampToTimeSpan(getTimestamp())); if (!TextUtils.isEmpty(getMetaHomeTitle()) || !TextUtils.isEmpty(getMetaSiteUrl())) { noteBlockHolder.bulletTextView.setVisibility(View.VISIBLE); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderUserNoteBlock.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderUserNoteBlock.java index 135afb015..cfefc27a5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderUserNoteBlock.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderUserNoteBlock.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.notifications.blocks; import android.content.Context; +import android.text.Spannable; import android.text.TextUtils; import android.view.MotionEvent; import android.view.View; @@ -10,6 +11,7 @@ import android.widget.TextView; import org.json.JSONArray; import org.json.JSONObject; import org.wordpress.android.R; +import org.wordpress.android.ui.notifications.utils.NotificationsUtils; import org.wordpress.android.util.GravatarUtils; import org.wordpress.android.util.JSONUtil; import org.wordpress.android.widgets.WPNetworkImageView; @@ -49,7 +51,11 @@ public class HeaderUserNoteBlock extends NoteBlock { public View configureView(View view) { final NoteHeaderBlockHolder noteBlockHolder = (NoteHeaderBlockHolder)view.getTag(); - noteBlockHolder.nameTextView.setText(getUserName()); + Spannable spannable = NotificationsUtils.getSpannableContentFromIndices( + mHeaderArray.optJSONObject(0), + null, + null); + noteBlockHolder.nameTextView.setText(spannable); noteBlockHolder.avatarImageView.setImageUrl(getAvatarUrl(), WPNetworkImageView.ImageType.AVATAR); if (!TextUtils.isEmpty(getUserUrl())) { noteBlockHolder.avatarImageView.setOnTouchListener(mOnGravatarTouchListener); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java index 78cc71e6d..3c963979d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java @@ -71,6 +71,7 @@ public class ReaderCommentListActivity extends ActionBarActivity { private boolean mIsUpdatingComments; private boolean mHasUpdatedComments; + private boolean mIsSubmittingComment; private long mReplyToCommentId; private int mRestorePosition; @@ -358,7 +359,9 @@ public class ReaderCommentListActivity extends ActionBarActivity { private void checkEmptyView() { TextView txtEmpty = (TextView) findViewById(R.id.text_empty); - boolean isEmpty = hasCommentAdapter() && getCommentAdapter().isEmpty(); + boolean isEmpty = hasCommentAdapter() + && getCommentAdapter().isEmpty() + && !mIsSubmittingComment; if (isEmpty && !NetworkUtils.isNetworkAvailable(this)) { txtEmpty.setText(R.string.no_network_message); txtEmpty.setVisibility(View.VISIBLE); @@ -406,6 +409,7 @@ public class ReaderCommentListActivity extends ActionBarActivity { mImgSubmitComment.setEnabled(false); mEditComment.setEnabled(false); + mIsSubmittingComment = true; // generate a "fake" comment id to assign to the new comment so we can add it to the db // and reflect it in the adapter before the API call returns @@ -417,6 +421,7 @@ public class ReaderCommentListActivity extends ActionBarActivity { if (isFinishing()) { return; } + mIsSubmittingComment = false; mImgSubmitComment.setEnabled(true); mEditComment.setEnabled(true); if (succeeded) { @@ -431,6 +436,7 @@ public class ReaderCommentListActivity extends ActionBarActivity { ToastUtils.showToast( ReaderCommentListActivity.this, R.string.reader_toast_err_comment_failed, ToastUtils.Duration.LONG); } + checkEmptyView(); } }; @@ -449,6 +455,7 @@ public class ReaderCommentListActivity extends ActionBarActivity { getCommentAdapter().addComment(newComment); // make sure it's scrolled into view scrollToCommentId(fakeCommentId); + checkEmptyView(); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java index f5790086b..8b04df9eb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java @@ -999,10 +999,26 @@ public class ReaderPostListFragment extends Fragment return; } + // show "new posts" bar if new posts were downloaded in a followed tag and the adapter + // isn't empty (if it's empty, we want to display the new posts immediately) + boolean showNewPostsBar; if (event.getResult() == ReaderActions.UpdateResult.HAS_NEW && !isPostAdapterEmpty() && event.getAction() == UpdateAction.REQUEST_NEWER && getPostListType() == ReaderPostListType.TAG_FOLLOWED) { + // make sure that these new posts will actually appear at the top of the list - we + // don't want to show "new posts" if the new posts are older ones since the user + // expects to see the new posts at the top of the list. we do this by getting the + // id of the newest post in the database (which will contain the newly downloaded + // posts) and comparing it to the id of the first post in the adapter + long newestPostId = ReaderPostTable.getNewestPostIdWithTag(getCurrentTag()); + ReaderPost post = getPostAdapter().getItem(0); + showNewPostsBar = (post != null && post.postId != newestPostId); + } else { + showNewPostsBar = false; + } + + if (showNewPostsBar) { showNewPostsBar(); refreshPosts(); } else if (event.getResult().isNewOrChanged()) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/adapters/ReaderPostAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/adapters/ReaderPostAdapter.java index b57517eb8..6ad8c2722 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/adapters/ReaderPostAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/adapters/ReaderPostAdapter.java @@ -450,7 +450,7 @@ public class ReaderPostAdapter extends RecyclerView.Adapter<ReaderPostAdapter.Re new LoadPostsTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } - ReaderPost getItem(int position) { + public ReaderPost getItem(int position) { if (isValidPosition(position)) { return mPosts.get(position); } else { |