Merge "Fix NPE in background thread" into lmp-mr1-dev
diff --git a/res/layout/item_photo_editor.xml b/res/layout/item_photo_editor.xml
index ebf122d..bada4cc 100644
--- a/res/layout/item_photo_editor.xml
+++ b/res/layout/item_photo_editor.xml
@@ -24,7 +24,7 @@
android:id="@+id/kind_icon"
android:src="@drawable/ic_camera_alt_black_24dp"
android:layout_marginTop="8dp"
- android:contentDescription="@string/photo_section"
+ android:contentDescription="@string/header_photo_entry"
style="@style/EditKindIconStyle" />
<!-- Needs 10dp of top padding, in order get a total of 32dp of padding between this view
diff --git a/res/layout/item_photo_editor_readonly.xml b/res/layout/item_photo_editor_readonly.xml
index 0f9f935..1e99809 100644
--- a/res/layout/item_photo_editor_readonly.xml
+++ b/res/layout/item_photo_editor_readonly.xml
@@ -25,7 +25,7 @@
android:id="@+id/kind_icon"
android:src="@drawable/ic_camera_alt_black_24dp"
android:layout_marginTop="8dp"
- android:contentDescription="@string/photo_section"
+ android:contentDescription="@string/header_photo_entry"
style="@style/EditKindIconStyle" />
<!-- Needs 10dp of top padding, in order get a total of 32dp of padding between this view
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d0aebf6..fe77b71 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -438,9 +438,6 @@
<!-- Button used for changing a photo in the Raw Contact Editor [CHAR LIMIT=15] -->
<string name="change_photo">Change</string>
- <!-- Content description for the camera icon beside the photo section in the Raw Contact Editor [CHAR LIMIT=NONE] -->
- <string name="photo_section">Photo section</string>
-
<!-- RadioButton that determines whether a raw contact's photo should be used for the entire contact [CHAR LIMIT=15] -->
<string name="primary_photo">Primary photo</string>
@@ -709,11 +706,13 @@
<!-- Header for the Relation entry [CHAR LIMIT=40] -->
<string name="header_relation_entry">Relation</string>
<!-- Content description for the name fields header entry [CHAR LIMIT=NONE] -->
- <string name="header_name_entry">Name section</string>
+ <string name="header_name_entry">Name</string>
<!-- Content description for the email fields header entry [CHAR LIMIT=NONE] -->
- <string name="header_email_entry">Email section</string>
+ <string name="header_email_entry">Email</string>
<!-- Content description for the phone fields header entry [CHAR LIMIT=NONE] -->
- <string name="header_phone_entry">Phone section</string>
+ <string name="header_phone_entry">Phone</string>
+ <!-- Content description for the camera icon beside the photo section in the Raw Contact Editor [CHAR LIMIT=NONE] -->
+ <string name="header_photo_entry">Photo</string>
<!-- Content description for directions secondary button [CHAR LIMIT=NONE] -->
<string name="content_description_directions">directions to location</string>
diff --git a/src/com/android/contacts/editor/KindSectionView.java b/src/com/android/contacts/editor/KindSectionView.java
index 24d4ee8..3b10fe4 100644
--- a/src/com/android/contacts/editor/KindSectionView.java
+++ b/src/com/android/contacts/editor/KindSectionView.java
@@ -141,6 +141,9 @@
mIcon.setContentDescription(titleString);
mIcon.setImageDrawable(getMimeTypeDrawable(kind.mimeType));
+ if (mIcon.getDrawable() == null) {
+ mIcon.setContentDescription(null);
+ }
rebuildFromState();
updateEmptyEditors(/* shouldAnimate = */ false);
diff --git a/src/com/android/contacts/list/JoinContactListFragment.java b/src/com/android/contacts/list/JoinContactListFragment.java
index f3788a4..3e42fdf 100644
--- a/src/com/android/contacts/list/JoinContactListFragment.java
+++ b/src/com/android/contacts/list/JoinContactListFragment.java
@@ -81,8 +81,11 @@
break;
}
case JoinContactListAdapter.PARTITION_ALL_CONTACTS: {
- Cursor suggestionsCursor = ((JoinContactLoaderResult) data).suggestionCursor;
- onContactListLoaded(suggestionsCursor, data);
+ if (data != null) {
+ final Cursor suggestionsCursor =
+ ((JoinContactLoaderResult) data).suggestionCursor;
+ onContactListLoaded(suggestionsCursor, data);
+ }
break;
}
}
diff --git a/src/com/android/contacts/list/JoinContactLoader.java b/src/com/android/contacts/list/JoinContactLoader.java
index beb5208..075d789 100644
--- a/src/com/android/contacts/list/JoinContactLoader.java
+++ b/src/com/android/contacts/list/JoinContactLoader.java
@@ -52,9 +52,13 @@
@Override
public void close() {
try {
- suggestionCursor.close();
+ if (suggestionCursor != null) {
+ suggestionCursor.close();
+ }
} finally {
- super.close();
+ if (super.getWrappedCursor() != null) {
+ super.close();
+ }
}
}
}
@@ -79,6 +83,23 @@
// to load the entire list
final Cursor suggestionsCursor = getContext().getContentResolver()
.query(mSuggestionUri, mProjection, null, null, null);
- return new JoinContactLoaderResult(super.loadInBackground(), suggestionsCursor);
+ if (suggestionsCursor == null) {
+ return null;
+ }
+ Cursor cursorToClose = suggestionsCursor;
+ try {
+ final Cursor baseCursor = super.loadInBackground();
+ if (baseCursor != null) {
+ final JoinContactLoaderResult result =
+ new JoinContactLoaderResult(baseCursor, suggestionsCursor);
+ cursorToClose = null;
+ return result;
+ }
+ } finally {
+ if (cursorToClose != null) {
+ cursorToClose.close();
+ }
+ }
+ return null;
}
-}
\ No newline at end of file
+}