1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-23 05:16:58 +00:00

fix #63 (not tested) plus direct download issue

This commit is contained in:
Austin Huang 2020-08-20 21:49:05 -04:00
parent 4b8e8dd8a3
commit 6e754acaba
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
5 changed files with 22 additions and 9 deletions

View File

@ -1100,8 +1100,15 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
}
private void toggleSelection(final PostModel postModel) {
if (postModel != null && postsAdapter != null) {
if (postModel != null && postsAdapter != null && main.selectedItems.size() >= 100) {
Toast.makeText(main, R.string.downloader_too_many, Toast.LENGTH_SHORT);
}
else if (postModel != null && postsAdapter != null) {
if (postModel.isSelected()) main.selectedItems.remove(postModel);
else if (main.selectedItems.size() >= 100) {
Toast.makeText(main, R.string.downloader_too_many, Toast.LENGTH_SHORT);
return;
}
else main.selectedItems.add(postModel);
postModel.setSelected(!postModel.isSelected());
notifyAdapter(postModel);
@ -1217,9 +1224,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
private final View.OnClickListener profileActionListener = new View.OnClickListener() {
@Override
public void onClick(final View v) {
final boolean iamme = (isLoggedIn && main.profileModel != null)
? Utils.getUserIdFromCookie(cookie).equals(main.profileModel.getId())
: false;
final boolean iamme = (isLoggedIn && main.profileModel != null) && Utils.getUserIdFromCookie(cookie).equals(main.profileModel.getId());
if (!isLoggedIn && Utils.dataBox.getFavorite(main.userQuery) != null && v == main.mainBinding.profileView.btnFollow) {
Utils.dataBox.delFavorite(new DataBox.FavoriteModel(main.userQuery,
Long.parseLong(Utils.dataBox.getFavorite(main.userQuery).split("/")[1]),
@ -1283,7 +1288,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
final String urlParameters = "target_user_id="+main.profileModel.getId();
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
urlConnection.setRequestProperty("Content-Length", "" +
Integer.toString(urlParameters.getBytes().length));
urlParameters.getBytes().length);
urlConnection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
wr.writeBytes(urlParameters);

View File

@ -767,6 +767,10 @@ public final class ProfileViewer extends BaseLanguageActivity implements SwipeRe
private void toggleSelection(final PostModel postModel) {
if (postModel != null && postsAdapter != null) {
if (postModel.isSelected()) selectedItems.remove(postModel);
else if (selectedItems.size() >= 100) {
Toast.makeText(ProfileViewer.this, R.string.downloader_too_many, Toast.LENGTH_SHORT);
return;
}
else selectedItems.add(postModel);
postModel.setSelected(!postModel.isSelected());
notifyAdapter(postModel);
@ -823,9 +827,7 @@ public final class ProfileViewer extends BaseLanguageActivity implements SwipeRe
private final View.OnClickListener profileActionListener = new View.OnClickListener() {
@Override
public void onClick(final View v) {
final boolean iamme = (isLoggedIn && profileModel != null)
? Utils.getUserIdFromCookie(cookie).equals(profileModel.getId())
: false;
final boolean iamme = (isLoggedIn && profileModel != null) && Utils.getUserIdFromCookie(cookie).equals(profileModel.getId());
if (!isLoggedIn && Utils.dataBox.getFavorite(userQuery) != null && v == profileBinding.profileView.btnFollow) {
Utils.dataBox.delFavorite(new DataBox.FavoriteModel(userQuery,
Long.parseLong(Utils.dataBox.getFavorite(userQuery).split("/")[1]),
@ -889,7 +891,7 @@ public final class ProfileViewer extends BaseLanguageActivity implements SwipeRe
final String urlParameters = "target_user_id="+profileModel.getId();
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
urlConnection.setRequestProperty("Content-Length", "" +
Integer.toString(urlParameters.getBytes().length));
urlParameters.getBytes().length);
urlConnection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
wr.writeBytes(urlParameters);

View File

@ -226,6 +226,10 @@ public final class SavedViewer extends BaseLanguageActivity implements SwipeRefr
private void toggleSelection(final PostModel postModel) {
if (postModel != null && postsAdapter != null) {
if (postModel.isSelected()) selectedItems.remove(postModel);
else if (selectedItems.size() >= 100) {
Toast.makeText(SavedViewer.this, R.string.downloader_too_many, Toast.LENGTH_SHORT);
return;
}
else selectedItems.add(postModel);
postModel.setSelected(!postModel.isSelected());
notifyAdapter(postModel);

View File

@ -36,6 +36,7 @@ public final class PostFetcher extends AsyncTask<Void, Void, ViewerPostModel[]>
@Override
protected ViewerPostModel[] doInBackground(final Void... voids) {
ViewerPostModel[] result = null;
Utils.setupCookies(Utils.settingsHelper.getString(Constants.COOKIE)); // <- direct download
try {
final HttpURLConnection conn = (HttpURLConnection) new URL("https://www.instagram.com/p/" + shortCode + "/?__a=1").openConnection();
conn.setUseCaches(false);

View File

@ -182,6 +182,7 @@
<string name="downloader_unknown_error">Unknown error occurred!!!</string>
<string name="downloader_error_creating_folder">Error creating folder!</string>
<string name="downloader_error_download_file">Error downloading file</string>
<string name="downloader_too_many">You can only download 100 posts at a time. Don\'t be too greedy!</string>
<string name="comment_viewer_copy_user">Copy username</string>
<string name="comment_viewer_copy_comment">Copy comment</string>
<string name="comment_viewer_reply_comment">Reply to comment</string>