From d4cec01e7d7e54745fa0959317ed420a303969b9 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Fri, 5 Apr 2019 18:59:05 -0400 Subject: [PATCH] fixed merge conflict --- .../android/ui/posts/EditPostActivity.java | 2 +- .../ui/posts/EditPostPreviewFragment.java | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index 2e703f1b7fe2..001bf7412591 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -2223,7 +2223,7 @@ public Fragment getItem(int position) { case 3: return HistoryListFragment.Companion.newInstance(mPost, mSite); default: - return EditPostPreviewFragment.newInstance(mPost); + return EditPostPreviewFragment.newInstance(mPost, mSite); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostPreviewFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostPreviewFragment.java index b51cc6b9f820..34331be67d46 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostPreviewFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostPreviewFragment.java @@ -16,8 +16,11 @@ import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.model.PostModel; +import org.wordpress.android.fluxc.model.SiteModel; +import org.wordpress.android.fluxc.store.AccountStore; import org.wordpress.android.fluxc.store.PostStore; import org.wordpress.android.util.StringUtils; +import org.wordpress.android.util.WPWebViewClient; import javax.inject.Inject; @@ -26,12 +29,15 @@ public class EditPostPreviewFragment extends Fragment { private WebView mWebView; private int mLocalPostId; private LoadPostPreviewTask mLoadTask; + private SiteModel mSite; @Inject PostStore mPostStore; + @Inject AccountStore mAccountStore; - public static EditPostPreviewFragment newInstance(@NonNull PostModel post) { + public static EditPostPreviewFragment newInstance(@NonNull PostModel post, SiteModel site) { EditPostPreviewFragment fragment = new EditPostPreviewFragment(); Bundle bundle = new Bundle(); + bundle.putSerializable(WordPress.SITE, site); bundle.putInt(ARG_LOCAL_POST_ID, post.getId()); fragment.setArguments(bundle); return fragment; @@ -44,6 +50,12 @@ public void setArguments(Bundle args) { mSite = (SiteModel) args.getSerializable(WordPress.SITE); } + @Override + public void onSaveInstanceState(Bundle outState) { + outState.putSerializable(WordPress.SITE, mSite); + super.onSaveInstanceState(outState); + } + @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -55,6 +67,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, ViewGroup rootView = (ViewGroup) inflater .inflate(R.layout.edit_post_preview_fragment, container, false); mWebView = rootView.findViewById(R.id.post_preview_web_view); + WPWebViewClient client = new WPWebViewClient(mSite, mAccountStore.getAccessToken()); + mWebView.setWebViewClient(client); mWebView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() {