From 2cd98a662011f091f1df6fbfd567ec789b26340c Mon Sep 17 00:00:00 2001 From: Grishka Date: Thu, 28 Sep 2023 20:11:43 +0300 Subject: [PATCH] More crash fixes --- mastodon/build.gradle | 2 +- .../android/ui/photoviewer/ZoomPanView.java | 5 +++-- .../android/ui/views/MediaGridLayout.java | 12 ++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mastodon/build.gradle b/mastodon/build.gradle index b7b7e49c..517d1ee1 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -76,7 +76,7 @@ dependencies { implementation 'me.grishka.litex:viewpager:1.0.0' implementation 'me.grishka.litex:viewpager2:1.0.0' implementation 'me.grishka.litex:palette:1.0.0' - implementation 'me.grishka.appkit:appkit:1.2.12' + implementation 'me.grishka.appkit:appkit:1.2.13' implementation 'com.google.code.gson:gson:2.8.9' implementation 'org.jsoup:jsoup:1.14.3' implementation 'com.squareup:otto:1.3.8' diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/photoviewer/ZoomPanView.java b/mastodon/src/main/java/org/joinmastodon/android/ui/photoviewer/ZoomPanView.java index 58a4dfe2..ac9f5fba 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/photoviewer/ZoomPanView.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/photoviewer/ZoomPanView.java @@ -119,6 +119,9 @@ public class ZoomPanView extends FrameLayout implements ScaleGestureDetector.OnS int width=right-left; int height=bottom-top; + if(width==0 || height==0) + return; + float scale=Math.min(width/(float)child.getWidth(), height/(float)child.getHeight()); minScale=scale; maxScale=Math.max(3f, height/(float)child.getHeight()); @@ -306,8 +309,6 @@ public class ZoomPanView extends FrameLayout implements ScaleGestureDetector.OnS }, 1f).setMinimumVisibleChange(DynamicAnimation.MIN_VISIBLE_CHANGE_ALPHA)); } }else{ - if(animatingTransition) - Log.w(TAG, "updateViewTransform: ", new Throwable().fillInStackTrace()); child.setScaleX(matrixValues[Matrix.MSCALE_X]); child.setScaleY(matrixValues[Matrix.MSCALE_Y]); child.setTranslationX(matrixValues[Matrix.MTRANS_X]); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java b/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java index bd6b297b..67ff45d8 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java @@ -18,7 +18,7 @@ public class MediaGridLayout extends ViewGroup{ public static final int MAX_WIDTH=400; // dp private static final int GAP=2; // dp private PhotoLayoutHelper.TiledLayoutResult tiledLayout; - private int[] columnStarts=new int[10], columnEnds=new int[10], rowStarts=new int[10], rowEnds=new int[10]; + private int[] columnStarts, columnEnds, rowStarts, rowEnds; public MediaGridLayout(Context context){ this(context, null); @@ -45,6 +45,14 @@ public class MediaGridLayout extends ViewGroup{ width=Math.round(width*(tiledLayout.width/(float)PhotoLayoutHelper.MAX_WIDTH)); } + if(rowStarts==null || rowStarts.length