From 8666ac00f89e31db8a09b3bdb004a0e275744113 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 6 Mar 2020 09:07:59 +0100 Subject: android: Avoid a crash when recently used file has unknown type I cannot tell how to reproduce (how to open a file of "invalid type"?), but had a crash with this stacktrace in adb log at some point when testing various scenarios with the Android Viewer app. It shows that no proper value was assigned for the resource ID, leaving the default 0. Just don't set an icon in this case. E AndroidRuntime: FATAL EXCEPTION: main E AndroidRuntime: Process: org.libreoffice, PID: 8749 E AndroidRuntime: android.content.res.Resources$NotFoundException: Resource ID #0x0 E AndroidRuntime: at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:246) E AndroidRuntime: at android.content.res.Resources.getDrawableForDensity(Resources.java:905) E AndroidRuntime: at android.content.res.Resources.getDrawable(Resources.java:845) E AndroidRuntime: at android.content.Context.getDrawable(Context.java:687) E AndroidRuntime: at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:358) E AndroidRuntime: at org.libreoffice.ui.RecentFilesAdapter.onBindViewHolder(RecentFilesAdapter.java:73) E AndroidRuntime: at org.libreoffice.ui.RecentFilesAdapter.onBindViewHolder(RecentFilesAdapter.java:25) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6673) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6714) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5647) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5913) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748) E AndroidRuntime: at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232) E AndroidRuntime: at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556) E AndroidRuntime: at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519) E AndroidRuntime: at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614) E AndroidRuntime: at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170) E AndroidRuntime: at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812) E AndroidRuntime: at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3225) [...] Change-Id: I05594c3da26125a18be9226f290430aa9c7fa14c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90090 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- android/source/src/java/org/libreoffice/ui/RecentFilesAdapter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'android') diff --git a/android/source/src/java/org/libreoffice/ui/RecentFilesAdapter.java b/android/source/src/java/org/libreoffice/ui/RecentFilesAdapter.java index 7f81df877dfb..fc16d06a48d7 100644 --- a/android/source/src/java/org/libreoffice/ui/RecentFilesAdapter.java +++ b/android/source/src/java/org/libreoffice/ui/RecentFilesAdapter.java @@ -70,7 +70,10 @@ class RecentFilesAdapter extends RecyclerView.Adapter