Items should not have null data. Code exists to handle null
items generated, and skip them, but if data is null, items
are still added to caches and cause exceptions later.
Bug:
19097423
Change-Id: I171ec40369cdcc5a5567968380a600943d4991e4
List<I> result = new ArrayList<>();
if (cursor != null) {
while (cursor.moveToNext()) {
- I data = factory.get(cursor);
- if (data != null) {
- result.add(data);
+ I item = factory.get(cursor);
+ if (item != null) {
+ result.add(item);
} else {
final int dataIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
Log.e(TAG, "Error loading data:" + cursor.getString(dataIndex));
Bitmap b = BitmapFactory.decodeFile(filePath);
if (b == null) {
Log.w(TAG, "PhotoData skipped."
- + " Decoding " + filePath + "failed.");
+ + " Decoding " + filePath + " failed.");
return null;
}
width = b.getWidth();
import android.net.Uri;
import com.android.camera.data.FilmstripContentQueries.CursorToFilmstripItemFactory;
+import com.android.camera.debug.Log;
import java.util.List;
public class PhotoItemFactory implements CursorToFilmstripItemFactory<PhotoItem> {
+ private static final Log.Tag TAG = new Log.Tag("PhotoItemFact");
+
private final Context mContext;
private final ContentResolver mContentResolver;
private final PhotoDataFactory mPhotoDataFactory;
@Override
public PhotoItem get(Cursor c) {
FilmstripItemData data = mPhotoDataFactory.fromCursor(c);
- return new PhotoItem(mContext, data, this);
+ if (data != null) {
+ return new PhotoItem(mContext, data, this);
+ } else {
+ Log.w(TAG, "skipping item with null data, returning null for item");
+ return null;
+ }
}
public PhotoItem get(Uri uri) {
@Override
public VideoItem get(Cursor c) {
VideoItemData data = mVideoDataFactory.fromCursor(c);
- return new VideoItem(mContext, data, this);
+ if (data != null) {
+ return new VideoItem(mContext, data, this);
+ } else {
+ Log.w(TAG, "skipping item with null data, returning null for item");
+ return null;
+ }
}
/** Query for a single video data item */