From 523231c2f20cc14305bcf5c63feb76cd9f2a6b46 Mon Sep 17 00:00:00 2001 From: Viktor Yakovel Date: Thu, 26 Feb 2015 11:23:21 +0100 Subject: Fixed NullPointerException during Cursor reuse Every time an image is selected, CursorPhotoSource.naturalNext() and naturalPrevious() functions are called to find the next/previous images. Those functions check if a cursor which is associated with an ImageData exists and is opened. If the cursor isn't opened then an attempt to open a cursor is made. The problem is that when a new ImageData is constructed inside naturalNext() or naturalPrevious() functions, it shares the Cursor with the currently selected image. Later on, one of the ImageData objects closes the cursor which forces other ImageData's to reopen it. However since uri wasn't set, null pointer exception occurs. Fixed by setting uri on newly created ImageData. Bug: 28054525 Change-Id: I9ebad683089f872299343572f1df4dc7cc4ae628 --- src/com/android/dreams/phototable/CursorPhotoSource.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/com/android/dreams/phototable/CursorPhotoSource.java b/src/com/android/dreams/phototable/CursorPhotoSource.java index f010a92..6af0807 100644 --- a/src/com/android/dreams/phototable/CursorPhotoSource.java +++ b/src/com/android/dreams/phototable/CursorPhotoSource.java @@ -49,6 +49,7 @@ public abstract class CursorPhotoSource extends PhotoSource { if (!current.cursor.isAfterLast()) { data = unpackImageData(current.cursor, null); data.cursor = current.cursor; + data.uri = current.uri; data.position = current.cursor.getPosition(); } return data; @@ -66,6 +67,7 @@ public abstract class CursorPhotoSource extends PhotoSource { if (!current.cursor.isBeforeFirst()) { data = unpackImageData(current.cursor, null); data.cursor = current.cursor; + data.uri = current.uri; data.position = current.cursor.getPosition(); } return data; -- cgit v1.2.3