From d1a93932494a9ac0938d9c88cb2565a8f6fce302 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Thu, 19 Nov 2020 19:00:14 +0900 Subject: [PATCH] FeedModel null checks. Fixes https://github.com/austinhuang0131/barinsta/issues/293 --- .../instagrabber/fragments/PostViewV2Fragment.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java index a2d56916..5482eb0a 100644 --- a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java @@ -233,6 +233,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { return; } feedModel = (FeedModel) feedModelSerializable; + if (feedModel == null) return; if (feedModel.getItemType() == MediaItemType.MEDIA_TYPE_SLIDER) { sliderPosition = arguments.getInt(ARG_SLIDER_POSITION, 0); } @@ -258,7 +259,6 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { @Override public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) { - setupToolbar(); init(); } @@ -322,6 +322,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { @Override public void onSaveInstanceState(@NonNull final Bundle outState) { super.onSaveInstanceState(outState); + if (feedModel == null) return; if (feedModel.getItemType() == MediaItemType.MEDIA_TYPE_SLIDER) { outState.putInt(ARG_SLIDER_POSITION, sliderPosition); } @@ -411,6 +412,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { } private void init() { + if (feedModel == null) return; final String cookie = settingsHelper.getString(Constants.COOKIE); isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) != null; if (!wasPaused && (sharedProfilePicElement != null || sharedMainPostElement != null)) { @@ -668,14 +670,6 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { binding.profilePic.setOnClickListener(v -> navigateToProfile("@" + profileModel.getUsername())); } - private void setupToolbar() { - // fragmentActivity.fitSystemWindows(true); - // final ActionBar actionBar = fragmentActivity.getSupportActionBar(); - // if (actionBar == null) return; - // actionBar.setTitle(null); - // actionBar.setSubtitle(null); - } - private void setupTitles() { final ProfileModel profileModel = feedModel.getProfileModel(); if (profileModel == null) {