Browse Source

fix #49, #50 and the saved issue

legacy
Austin Huang 4 years ago
parent
commit
e02ef0aa09
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 7
      app/src/main/java/awais/instagrabber/MainHelper.java
  2. 2
      app/src/main/java/awais/instagrabber/activities/Login.java
  3. 4
      app/src/main/java/awais/instagrabber/activities/SavedViewer.java
  4. 4
      app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java

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

@ -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;

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

@ -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/");
}
}

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

@ -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) {
if (result != null) {
final int oldSize = allItems.size();
if (result != null) {
allItems.addAll(Arrays.asList(result));
postsAdapter.notifyItemRangeInserted(oldSize, result.length);
@ -88,10 +88,12 @@ public final class SavedViewer extends BaseLanguageActivity implements SwipeRefr
}
else {
savedBinding.swipeRefreshLayout.setRefreshing(false);
if (oldSize == 0) {
Toast.makeText(getApplicationContext(), R.string.empty_list, Toast.LENGTH_SHORT).show();
finish();
}
}
}
};
@Override

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

@ -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);

Loading…
Cancel
Save