From 16fd56c7e5a949286b8414a19eac46b21173024d Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sun, 21 Mar 2021 00:23:25 +0900 Subject: [PATCH] Fix profile fetching when username sometimes without '@' --- .../instagrabber/fragments/main/ProfileFragment.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 de355f2f..12a42ff6 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java @@ -592,8 +592,11 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe private void fetchProfileDetails() { accountIsUpdated = false; - new ProfileFetcher(TextUtils.isEmpty(username) ? null : username.trim().substring(1), - myId, isLoggedIn, new FetchListener() { + String usernameTemp = username.trim(); + if (usernameTemp.startsWith("@")) { + usernameTemp = usernameTemp.substring(1); + } + new ProfileFetcher(TextUtils.isEmpty(username) ? null : usernameTemp, myId, isLoggedIn, new FetchListener() { @Override public void onResult(final User user) { if (getContext() == null) return; @@ -614,7 +617,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe isLoggedIn ? R.string.error_loading_profile_loggedin : R.string.error_loading_profile, Toast.LENGTH_LONG).show(); else Toast.makeText(context, t.getMessage(), Toast.LENGTH_SHORT).show(); - } catch (final Throwable e) {} + } catch (final Throwable ignored) {} } }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);