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

fix #75, fix #94 (added error handling for suspicious situations)

This commit is contained in:
Austin Huang 2020-08-29 15:55:40 -04:00
parent 1fda45c01a
commit 7b4c005513
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
3 changed files with 26 additions and 17 deletions

View File

@ -119,21 +119,25 @@ public final class CommentsViewer extends BaseLanguageActivity implements SwipeR
} else if (which == 3) { } else if (which == 3) {
Utils.copyText(this, commentModel.getText().toString()); Utils.copyText(this, commentModel.getText().toString());
} else if (which == 4) { } else if (which == 4) {
focus = commentsBinding.rvComments.findViewWithTag(commentModel); if (commentModel == null) {
focus.setBackgroundColor(0x80888888); Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
commentsBinding.commentCancelParent.setVisibility(View.VISIBLE); }
String mention = "@"+profileModel.getUsername()+" "; else {
commentsBinding.commentText.setText(mention); focus = commentsBinding.rvComments.findViewWithTag(commentModel);
commentsBinding.commentText.requestFocus(); focus.setBackgroundColor(0x80888888);
commentsBinding.commentText.setSelection(mention.length()); commentsBinding.commentCancelParent.setVisibility(View.VISIBLE);
commentsBinding.commentText.postDelayed(new Runnable(){ String mention = "@" + profileModel.getUsername() + " ";
@Override commentsBinding.commentText.setText(mention);
public void run(){ commentsBinding.commentText.requestFocus();
imm = (InputMethodManager) getSystemService(getApplicationContext().INPUT_METHOD_SERVICE); commentsBinding.commentText.setSelection(mention.length());
imm.showSoftInput(commentsBinding.commentText, 0); commentsBinding.commentText.postDelayed(new Runnable() {
} @Override
public void run() {
imm = (InputMethodManager) getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
imm.showSoftInput(commentsBinding.commentText, 0);
}
}, 200);
} }
,200);
} else if (which == 5) { } else if (which == 5) {
new CommentAction().execute((commentModel.getLiked() ? "unlike/" : "like/")+commentModel.getId()); new CommentAction().execute((commentModel.getLiked() ? "unlike/" : "like/")+commentModel.getId());
} else if (which == 6) { } else if (which == 6) {

View File

@ -131,7 +131,7 @@ public final class PostsFetcher extends AsyncTask<Void, Void, PostModel[]> {
Utils.checkExistence(downloadDir, customDir, isSlider, models[i]); Utils.checkExistence(downloadDir, customDir, isSlider, models[i]);
} }
if (models[models.length - 1] != null) if (models.length > 0 && models[models.length - 1] != null)
models[models.length - 1].setPageCursor(hasNextPage, endCursor); models[models.length - 1].setPageCursor(hasNextPage, endCursor);
result = models; result = models;

View File

@ -67,6 +67,7 @@ import awais.instagrabber.models.direct_messages.DirectItemModel;
import awais.instagrabber.models.direct_messages.InboxThreadModel; import awais.instagrabber.models.direct_messages.InboxThreadModel;
import awais.instagrabber.models.enums.DirectItemType; import awais.instagrabber.models.enums.DirectItemType;
import awais.instagrabber.models.enums.DownloadMethod; import awais.instagrabber.models.enums.DownloadMethod;
import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.models.enums.UserInboxDirection; import awais.instagrabber.models.enums.UserInboxDirection;
import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.Utils; import awais.instagrabber.utils.Utils;
@ -220,8 +221,12 @@ public class DirectMessageThreadFragment extends Fragment {
case RAVEN_MEDIA: case RAVEN_MEDIA:
case MEDIA: case MEDIA:
final ProfileModel user = getUser(directItemModel.getUserId()); final ProfileModel user = getUser(directItemModel.getUserId());
Utils.dmDownload(requireContext(), user.getUsername(), DownloadMethod.DOWNLOAD_DIRECT, Collections.singletonList(itemType == DirectItemType.MEDIA ? directItemModel.getMediaModel() : directItemModel.getRavenMediaModel().getMedia())); String url = selectedItem.getMediaType() == MediaItemType.MEDIA_TYPE_VIDEO ? selectedItem.getVideoUrl() : selectedItem.getThumbUrl();
Toast.makeText(requireContext(), R.string.downloader_downloading_media, Toast.LENGTH_SHORT).show(); if (url != null) {
Utils.dmDownload(requireContext(), user.getUsername(), DownloadMethod.DOWNLOAD_DIRECT, Collections.singletonList(itemType == DirectItemType.MEDIA ? directItemModel.getMediaModel() : directItemModel.getRavenMediaModel().getMedia()));
Toast.makeText(requireContext(), R.string.downloader_downloading_media, Toast.LENGTH_SHORT).show();
}
else Toast.makeText(requireContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
break; break;
case STORY_SHARE: case STORY_SHARE:
if (directItemModel.getReelShare() != null) { if (directItemModel.getReelShare() != null) {