fix #49, #50 and the saved issue

This commit is contained in:
Austin Huang 2020-08-13 13:21:26 -04:00
parent 2e988b3ef3
commit e02ef0aa09
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
4 changed files with 16 additions and 5 deletions

View File

@ -119,7 +119,9 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
endCursor = model.getEndCursor();
hasNextPage = model.hasNextPage();
if (autoloadPosts && hasNextPage)
currentlyExecuting = new PostsFetcher(main.profileModel.getId(), endCursor, this)
currentlyExecuting = new PostsFetcher(
main.profileModel != null ? main.profileModel.getId()
: (main.hashtagModel != null ? main.userQuery : main.locationModel.getId()), endCursor, this)
.setUsername((isLocation || isHashtag) ? null : main.profileModel.getUsername())
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else {
@ -462,7 +464,8 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
if ((!autoloadPosts || isHashtag) && hasNextPage) {
main.mainBinding.profileView.swipeRefreshLayout.setRefreshing(true);
stopCurrentExecutor();
currentlyExecuting = new PostsFetcher((isHashtag || isLocation) ? main.userQuery : main.profileModel.getId(), endCursor, postsFetchListener)
currentlyExecuting = new PostsFetcher(main.profileModel != null ? main.profileModel.getId()
: (main.hashtagModel != null ? main.userQuery : main.locationModel.getId()), endCursor, postsFetchListener)
.setUsername((isHashtag || isLocation) ? null : main.profileModel.getUsername())
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
endCursor = null;

View File

@ -6,6 +6,7 @@ import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
@ -118,6 +119,7 @@ public final class Login extends BaseLanguageActivity implements View.OnClickLis
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
CookieManager.getInstance().removeAllCookies(null);
loginBinding.webView.loadUrl("https://instagram.com/");
}
}

View File

@ -58,8 +58,8 @@ public final class SavedViewer extends BaseLanguageActivity implements SwipeRefr
private final FetchListener<PostModel[]> postsFetchListener = new FetchListener<PostModel[]>() {
@Override
public void onResult(final PostModel[] result) {
final int oldSize = allItems.size();
if (result != null) {
final int oldSize = allItems.size();
allItems.addAll(Arrays.asList(result));
postsAdapter.notifyItemRangeInserted(oldSize, result.length);
@ -88,8 +88,10 @@ public final class SavedViewer extends BaseLanguageActivity implements SwipeRefr
}
else {
savedBinding.swipeRefreshLayout.setRefreshing(false);
Toast.makeText(getApplicationContext(), R.string.empty_list, Toast.LENGTH_SHORT).show();
finish();
if (oldSize == 0) {
Toast.makeText(getApplicationContext(), R.string.empty_list, Toast.LENGTH_SHORT).show();
finish();
}
}
}
};

View File

@ -39,6 +39,7 @@ import static awais.instagrabber.utils.Constants.APP_THEME;
import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS;
import static awais.instagrabber.utils.Constants.AUTOPLAY_VIDEOS;
import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR;
import static awais.instagrabber.utils.Constants.COOKIE;
import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER;
import static awais.instagrabber.utils.Constants.FOLDER_PATH;
import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO;
@ -57,6 +58,7 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
private Spinner spAppTheme, spLanguage;
private boolean somethingChanged = false;
private int currentTheme, currentLanguage, selectedLanguage;
private String currentCookie;
@Override
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
@ -121,6 +123,8 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
spLanguage.setSelection(currentLanguage);
spLanguage.setOnItemSelectedListener(this);
currentCookie = settingsHelper.getString(COOKIE);
final AppCompatCheckBox cbSaveTo = contentView.findViewById(R.id.cbSaveTo);
final AppCompatCheckBox cbMuteVideos = contentView.findViewById(R.id.cbMuteVideos);
final AppCompatCheckBox cbBottomToolbar = contentView.findViewById(R.id.cbBottomToolbar);