From 3cc4f7b7bc0cf5d2812dce494a263f6ed836c2d4 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Mon, 10 May 2021 21:22:35 +0900 Subject: [PATCH] Check null url. Fixes austinhuang0131/barinsta#1192 --- .../instagrabber/dialogs/ProfilePicDialogFragment.java | 9 ++++++++- .../awais/instagrabber/repositories/responses/User.java | 3 +++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/awais/instagrabber/dialogs/ProfilePicDialogFragment.java b/app/src/main/java/awais/instagrabber/dialogs/ProfilePicDialogFragment.java index affe5cba..84a829cb 100644 --- a/app/src/main/java/awais/instagrabber/dialogs/ProfilePicDialogFragment.java +++ b/app/src/main/java/awais/instagrabber/dialogs/ProfilePicDialogFragment.java @@ -134,7 +134,14 @@ public class ProfilePicDialogFragment extends DialogFragment { @Override public void onSuccess(final User result) { if (result != null) { - setupPhoto(result.getHDProfilePicUrl()); + final String url = result.getHDProfilePicUrl(); + if (url == null) { + final Context context = getContext(); + if (context == null) return; + Toast.makeText(context, R.string.no_profile_pic_found, Toast.LENGTH_LONG).show(); + return; + } + setupPhoto(url); } } diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/User.java b/app/src/main/java/awais/instagrabber/repositories/responses/User.java index 403ef285..b2f2a0b2 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/User.java +++ b/app/src/main/java/awais/instagrabber/repositories/responses/User.java @@ -111,6 +111,9 @@ public class User implements Serializable { } public String getHDProfilePicUrl() { + if (hdProfilePicUrlInfo == null) { + return getProfilePicUrl(); + } return hdProfilePicUrlInfo.getUrl(); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 36fa5042..8c59762e 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -504,4 +504,5 @@ Clear No Map app found! Click to view full count + No profile pic found!