From 528736a18e72da24bb9b4e0cc9d1090238ef1505 Mon Sep 17 00:00:00 2001 From: gdlbo <41114720+gdlbo@users.noreply.github.com> Date: Mon, 3 Oct 2022 01:22:46 +0300 Subject: [PATCH] fixed crash --- .../ru/vtosters/lite/hooks/PhotoViewer.java | 44 +++++++++++++++++-- .../vk/ui/photoviewer/MenuController.smali | 2 +- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/ru/vtosters/lite/hooks/PhotoViewer.java b/app/src/main/java/ru/vtosters/lite/hooks/PhotoViewer.java index f4bb7954d..f71dc222e 100644 --- a/app/src/main/java/ru/vtosters/lite/hooks/PhotoViewer.java +++ b/app/src/main/java/ru/vtosters/lite/hooks/PhotoViewer.java @@ -47,16 +47,52 @@ public class PhotoViewer { public static boolean interceptClick(AttachmentWithMedia attachment, MenuItem item, View view) { if (item.getItemId() == AndroidUtils.getIdentifier("search_photo", "id")) { - searchPhoto(getUrlFromPhotoAttachment((PhotoAttachment) attachment)); + if (attachment instanceof PhotoAttachment) { + searchPhoto(getUrlFromPhotoAttachment((PhotoAttachment) attachment)); + } else if (attachment instanceof DocumentAttachment) { + var documentAttachment = (DocumentAttachment) attachment; + if (documentAttachment.J != null) + try { + searchPhoto(getUrlFromDocumentAttachment(documentAttachment)); + } catch (Exception e) { + ToastUtils.a(getString("photo_get_error")); + } + else + ToastUtils.a(getString("photo_get_error")); + } return true; } else if (item.getItemId() == AndroidUtils.getIdentifier("copy_photo_url", "id")) { - copyPhotoUrl(getUrlFromPhotoAttachment((PhotoAttachment) attachment)); + if (attachment instanceof PhotoAttachment) { + copyPhotoUrl(getUrlFromPhotoAttachment((PhotoAttachment) attachment)); + } else if (attachment instanceof DocumentAttachment) { + var documentAttachment = (DocumentAttachment) attachment; + if (documentAttachment.J != null) + try { + copyPhotoUrl(getUrlFromDocumentAttachment(documentAttachment)); + } catch (Exception e) { + ToastUtils.a(getString("photo_get_error")); + } + else + ToastUtils.a(getString("photo_get_error")); + } return true; } else if (item.getItemId() == AndroidUtils.getIdentifier("open_original_photo", "id")) { - openUrl(getUrlFromPhotoAttachment((PhotoAttachment) attachment)); + if (attachment instanceof PhotoAttachment) { + openUrl(getUrlFromPhotoAttachment((PhotoAttachment) attachment)); + } else if (attachment instanceof DocumentAttachment) { + var documentAttachment = (DocumentAttachment) attachment; + if (documentAttachment.J != null) + try { + openUrl(getUrlFromDocumentAttachment(documentAttachment)); + } catch (Exception e) { + ToastUtils.a(getString("photo_get_error")); + } + else + ToastUtils.a(getString("photo_get_error")); + } return true; } - return true; + return false; } @SuppressLint("UseCompatLoadingForDrawables") diff --git a/smali/smali_classes4/com/vk/ui/photoviewer/MenuController.smali b/smali/smali_classes4/com/vk/ui/photoviewer/MenuController.smali index 07b46556d..381e5ffbc 100644 --- a/smali/smali_classes4/com/vk/ui/photoviewer/MenuController.smali +++ b/smali/smali_classes4/com/vk/ui/photoviewer/MenuController.smali @@ -2761,7 +2761,7 @@ move-result v0 - if-nez v0, :cond_custom + if-eqz v0, :cond_custom return v0