mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 22:57:29 +00:00
fix #63 (not tested) plus direct download issue
This commit is contained in:
parent
4b8e8dd8a3
commit
6e754acaba
@ -1100,8 +1100,15 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void toggleSelection(final PostModel postModel) {
|
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);
|
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);
|
else main.selectedItems.add(postModel);
|
||||||
postModel.setSelected(!postModel.isSelected());
|
postModel.setSelected(!postModel.isSelected());
|
||||||
notifyAdapter(postModel);
|
notifyAdapter(postModel);
|
||||||
@ -1217,9 +1224,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||||||
private final View.OnClickListener profileActionListener = new View.OnClickListener() {
|
private final View.OnClickListener profileActionListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View v) {
|
public void onClick(final View v) {
|
||||||
final boolean iamme = (isLoggedIn && main.profileModel != null)
|
final boolean iamme = (isLoggedIn && main.profileModel != null) && Utils.getUserIdFromCookie(cookie).equals(main.profileModel.getId());
|
||||||
? Utils.getUserIdFromCookie(cookie).equals(main.profileModel.getId())
|
|
||||||
: false;
|
|
||||||
if (!isLoggedIn && Utils.dataBox.getFavorite(main.userQuery) != null && v == main.mainBinding.profileView.btnFollow) {
|
if (!isLoggedIn && Utils.dataBox.getFavorite(main.userQuery) != null && v == main.mainBinding.profileView.btnFollow) {
|
||||||
Utils.dataBox.delFavorite(new DataBox.FavoriteModel(main.userQuery,
|
Utils.dataBox.delFavorite(new DataBox.FavoriteModel(main.userQuery,
|
||||||
Long.parseLong(Utils.dataBox.getFavorite(main.userQuery).split("/")[1]),
|
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();
|
final String urlParameters = "target_user_id="+main.profileModel.getId();
|
||||||
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||||
urlConnection.setRequestProperty("Content-Length", "" +
|
urlConnection.setRequestProperty("Content-Length", "" +
|
||||||
Integer.toString(urlParameters.getBytes().length));
|
urlParameters.getBytes().length);
|
||||||
urlConnection.setDoOutput(true);
|
urlConnection.setDoOutput(true);
|
||||||
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
|
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
|
||||||
wr.writeBytes(urlParameters);
|
wr.writeBytes(urlParameters);
|
||||||
|
@ -767,6 +767,10 @@ public final class ProfileViewer extends BaseLanguageActivity implements SwipeRe
|
|||||||
private void toggleSelection(final PostModel postModel) {
|
private void toggleSelection(final PostModel postModel) {
|
||||||
if (postModel != null && postsAdapter != null) {
|
if (postModel != null && postsAdapter != null) {
|
||||||
if (postModel.isSelected()) selectedItems.remove(postModel);
|
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);
|
else selectedItems.add(postModel);
|
||||||
postModel.setSelected(!postModel.isSelected());
|
postModel.setSelected(!postModel.isSelected());
|
||||||
notifyAdapter(postModel);
|
notifyAdapter(postModel);
|
||||||
@ -823,9 +827,7 @@ public final class ProfileViewer extends BaseLanguageActivity implements SwipeRe
|
|||||||
private final View.OnClickListener profileActionListener = new View.OnClickListener() {
|
private final View.OnClickListener profileActionListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View v) {
|
public void onClick(final View v) {
|
||||||
final boolean iamme = (isLoggedIn && profileModel != null)
|
final boolean iamme = (isLoggedIn && profileModel != null) && Utils.getUserIdFromCookie(cookie).equals(profileModel.getId());
|
||||||
? Utils.getUserIdFromCookie(cookie).equals(profileModel.getId())
|
|
||||||
: false;
|
|
||||||
if (!isLoggedIn && Utils.dataBox.getFavorite(userQuery) != null && v == profileBinding.profileView.btnFollow) {
|
if (!isLoggedIn && Utils.dataBox.getFavorite(userQuery) != null && v == profileBinding.profileView.btnFollow) {
|
||||||
Utils.dataBox.delFavorite(new DataBox.FavoriteModel(userQuery,
|
Utils.dataBox.delFavorite(new DataBox.FavoriteModel(userQuery,
|
||||||
Long.parseLong(Utils.dataBox.getFavorite(userQuery).split("/")[1]),
|
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();
|
final String urlParameters = "target_user_id="+profileModel.getId();
|
||||||
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||||
urlConnection.setRequestProperty("Content-Length", "" +
|
urlConnection.setRequestProperty("Content-Length", "" +
|
||||||
Integer.toString(urlParameters.getBytes().length));
|
urlParameters.getBytes().length);
|
||||||
urlConnection.setDoOutput(true);
|
urlConnection.setDoOutput(true);
|
||||||
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
|
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
|
||||||
wr.writeBytes(urlParameters);
|
wr.writeBytes(urlParameters);
|
||||||
|
@ -226,6 +226,10 @@ public final class SavedViewer extends BaseLanguageActivity implements SwipeRefr
|
|||||||
private void toggleSelection(final PostModel postModel) {
|
private void toggleSelection(final PostModel postModel) {
|
||||||
if (postModel != null && postsAdapter != null) {
|
if (postModel != null && postsAdapter != null) {
|
||||||
if (postModel.isSelected()) selectedItems.remove(postModel);
|
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);
|
else selectedItems.add(postModel);
|
||||||
postModel.setSelected(!postModel.isSelected());
|
postModel.setSelected(!postModel.isSelected());
|
||||||
notifyAdapter(postModel);
|
notifyAdapter(postModel);
|
||||||
|
@ -36,6 +36,7 @@ public final class PostFetcher extends AsyncTask<Void, Void, ViewerPostModel[]>
|
|||||||
@Override
|
@Override
|
||||||
protected ViewerPostModel[] doInBackground(final Void... voids) {
|
protected ViewerPostModel[] doInBackground(final Void... voids) {
|
||||||
ViewerPostModel[] result = null;
|
ViewerPostModel[] result = null;
|
||||||
|
Utils.setupCookies(Utils.settingsHelper.getString(Constants.COOKIE)); // <- direct download
|
||||||
try {
|
try {
|
||||||
final HttpURLConnection conn = (HttpURLConnection) new URL("https://www.instagram.com/p/" + shortCode + "/?__a=1").openConnection();
|
final HttpURLConnection conn = (HttpURLConnection) new URL("https://www.instagram.com/p/" + shortCode + "/?__a=1").openConnection();
|
||||||
conn.setUseCaches(false);
|
conn.setUseCaches(false);
|
||||||
|
@ -182,6 +182,7 @@
|
|||||||
<string name="downloader_unknown_error">Unknown error occurred!!!</string>
|
<string name="downloader_unknown_error">Unknown error occurred!!!</string>
|
||||||
<string name="downloader_error_creating_folder">Error creating folder!</string>
|
<string name="downloader_error_creating_folder">Error creating folder!</string>
|
||||||
<string name="downloader_error_download_file">Error downloading file</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_user">Copy username</string>
|
||||||
<string name="comment_viewer_copy_comment">Copy comment</string>
|
<string name="comment_viewer_copy_comment">Copy comment</string>
|
||||||
<string name="comment_viewer_reply_comment">Reply to comment</string>
|
<string name="comment_viewer_reply_comment">Reply to comment</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user