diff --git a/app/src/main/java/androidx/paging/PagedList.java b/app/src/main/java/androidx/paging/PagedList.java index 1d4a184efd..19b8d5cca5 100644 --- a/app/src/main/java/androidx/paging/PagedList.java +++ b/app/src/main/java/androidx/paging/PagedList.java @@ -525,14 +525,26 @@ public abstract class PagedList extends AbstractList { @SuppressWarnings("WeakerAccess") /* synthetic access */ void dispatchBoundaryCallbacks(boolean begin, boolean end) { - // safe to deref mBoundaryCallback here, since we only defer if mBoundaryCallback present - if (begin) { - //noinspection ConstantConditions - mBoundaryCallback.onItemAtFrontLoaded(mStorage.getFirstLoadedItem()); - } - if (end) { - //noinspection ConstantConditions - mBoundaryCallback.onItemAtEndLoaded(mStorage.getLastLoadedItem()); + try { + // safe to deref mBoundaryCallback here, since we only defer if mBoundaryCallback present + if (begin) { + //noinspection ConstantConditions + mBoundaryCallback.onItemAtFrontLoaded(mStorage.getFirstLoadedItem()); + } + if (end) { + //noinspection ConstantConditions + mBoundaryCallback.onItemAtEndLoaded(mStorage.getLastLoadedItem()); + } + } catch (Throwable ex) { + eu.faircode.email.Log.w(ex); + /* + java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1 + at java.util.ArrayList.get(ArrayList.java:439) + at androidx.paging.PagedStorage.getLastLoadedItem(SourceFile:361) + at androidx.paging.PagedList.dispatchBoundaryCallbacks(SourceFile:535) + at androidx.paging.PagedList.tryDispatchBoundaryCallbacks(SourceFile:522) + at androidx.paging.PagedList$1.run(SourceFile:487) + */ } } diff --git a/patches/PagedList.patch b/patches/PagedList.patch new file mode 100644 index 0000000000..b74c914bfc --- /dev/null +++ b/patches/PagedList.patch @@ -0,0 +1,39 @@ +diff --git a/app/src/main/java/androidx/paging/PagedList.java b/app/src/main/java/androidx/paging/PagedList.java +index 1d4a184ef..19b8d5cca 100644 +--- a/app/src/main/java/androidx/paging/PagedList.java ++++ b/app/src/main/java/androidx/paging/PagedList.java +@@ -525,14 +525,26 @@ public abstract class PagedList extends AbstractList { + + @SuppressWarnings("WeakerAccess") /* synthetic access */ + void dispatchBoundaryCallbacks(boolean begin, boolean end) { +- // safe to deref mBoundaryCallback here, since we only defer if mBoundaryCallback present +- if (begin) { +- //noinspection ConstantConditions +- mBoundaryCallback.onItemAtFrontLoaded(mStorage.getFirstLoadedItem()); +- } +- if (end) { +- //noinspection ConstantConditions +- mBoundaryCallback.onItemAtEndLoaded(mStorage.getLastLoadedItem()); ++ try { ++ // safe to deref mBoundaryCallback here, since we only defer if mBoundaryCallback present ++ if (begin) { ++ //noinspection ConstantConditions ++ mBoundaryCallback.onItemAtFrontLoaded(mStorage.getFirstLoadedItem()); ++ } ++ if (end) { ++ //noinspection ConstantConditions ++ mBoundaryCallback.onItemAtEndLoaded(mStorage.getLastLoadedItem()); ++ } ++ } catch (Throwable ex) { ++ eu.faircode.email.Log.w(ex); ++ /* ++ java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1 ++ at java.util.ArrayList.get(ArrayList.java:439) ++ at androidx.paging.PagedStorage.getLastLoadedItem(SourceFile:361) ++ at androidx.paging.PagedList.dispatchBoundaryCallbacks(SourceFile:535) ++ at androidx.paging.PagedList.tryDispatchBoundaryCallbacks(SourceFile:522) ++ at androidx.paging.PagedList$1.run(SourceFile:487) ++ */ + } + } +