From e1a13c7eeeed6d2be59b79472d4df3d8d6a7cb06 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Tue, 8 Sep 2020 20:27:13 +0900 Subject: [PATCH] Fix profile, location view when logged out --- .../instagrabber/fragments/main/ProfileFragment.java | 6 +++--- app/src/main/java/awais/instagrabber/utils/Utils.java | 11 +++++------ app/src/main/res/navigation/profile_nav_graph.xml | 11 +++++++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java index 329177ac..071b5618 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java @@ -281,7 +281,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe username = fragmentArgs.getUsername(); setUsernameDelayed(); } - if (!isLoggedIn) { + if (Utils.isEmpty(username) && !isLoggedIn) { binding.privatePage1.setImageResource(R.drawable.ic_outline_info_24); binding.privatePage2.setText(R.string.no_acc); binding.privatePage.setVisibility(View.VISIBLE); @@ -733,8 +733,8 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe final List postModels = postsViewModel.getList().getValue(); if (postModels == null || postModels.size() == 0) return; if (postModels.get(0) == null) return; - final String postId = postModels.get(0).getPostId(); - final boolean isId = postId != null; + final String postId = isLoggedIn ? postModels.get(0).getPostId() : postModels.get(0).getShortCode(); + final boolean isId = isLoggedIn && postId != null; final String[] idsOrShortCodes = new String[postModels.size()]; for (int i = 0; i < postModels.size(); i++) { idsOrShortCodes[i] = isId ? postModels.get(i).getPostId() diff --git a/app/src/main/java/awais/instagrabber/utils/Utils.java b/app/src/main/java/awais/instagrabber/utils/Utils.java index 047f97da..71249336 100755 --- a/app/src/main/java/awais/instagrabber/utils/Utils.java +++ b/app/src/main/java/awais/instagrabber/utils/Utils.java @@ -77,7 +77,6 @@ import awais.instagrabber.asyncs.PostFetcher; import awais.instagrabber.customviews.CommentMentionClickSpan; import awais.instagrabber.databinding.DialogImportExportBinding; import awais.instagrabber.models.BasePostModel; -import awais.instagrabber.models.IntentModel; import awais.instagrabber.models.ProfileModel; import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.direct_messages.DirectItemModel; @@ -86,7 +85,6 @@ import awais.instagrabber.models.direct_messages.InboxThreadModel; import awais.instagrabber.models.enums.DirectItemType; import awais.instagrabber.models.enums.DownloadMethod; import awais.instagrabber.models.enums.InboxReadState; -import awais.instagrabber.models.enums.IntentModelType; import awais.instagrabber.models.enums.MediaItemType; import awais.instagrabber.models.enums.NotificationType; import awais.instagrabber.models.enums.RavenExpiringMediaType; @@ -1023,8 +1021,10 @@ public final class Utils { try { final String displayUrl = model.getDisplayUrl(); - final int index = displayUrl.indexOf('?'); - + int index = displayUrl.indexOf('?'); + if (index < 0) { + return; + } final String fileName = model.getPostId() + '_'; final String extension = displayUrl.substring(index - 4, index); @@ -1428,8 +1428,7 @@ public final class Utils { u = random.nextLong() >>> 1) // retry ; r += origin; - } - else { // range not representable as long + } else { // range not representable as long while (r < origin || r >= bound) r = random.nextLong(); } diff --git a/app/src/main/res/navigation/profile_nav_graph.xml b/app/src/main/res/navigation/profile_nav_graph.xml index 39f5a144..81e41859 100644 --- a/app/src/main/res/navigation/profile_nav_graph.xml +++ b/app/src/main/res/navigation/profile_nav_graph.xml @@ -44,6 +44,17 @@ app:nullable="false" /> + + + + + +