1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 22:57:29 +00:00

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(); endCursor = model.getEndCursor();
hasNextPage = model.hasNextPage(); hasNextPage = model.hasNextPage();
if (autoloadPosts && 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()) .setUsername((isLocation || isHashtag) ? null : main.profileModel.getUsername())
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else { else {
@ -462,7 +464,8 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
if ((!autoloadPosts || isHashtag) && hasNextPage) { if ((!autoloadPosts || isHashtag) && hasNextPage) {
main.mainBinding.profileView.swipeRefreshLayout.setRefreshing(true); main.mainBinding.profileView.swipeRefreshLayout.setRefreshing(true);
stopCurrentExecutor(); 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()) .setUsername((isHashtag || isLocation) ? null : main.profileModel.getUsername())
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
endCursor = null; endCursor = null;

View File

@ -6,6 +6,7 @@ import android.graphics.Bitmap;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
@ -118,6 +119,7 @@ public final class Login extends BaseLanguageActivity implements View.OnClickLis
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
} }
CookieManager.getInstance().removeAllCookies(null);
loginBinding.webView.loadUrl("https://instagram.com/"); 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[]>() { private final FetchListener<PostModel[]> postsFetchListener = new FetchListener<PostModel[]>() {
@Override @Override
public void onResult(final PostModel[] result) { public void onResult(final PostModel[] result) {
if (result != null) {
final int oldSize = allItems.size(); final int oldSize = allItems.size();
if (result != null) {
allItems.addAll(Arrays.asList(result)); allItems.addAll(Arrays.asList(result));
postsAdapter.notifyItemRangeInserted(oldSize, result.length); postsAdapter.notifyItemRangeInserted(oldSize, result.length);
@ -88,10 +88,12 @@ public final class SavedViewer extends BaseLanguageActivity implements SwipeRefr
} }
else { else {
savedBinding.swipeRefreshLayout.setRefreshing(false); savedBinding.swipeRefreshLayout.setRefreshing(false);
if (oldSize == 0) {
Toast.makeText(getApplicationContext(), R.string.empty_list, Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(), R.string.empty_list, Toast.LENGTH_SHORT).show();
finish(); finish();
} }
} }
}
}; };
@Override @Override

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.AUTOLOAD_POSTS;
import static awais.instagrabber.utils.Constants.AUTOPLAY_VIDEOS; import static awais.instagrabber.utils.Constants.AUTOPLAY_VIDEOS;
import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR; 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.DOWNLOAD_USER_FOLDER;
import static awais.instagrabber.utils.Constants.FOLDER_PATH; import static awais.instagrabber.utils.Constants.FOLDER_PATH;
import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO; 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 Spinner spAppTheme, spLanguage;
private boolean somethingChanged = false; private boolean somethingChanged = false;
private int currentTheme, currentLanguage, selectedLanguage; private int currentTheme, currentLanguage, selectedLanguage;
private String currentCookie;
@Override @Override
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) { 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.setSelection(currentLanguage);
spLanguage.setOnItemSelectedListener(this); spLanguage.setOnItemSelectedListener(this);
currentCookie = settingsHelper.getString(COOKIE);
final AppCompatCheckBox cbSaveTo = contentView.findViewById(R.id.cbSaveTo); final AppCompatCheckBox cbSaveTo = contentView.findViewById(R.id.cbSaveTo);
final AppCompatCheckBox cbMuteVideos = contentView.findViewById(R.id.cbMuteVideos); final AppCompatCheckBox cbMuteVideos = contentView.findViewById(R.id.cbMuteVideos);
final AppCompatCheckBox cbBottomToolbar = contentView.findViewById(R.id.cbBottomToolbar); final AppCompatCheckBox cbBottomToolbar = contentView.findViewById(R.id.cbBottomToolbar);