Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/org/wordpress/android/ui/posts/PostsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -680,16 +680,13 @@ protected String doInBackground(Post... params) {
|| (!isPage && !"publish".equals(contentHash.get(
"post_status").toString()))) {
if (isPage) {
errorMsg = getResources().getText(
R.string.page_not_published).toString();
errorMsg = getString(R.string.page_not_published);
} else {
errorMsg = getResources().getText(
R.string.post_not_published).toString();
errorMsg = getString(R.string.post_not_published);
}
return null;
} else {
String postURL = contentHash.get("permaLink")
.toString();
String postURL = contentHash.get("permaLink").toString();
String shortlink = getShortlinkTagHref(postURL);
if (shortlink == null) {
result = postURL;
Expand Down
22 changes: 15 additions & 7 deletions src/org/wordpress/android/ui/posts/PostsListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewSwitcher;

import org.wordpress.android.R;
import org.wordpress.android.WordPress;
import org.wordpress.android.models.Blog;
Expand Down Expand Up @@ -56,6 +57,7 @@ public class PostsListFragment extends ListFragment {
private OnPostActionListener mOnPostActionListener;
private PostsActivity mParentActivity;
private ListScrollPositionManager mListScrollPositionManager;
private int mLoadedBlogID;

public boolean inDrafts = false;
public List<String> imageUrl = new Vector<String>();
Expand Down Expand Up @@ -122,6 +124,10 @@ public void onAttach(Activity activity) {
public void onResume() {
super.onResume();
mParentActivity = (PostsActivity) getActivity();
if (mLoadedBlogID != WordPress.getCurrentBlog().getBlogId()) {
WordPress.currentPost = null;
loadPosts(false);
}
}

public void createSwitcher() {
Expand Down Expand Up @@ -185,12 +191,11 @@ public void refreshPosts(final boolean loadMore) {

public boolean loadPosts(boolean loadMore) { // loads posts from the db
List<Map<String, Object>> loadedPosts;
if (WordPress.currentBlog != null) {
mLoadedBlogID = WordPress.currentBlog.getBlogId();
}
try {
if (isPage) {
loadedPosts = WordPress.wpDB.loadUploadedPosts(WordPress.currentBlog.getId(), true);
} else {
loadedPosts = WordPress.wpDB.loadUploadedPosts(WordPress.currentBlog.getId(), false);
}
loadedPosts = WordPress.wpDB.loadUploadedPosts(WordPress.currentBlog.getId(), isPage);
} catch (Exception e1) {
return false;
}
Expand All @@ -210,6 +215,10 @@ public boolean loadPosts(boolean loadMore) { // loads posts from the db
mStatuses = new String[0];
if (mPostListAdapter != null) {
mPostListAdapter.notifyDataSetChanged();
if (WordPress.currentPost != null) {
mOnPostActionListener.onPostAction(PostsActivity.POST_CLEAR, WordPress.currentPost);
WordPress.currentPost = null;
}
}
}
if (loadedPosts != null) {
Expand Down Expand Up @@ -655,8 +664,7 @@ protected Boolean doInBackground(List<?>... args) {
WordPress.wpDB.deleteUploadedPosts(
WordPress.currentBlog.getId(),
WordPress.currentPost.isPage());
mOnPostActionListener
.onPostAction(PostsActivity.POST_CLEAR,
mOnPostActionListener.onPostAction(PostsActivity.POST_CLEAR,
WordPress.currentPost);
} catch (Exception e) {
e.printStackTrace();
Expand Down