Fix crash editing newly saved directory contact

After saving a directory contact via QC, mLookupUri still refers to a directory
contact. ContactLoader knows to map the directory URI to a local URI.
When editing/starring a contact we should therefore use the URI returned
from ContactLoader instead of the URI passed into QuickContactActivity.

I also fixed some IntelliJ style nits.

Bug: 16670552
Change-Id: I8cb04b645c050e2aa563abaa64125d1ef17e402e
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 1607c7d..b61985f 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -186,6 +186,10 @@
             "vnd.android.cursor.item/vnd.googleplus.profile.comm";
     private static final String INTENT_DATA_HANGOUTS_VIDEO = "Start video call";
 
+    /**
+     * The URI used to load the the Contact. Once the contact is loaded, use Contact#getLookupUri()
+     * instead of referencing this URI.
+     */
     private Uri mLookupUri;
     private String[] mExcludeMimes;
     private int mExtraMode;
@@ -193,7 +197,6 @@
     private boolean mHasAlreadyBeenOpened;
 
     private ImageView mPhotoView;
-    private View mTransparentView;
     private ExpandingEntryCardView mContactCard;
     private ExpandingEntryCardView mNoContactDetailsCard;
     private ExpandingEntryCardView mRecentCard;
@@ -571,9 +574,9 @@
         mAboutCard.setOnCreateContextMenuListener(mEntryContextMenuListener);
 
         mPhotoView = (ImageView) findViewById(R.id.photo);
-        mTransparentView = findViewById(R.id.transparent_view);
+        final View transparentView = findViewById(R.id.transparent_view);
         if (mScroller != null) {
-            mTransparentView.setOnClickListener(new OnClickListener() {
+            transparentView.setOnClickListener(new OnClickListener() {
                 @Override
                 public void onClick(View v) {
                     mScroller.scrollOffBottom();
@@ -1700,7 +1703,7 @@
     }
 
     private Intent getEditContactIntent() {
-        final Intent intent = new Intent(Intent.ACTION_EDIT, mLookupUri);
+        final Intent intent = new Intent(Intent.ACTION_EDIT, mContactData.getLookupUri());
         mContactLoader.cacheResult();
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
         return intent;
@@ -1712,7 +1715,7 @@
 
     private void toggleStar(MenuItem starredMenuItem) {
         // Make sure there is a contact
-        if (mLookupUri != null) {
+        if (mContactData != null) {
             // Read the current starred value from the UI instead of using the last
             // loaded state. This allows rapid tapping without writing the same
             // value several times
@@ -1725,7 +1728,7 @@
 
             // Now perform the real save
             final Intent intent = ContactSaveService.createSetStarredIntent(
-                    QuickContactActivity.this, mLookupUri, !isStarred);
+                    QuickContactActivity.this, mContactData.getLookupUri(), !isStarred);
             startService(intent);
 
             final CharSequence accessibilityText = !isStarred
@@ -1803,7 +1806,7 @@
                     }
 
                 });
-        builder.createContactShortcutIntent(mLookupUri);
+        builder.createContactShortcutIntent(mContactData.getLookupUri());
     }
 
     @Override