Skip to content

Commit e02ef0a

Browse files
fix #49, #50 and the saved issue
1 parent 2e988b3 commit e02ef0a

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

app/src/main/java/awais/instagrabber/MainHelper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ else if (isLocation)
119119
endCursor = model.getEndCursor();
120120
hasNextPage = model.hasNextPage();
121121
if (autoloadPosts && hasNextPage)
122-
currentlyExecuting = new PostsFetcher(main.profileModel.getId(), endCursor, this)
122+
currentlyExecuting = new PostsFetcher(
123+
main.profileModel != null ? main.profileModel.getId()
124+
: (main.hashtagModel != null ? main.userQuery : main.locationModel.getId()), endCursor, this)
123125
.setUsername((isLocation || isHashtag) ? null : main.profileModel.getUsername())
124126
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
125127
else {
@@ -462,7 +464,8 @@ public void onDrawerClosed(@NonNull final View drawerView, @MouseDrawer.EdgeGrav
462464
if ((!autoloadPosts || isHashtag) && hasNextPage) {
463465
main.mainBinding.profileView.swipeRefreshLayout.setRefreshing(true);
464466
stopCurrentExecutor();
465-
currentlyExecuting = new PostsFetcher((isHashtag || isLocation) ? main.userQuery : main.profileModel.getId(), endCursor, postsFetchListener)
467+
currentlyExecuting = new PostsFetcher(main.profileModel != null ? main.profileModel.getId()
468+
: (main.hashtagModel != null ? main.userQuery : main.locationModel.getId()), endCursor, postsFetchListener)
466469
.setUsername((isHashtag || isLocation) ? null : main.profileModel.getUsername())
467470
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
468471
endCursor = null;

app/src/main/java/awais/instagrabber/activities/Login.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.os.Build;
77
import android.os.Bundle;
88
import android.view.View;
9+
import android.webkit.CookieManager;
910
import android.webkit.WebChromeClient;
1011
import android.webkit.WebSettings;
1112
import android.webkit.WebView;
@@ -118,6 +119,7 @@ private void initWebView() {
118119
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
119120
}
120121

122+
CookieManager.getInstance().removeAllCookies(null);
121123
loginBinding.webView.loadUrl("https://instagram.com/");
122124
}
123125
}

app/src/main/java/awais/instagrabber/activities/SavedViewer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public final class SavedViewer extends BaseLanguageActivity implements SwipeRefr
5858
private final FetchListener<PostModel[]> postsFetchListener = new FetchListener<PostModel[]>() {
5959
@Override
6060
public void onResult(final PostModel[] result) {
61+
final int oldSize = allItems.size();
6162
if (result != null) {
62-
final int oldSize = allItems.size();
6363
allItems.addAll(Arrays.asList(result));
6464

6565
postsAdapter.notifyItemRangeInserted(oldSize, result.length);
@@ -88,8 +88,10 @@ else if (autoloadPosts && hasNextPage)
8888
}
8989
else {
9090
savedBinding.swipeRefreshLayout.setRefreshing(false);
91-
Toast.makeText(getApplicationContext(), R.string.empty_list, Toast.LENGTH_SHORT).show();
92-
finish();
91+
if (oldSize == 0) {
92+
Toast.makeText(getApplicationContext(), R.string.empty_list, Toast.LENGTH_SHORT).show();
93+
finish();
94+
}
9395
}
9496
}
9597
};

app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS;
4040
import static awais.instagrabber.utils.Constants.AUTOPLAY_VIDEOS;
4141
import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR;
42+
import static awais.instagrabber.utils.Constants.COOKIE;
4243
import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER;
4344
import static awais.instagrabber.utils.Constants.FOLDER_PATH;
4445
import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO;
@@ -57,6 +58,7 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
5758
private Spinner spAppTheme, spLanguage;
5859
private boolean somethingChanged = false;
5960
private int currentTheme, currentLanguage, selectedLanguage;
61+
private String currentCookie;
6062

6163
@Override
6264
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
@@ -121,6 +123,8 @@ public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) {
121123
spLanguage.setSelection(currentLanguage);
122124
spLanguage.setOnItemSelectedListener(this);
123125

126+
currentCookie = settingsHelper.getString(COOKIE);
127+
124128
final AppCompatCheckBox cbSaveTo = contentView.findViewById(R.id.cbSaveTo);
125129
final AppCompatCheckBox cbMuteVideos = contentView.findViewById(R.id.cbMuteVideos);
126130
final AppCompatCheckBox cbBottomToolbar = contentView.findViewById(R.id.cbBottomToolbar);

0 commit comments

Comments
 (0)