From: Debajit Ghosh Date: Mon, 21 Sep 2009 01:16:53 +0000 (-0700) Subject: be sure to close the presence cursor when displaying event info. X-Git-Tag: android-x86-2.2~107^2~47^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7d41eeb153cff835572229bc149a09376c7eddd8;p=android-x86%2Fpackages-apps-Calendar.git be sure to close the presence cursor when displaying event info. --- diff --git a/src/com/android/calendar/EventInfoActivity.java b/src/com/android/calendar/EventInfoActivity.java index f78fbc6..714952e 100644 --- a/src/com/android/calendar/EventInfoActivity.java +++ b/src/com/android/calendar/EventInfoActivity.java @@ -983,32 +983,37 @@ public class EventInfoActivity extends Activity implements View.OnClickListener, return; } - cursor.moveToPosition(-1); - while (cursor.moveToNext()) { - String email = cursor.getString(PRESENCE_PROJECTION_EMAIL_INDEX); - int contactId = cursor.getInt(PRESENCE_PROJECTION_CONTACT_ID_INDEX); - ViewHolder vh = mViewHolders.get(email); - int photoId = cursor.getInt(PRESENCE_PROJECTION_PHOTO_ID_INDEX); - if (DEBUG) { - Log.e(TAG, "onQueryComplete Id: " + contactId + " PhotoId: " + photoId - + " Email: " + email); - } - if (vh == null) { - continue; - } - ImageView presenceView = vh.presence; - if (presenceView != null) { - int status = cursor.getInt(PRESENCE_PROJECTION_PRESENCE_INDEX); - presenceView.setImageResource(Presence.getPresenceIconResourceId(status)); - presenceView.setVisibility(View.VISIBLE); - } + try { - if (photoId > 0 && vh.updateCounts < queryIndex) { - vh.updateCounts = queryIndex; - Uri personUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); - ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, vh.avatar, - personUri, R.drawable.ic_contact_picture); + cursor.moveToPosition(-1); + while (cursor.moveToNext()) { + String email = cursor.getString(PRESENCE_PROJECTION_EMAIL_INDEX); + int contactId = cursor.getInt(PRESENCE_PROJECTION_CONTACT_ID_INDEX); + ViewHolder vh = mViewHolders.get(email); + int photoId = cursor.getInt(PRESENCE_PROJECTION_PHOTO_ID_INDEX); + if (DEBUG) { + Log.e(TAG, "onQueryComplete Id: " + contactId + " PhotoId: " + photoId + + " Email: " + email); + } + if (vh == null) { + continue; + } + ImageView presenceView = vh.presence; + if (presenceView != null) { + int status = cursor.getInt(PRESENCE_PROJECTION_PRESENCE_INDEX); + presenceView.setImageResource(Presence.getPresenceIconResourceId(status)); + presenceView.setVisibility(View.VISIBLE); + } + + if (photoId > 0 && vh.updateCounts < queryIndex) { + vh.updateCounts = queryIndex; + Uri personUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); + ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, vh.avatar, + personUri, R.drawable.ic_contact_picture); + } } + } finally { + cursor.close(); } } }