From 4fed608ffcc587dfe0524d65ed70c2deff08d83f Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Fri, 31 Jul 2020 17:34:44 -0400 Subject: [PATCH] custom folder + username folder --- .../instagrabber/asyncs/DiscoverFetcher.java | 34 ++++++++----------- .../instagrabber/asyncs/PostFetcher.java | 3 +- .../instagrabber/asyncs/PostsFetcher.java | 3 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/asyncs/DiscoverFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/DiscoverFetcher.java index a5d276a1..e0459b07 100755 --- a/app/src/main/java/awais/instagrabber/asyncs/DiscoverFetcher.java +++ b/app/src/main/java/awais/instagrabber/asyncs/DiscoverFetcher.java @@ -46,16 +46,10 @@ public final class DiscoverFetcher extends AsyncTask discoverItemModels = fetchItems(customDir, null, maxId); + final ArrayList discoverItemModels = fetchItems(null, maxId); if (discoverItemModels != null) { result = discoverItemModels.toArray(new DiscoverItemModel[0]); if (result.length > 0) { @@ -67,8 +61,7 @@ public final class DiscoverFetcher extends AsyncTask fetchItems(final File customDir, - ArrayList discoverItemModels, final String maxId) { + private ArrayList fetchItems(ArrayList discoverItemModels, final String maxId) { try { final String url = "https://www.instagram.com/explore/grid/?is_prefetch=false&omit_cover_media=true&module=explore_popular" + "&use_sectional_payload=false&cluster_id=explore_all%3A0&include_fixed_destinations=true" + maxId; @@ -99,8 +92,7 @@ public final class DiscoverFetcher extends AsyncTask 50) this.isFirst = false; - discoverItemModels = fetchItems(customDir, discoverItemModels, - "&max_id=" + (lastId++)); + discoverItemModels = fetchItems(discoverItemModels, "&max_id=" + (lastId++)); } } else { urlConnection.disconnect(); @@ -149,8 +138,7 @@ public final class DiscoverFetcher extends AsyncTask (Utils.settingsHelper.getBoolean(DOWNLOAD_USER_FOLDER) ? ("/"+username) : "")); File customDir = null; if (Utils.settingsHelper.getBoolean(FOLDER_SAVE_TO)) { - final String customPath = Utils.settingsHelper.getString(FOLDER_PATH); + final String customPath = Utils.settingsHelper.getString(FOLDER_PATH + + (Utils.settingsHelper.getBoolean(DOWNLOAD_USER_FOLDER) ? ("/"+username) : "")); if (!Utils.isEmpty(customPath)) customDir = new File(customPath); } diff --git a/app/src/main/java/awais/instagrabber/asyncs/PostsFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/PostsFetcher.java index 26458c64..1b750d26 100755 --- a/app/src/main/java/awais/instagrabber/asyncs/PostsFetcher.java +++ b/app/src/main/java/awais/instagrabber/asyncs/PostsFetcher.java @@ -83,7 +83,8 @@ public final class PostsFetcher extends AsyncTask { (Utils.settingsHelper.getBoolean(DOWNLOAD_USER_FOLDER) ? ("/"+username) : "")); File customDir = null; if (Utils.settingsHelper.getBoolean(FOLDER_SAVE_TO)) { - final String customPath = Utils.settingsHelper.getString(FOLDER_PATH); + final String customPath = Utils.settingsHelper.getString(FOLDER_PATH + + (Utils.settingsHelper.getBoolean(DOWNLOAD_USER_FOLDER) ? ("/"+username) : "")); if (!Utils.isEmpty(customPath)) customDir = new File(customPath); }