From 43b04a5ee126cd258469230e63a1b3413ee5c6cc Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Mon, 17 Aug 2020 15:02:14 -0400 Subject: [PATCH] fix #56 --- app/src/main/java/awais/instagrabber/MainHelper.java | 2 +- app/src/main/java/awais/instagrabber/utils/Utils.java | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/MainHelper.java b/app/src/main/java/awais/instagrabber/MainHelper.java index 01011bac..65c7084e 100755 --- a/app/src/main/java/awais/instagrabber/MainHelper.java +++ b/app/src/main/java/awais/instagrabber/MainHelper.java @@ -262,7 +262,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener { private DiscoverAdapter discoverAdapter; public SimpleExoPlayer currentFeedPlayer; // hack for remix drawer layout private String cookie = Utils.settingsHelper.getString(Constants.COOKIE); - public boolean isLoggedIn = !Utils.isEmpty(cookie); + public boolean isLoggedIn = !Utils.isEmpty(cookie) && Utils.getUserIdFromCookie(cookie) != null; public MainHelper(@NonNull final Main main) { stopCurrentExecutor(); diff --git a/app/src/main/java/awais/instagrabber/utils/Utils.java b/app/src/main/java/awais/instagrabber/utils/Utils.java index 8efd41cf..5e37d3db 100755 --- a/app/src/main/java/awais/instagrabber/utils/Utils.java +++ b/app/src/main/java/awais/instagrabber/utils/Utils.java @@ -150,13 +150,10 @@ public final class Utils { @Nullable public static String getUserIdFromCookie(final String cookie) { if (!isEmpty(cookie)) { - final int uidIndex = cookie.indexOf("ds_user_id"); + final int uidIndex = cookie.indexOf("ds_user_id="); if (uidIndex > 0) { - final int uidEndIndex = cookie.indexOf(';', uidIndex + 10); - if (uidEndIndex > 0) { - final String uid = cookie.substring(uidIndex + 11, uidEndIndex); - return !isEmpty(uid) ? uid : null; - } + String uid = cookie.split("ds_user_id=")[1].split(";")[0]; + return !isEmpty(uid) ? uid : null; } } return null;