From afbba1bcbb63559e8c6a3090494c7830311021e3 Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Sun, 17 Jul 2011 15:55:50 -0700 Subject: [PATCH] Fix NPE in MailboxListFragment Bug: 5037646 Change-Id: I74420d68398446f602ebe858760d9aaf5f88c107 --- .../activity/MailboxFragmentAdapter.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/com/android/email/activity/MailboxFragmentAdapter.java b/src/com/android/email/activity/MailboxFragmentAdapter.java index 8a0f75c75..2d7d0ca4c 100644 --- a/src/com/android/email/activity/MailboxFragmentAdapter.java +++ b/src/com/android/email/activity/MailboxFragmentAdapter.java @@ -16,22 +16,6 @@ package com.android.email.activity; -import com.android.email.Email; -import com.android.email.FolderProperties; -import com.android.email.R; -import com.android.email.ResourceHelper; -import com.android.email.data.ClosingMatrixCursor; -import com.android.email.data.ThrottlingCursorLoader; -import com.android.emailcommon.Logging; -import com.android.emailcommon.provider.Account; -import com.android.emailcommon.provider.EmailContent; -import com.android.emailcommon.provider.EmailContent.AccountColumns; -import com.android.emailcommon.provider.EmailContent.MailboxColumns; -import com.android.emailcommon.provider.EmailContent.Message; -import com.android.emailcommon.provider.Mailbox; -import com.android.emailcommon.utility.Utility; -import com.google.common.annotations.VisibleForTesting; - import android.content.ContentUris; import android.content.Context; import android.content.Loader; @@ -49,6 +33,22 @@ import android.widget.CursorAdapter; import android.widget.ImageView; import android.widget.TextView; +import com.android.email.Email; +import com.android.email.FolderProperties; +import com.android.email.R; +import com.android.email.ResourceHelper; +import com.android.email.data.ClosingMatrixCursor; +import com.android.email.data.ThrottlingCursorLoader; +import com.android.emailcommon.Logging; +import com.android.emailcommon.provider.Account; +import com.android.emailcommon.provider.EmailContent; +import com.android.emailcommon.provider.EmailContent.AccountColumns; +import com.android.emailcommon.provider.EmailContent.MailboxColumns; +import com.android.emailcommon.provider.EmailContent.Message; +import com.android.emailcommon.provider.Mailbox; +import com.android.emailcommon.utility.Utility; +import com.google.common.annotations.VisibleForTesting; + import java.util.ArrayList; /** @@ -210,6 +210,9 @@ class MailboxFragmentAdapter extends CursorAdapter { private boolean isHeader(int position) { Cursor c = getCursor(); + if (c == null) { + return false; + } c.moveToPosition(position); int rowType = c.getInt(c.getColumnIndex(ROW_TYPE)); return rowType == ROW_TYPE_HEADER;