Browse Source

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

legacy
Austin Huang 4 years ago
parent
commit
7b4c005513
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 32
      app/src/main/java/awais/instagrabber/activities/CommentsViewer.java
  2. 2
      app/src/main/java/awais/instagrabber/asyncs/PostsFetcher.java
  3. 9
      app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java

32
app/src/main/java/awais/instagrabber/activities/CommentsViewer.java

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

2
app/src/main/java/awais/instagrabber/asyncs/PostsFetcher.java

@ -131,7 +131,7 @@ public final class PostsFetcher extends AsyncTask<Void, Void, PostModel[]> {
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);
result = models;

9
app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java

@ -67,6 +67,7 @@ import awais.instagrabber.models.direct_messages.DirectItemModel;
import awais.instagrabber.models.direct_messages.InboxThreadModel;
import awais.instagrabber.models.enums.DirectItemType;
import awais.instagrabber.models.enums.DownloadMethod;
import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.models.enums.UserInboxDirection;
import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.Utils;
@ -220,8 +221,12 @@ public class DirectMessageThreadFragment extends Fragment {
case RAVEN_MEDIA:
case MEDIA:
final ProfileModel user = getUser(directItemModel.getUserId());
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();
String url = selectedItem.getMediaType() == MediaItemType.MEDIA_TYPE_VIDEO ? selectedItem.getVideoUrl() : selectedItem.getThumbUrl();
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;
case STORY_SHARE:
if (directItemModel.getReelShare() != null) {

Loading…
Cancel
Save