Program: 8217
Project: 8217
Buggy source:
@Override public void onLoadFinished(Loader<Cursor> loader,Cursor data){
switch (loader.getId()) {
case LOADER_ID_UNIFIED:
{
      if (data.getCount() == 0) {
        return;
      }
      if (data.moveToFirst()) {
        String name=data.getString(INDEX_NAME);
        mCollapsingToolbarLayout.setTitle(name != null ? name : getString(R.string.user_id_no_name));
        mMasterKeyId=data.getLong(INDEX_MASTER_KEY_ID);
        mFingerprint=data.getBlob(INDEX_FINGERPRINT);
        mFingerprintString=KeyFormattingUtils.convertFingerprintToHex(mFingerprint);
        mIsSecret=data.getInt(INDEX_HAS_ANY_SECRET) != 0;
        mHasEncrypt=data.getInt(INDEX_HAS_ENCRYPT) != 0;
        mIsRevoked=data.getInt(INDEX_IS_REVOKED) > 0;
        mIsExpired=data.getInt(INDEX_IS_EXPIRED) != 0;
        mIsSecure=data.getInt(INDEX_IS_SECURE) == 1;
        mIsVerified=data.getInt(INDEX_VERIFIED) > 0;
        showMainFragment();
        if (mShowSecurityTokenAfterCreation && getIntent().hasExtra(EXTRA_SECURITY_TOKEN_AID)) {
          mShowSecurityTokenAfterCreation=false;
          Intent intent=getIntent();
          byte[] tokenFingerprints=intent.getByteArrayExtra(EXTRA_SECURITY_TOKEN_FINGERPRINTS);
          String tokenUserId=intent.getStringExtra(EXTRA_SECURITY_TOKEN_USER_ID);
          byte[] tokenAid=intent.getByteArrayExtra(EXTRA_SECURITY_TOKEN_AID);
          double tokenVersion=intent.getDoubleExtra(EXTRA_SECURITY_TOKEN_VERSION,2.0);
          showSecurityTokenFragment(tokenFingerprints,tokenUserId,tokenAid,tokenVersion);
        }
        if (!mRotate.hasStarted() && !mRotateSpin.hasStarted()) {
          supportInvalidateOptionsMenu();
        }
        AsyncTask<Long,Void,Bitmap> photoTask=new AsyncTask<Long,Void,Bitmap>(){
          protected Bitmap doInBackground(          Long... mMasterKeyId){
            return new ContactHelper(ViewKeyActivity.this).loadPhotoByMasterKeyId(mMasterKeyId[0],true);
          }
          protected void onPostExecute(          Bitmap photo){
            if (photo == null) {
              return;
            }
            mPhoto.setImageBitmap(photo);
            mPhoto.setColorFilter(getResources().getColor(R.color.toolbar_photo_tint),PorterDuff.Mode.SRC_ATOP);
            mPhotoLayout.setVisibility(View.VISIBLE);
          }
        }
;
        boolean showStatusText=mIsSecure && !mIsExpired && !mIsRevoked;
        if (showStatusText) {
          mStatusText.setVisibility(View.VISIBLE);
          if (mIsSecret) {
            mStatusText.setText(R.string.view_key_my_key);
          }
 else           if (mIsVerified) {
            mStatusText.setText(R.string.view_key_verified);
          }
 else {
            mStatusText.setText(R.string.view_key_unverified);
          }
        }
 else {
          mStatusText.setVisibility(View.GONE);
        }
        int color;
        if (mIsRevoked) {
          mStatusImage.setVisibility(View.VISIBLE);
          KeyFormattingUtils.setStatusImage(this,mStatusImage,mStatusText,State.REVOKED,R.color.icons,true);
          color=getResources().getColor(R.color.key_flag_red);
          mActionEncryptFile.setVisibility(View.INVISIBLE);
          mActionEncryptText.setVisibility(View.INVISIBLE);
          hideFab();
          mQrCodeLayout.setVisibility(View.GONE);
        }
 else         if (!mIsSecure) {
          mStatusImage.setVisibility(View.VISIBLE);
          KeyFormattingUtils.setStatusImage(this,mStatusImage,mStatusText,State.INSECURE,R.color.icons,true);
          color=getResources().getColor(R.color.key_flag_red);
          mActionEncryptFile.setVisibility(View.INVISIBLE);
          mActionEncryptText.setVisibility(View.INVISIBLE);
          hideFab();
          mQrCodeLayout.setVisibility(View.GONE);
        }
 else         if (mIsExpired) {
          mStatusImage.setVisibility(View.VISIBLE);
          KeyFormattingUtils.setStatusImage(this,mStatusImage,mStatusText,State.EXPIRED,R.color.icons,true);
          color=getResources().getColor(R.color.key_flag_red);
          mActionEncryptFile.setVisibility(View.INVISIBLE);
          mActionEncryptText.setVisibility(View.INVISIBLE);
          hideFab();
          mQrCodeLayout.setVisibility(View.GONE);
        }
 else         if (mIsSecret) {
          mStatusImage.setVisibility(View.GONE);
          color=getResources().getColor(R.color.key_flag_green);
          if (!mFingerprintString.equals(mQrCodeLoaded)) {
            loadQrCode(mFingerprintString);
          }
          photoTask.execute(mMasterKeyId);
          mQrCodeLayout.setVisibility(View.VISIBLE);
          RelativeLayout.LayoutParams statusParams=(RelativeLayout.LayoutParams)mStatusText.getLayoutParams();
          statusParams.setMargins(FormattingUtils.dpToPx(this,48),0,0,0);
          if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            statusParams.setMarginEnd(0);
          }
          statusParams.addRule(RelativeLayout.LEFT_OF,R.id.view_key_qr_code_layout);
          mStatusText.setLayoutParams(statusParams);
          mActionEncryptFile.setVisibility(View.VISIBLE);
          mActionEncryptText.setVisibility(View.VISIBLE);
          showFab();
          mFab.setImageDrawable(getResources().getDrawable(R.drawable.ic_repeat_white_24dp));
        }
 else {
          mActionEncryptFile.setVisibility(View.VISIBLE);
          mActionEncryptText.setVisibility(View.VISIBLE);
          mQrCodeLayout.setVisibility(View.GONE);
          if (mIsVerified) {
            mStatusText.setText(R.string.view_key_verified);
            mStatusImage.setVisibility(View.VISIBLE);
            KeyFormattingUtils.setStatusImage(this,mStatusImage,mStatusText,State.VERIFIED,R.color.icons,true);
            color=getResources().getColor(R.color.key_flag_green);
            photoTask.execute(mMasterKeyId);
            hideFab();
          }
 else {
            mStatusText.setText(R.string.view_key_unverified);
            mStatusImage.setVisibility(View.VISIBLE);
            KeyFormattingUtils.setStatusImage(this,mStatusImage,mStatusText,State.UNVERIFIED,R.color.icons,true);
            color=getResources().getColor(R.color.key_flag_orange);
            showFab();
          }
        }
        if (mPreviousColor == 0 || mPreviousColor == color) {
          mAppBarLayout.setBackgroundColor(color);
          mCollapsingToolbarLayout.setContentScrimColor(color);
          mCollapsingToolbarLayout.setStatusBarScrimColor(getStatusBarBackgroundColor(color));
          mPreviousColor=color;
        }
 else {
          ObjectAnimator colorFade=ObjectAnimator.ofObject(mAppBarLayout,"String_Node_Str",new ArgbEvaluator(),mPreviousColor,color);
          mCollapsingToolbarLayout.setContentScrimColor(color);
          mCollapsingToolbarLayout.setStatusBarScrimColor(getStatusBarBackgroundColor(color));
          colorFade.setDuration(1200);
          colorFade.start();
          mPreviousColor=color;
        }
        mStatusImage.setAlpha(80);
        break;
      }
    }
}
}

Fixed version (ground truth):
@Override public void onLoadFinished(Loader<Cursor> loader,Cursor data){
switch (loader.getId()) {
case LOADER_ID_UNIFIED:
{
      if (data.getCount() == 0) {
        return;
      }
      if (data.moveToFirst()) {
        String name=data.getString(INDEX_NAME);
        mCollapsingToolbarLayout.setTitle(name != null ? name : getString(R.string.user_id_no_name));
        mMasterKeyId=data.getLong(INDEX_MASTER_KEY_ID);
        mFingerprint=data.getBlob(INDEX_FINGERPRINT);
        mIsSecret=data.getInt(INDEX_HAS_ANY_SECRET) != 0;
        mHasEncrypt=data.getInt(INDEX_HAS_ENCRYPT) != 0;
        mIsRevoked=data.getInt(INDEX_IS_REVOKED) > 0;
        mIsExpired=data.getInt(INDEX_IS_EXPIRED) != 0;
        mIsSecure=data.getInt(INDEX_IS_SECURE) == 1;
        mIsVerified=data.getInt(INDEX_VERIFIED) > 0;
        showMainFragment();
        if (mShowSecurityTokenAfterCreation && getIntent().hasExtra(EXTRA_SECURITY_TOKEN_AID)) {
          mShowSecurityTokenAfterCreation=false;
          Intent intent=getIntent();
          byte[] tokenFingerprints=intent.getByteArrayExtra(EXTRA_SECURITY_TOKEN_FINGERPRINTS);
          String tokenUserId=intent.getStringExtra(EXTRA_SECURITY_TOKEN_USER_ID);
          byte[] tokenAid=intent.getByteArrayExtra(EXTRA_SECURITY_TOKEN_AID);
          double tokenVersion=intent.getDoubleExtra(EXTRA_SECURITY_TOKEN_VERSION,2.0);
          showSecurityTokenFragment(tokenFingerprints,tokenUserId,tokenAid,tokenVersion);
        }
        if (!mRotate.hasStarted() && !mRotateSpin.hasStarted()) {
          supportInvalidateOptionsMenu();
        }
        AsyncTask<Long,Void,Bitmap> photoTask=new AsyncTask<Long,Void,Bitmap>(){
          protected Bitmap doInBackground(          Long... mMasterKeyId){
            return new ContactHelper(ViewKeyActivity.this).loadPhotoByMasterKeyId(mMasterKeyId[0],true);
          }
          protected void onPostExecute(          Bitmap photo){
            if (photo == null) {
              return;
            }
            mPhoto.setImageBitmap(photo);
            mPhoto.setColorFilter(getResources().getColor(R.color.toolbar_photo_tint),PorterDuff.Mode.SRC_ATOP);
            mPhotoLayout.setVisibility(View.VISIBLE);
          }
        }
;
        boolean showStatusText=mIsSecure && !mIsExpired && !mIsRevoked;
        if (showStatusText) {
          mStatusText.setVisibility(View.VISIBLE);
          if (mIsSecret) {
            mStatusText.setText(R.string.view_key_my_key);
          }
 else           if (mIsVerified) {
            mStatusText.setText(R.string.view_key_verified);
          }
 else {
            mStatusText.setText(R.string.view_key_unverified);
          }
        }
 else {
          mStatusText.setVisibility(View.GONE);
        }
        int color;
        if (mIsRevoked) {
          mStatusImage.setVisibility(View.VISIBLE);
          KeyFormattingUtils.setStatusImage(this,mStatusImage,mStatusText,State.REVOKED,R.color.icons,true);
          color=getResources().getColor(R.color.key_flag_red);
          mActionEncryptFile.setVisibility(View.INVISIBLE);
          mActionEncryptText.setVisibility(View.INVISIBLE);
          hideFab();
          mQrCodeLayout.setVisibility(View.GONE);
        }
 else         if (!mIsSecure) {
          mStatusImage.setVisibility(View.VISIBLE);
          KeyFormattingUtils.setStatusImage(this,mStatusImage,mStatusText,State.INSECURE,R.color.icons,true);
          color=getResources().getColor(R.color.key_flag_red);
          mActionEncryptFile.setVisibility(View.INVISIBLE);
          mActionEncryptText.setVisibility(View.INVISIBLE);
          hideFab();
          mQrCodeLayout.setVisibility(View.GONE);
        }
 else         if (mIsExpired) {
          mStatusImage.setVisibility(View.VISIBLE);
          KeyFormattingUtils.setStatusImage(this,mStatusImage,mStatusText,State.EXPIRED,R.color.icons,true);
          color=getResources().getColor(R.color.key_flag_red);
          mActionEncryptFile.setVisibility(View.INVISIBLE);
          mActionEncryptText.setVisibility(View.INVISIBLE);
          hideFab();
          mQrCodeLayout.setVisibility(View.GONE);
        }
 else         if (mIsSecret) {
          mStatusImage.setVisibility(View.GONE);
          color=getResources().getColor(R.color.key_flag_green);
          if (!Arrays.equals(mFingerprint,mQrCodeLoaded)) {
            loadQrCode(mFingerprint);
          }
          photoTask.execute(mMasterKeyId);
          mQrCodeLayout.setVisibility(View.VISIBLE);
          RelativeLayout.LayoutParams statusParams=(RelativeLayout.LayoutParams)mStatusText.getLayoutParams();
          statusParams.setMargins(FormattingUtils.dpToPx(this,48),0,0,0);
          if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            statusParams.setMarginEnd(0);
          }
          statusParams.addRule(RelativeLayout.LEFT_OF,R.id.view_key_qr_code_layout);
          mStatusText.setLayoutParams(statusParams);
          mActionEncryptFile.setVisibility(View.VISIBLE);
          mActionEncryptText.setVisibility(View.VISIBLE);
          showFab();
          mFab.setImageDrawable(getResources().getDrawable(R.drawable.ic_repeat_white_24dp));
        }
 else {
          mActionEncryptFile.setVisibility(View.VISIBLE);
          mActionEncryptText.setVisibility(View.VISIBLE);
          mQrCodeLayout.setVisibility(View.GONE);
          if (mIsVerified) {
            mStatusText.setText(R.string.view_key_verified);
            mStatusImage.setVisibility(View.VISIBLE);
            KeyFormattingUtils.setStatusImage(this,mStatusImage,mStatusText,State.VERIFIED,R.color.icons,true);
            color=getResources().getColor(R.color.key_flag_green);
            photoTask.execute(mMasterKeyId);
            hideFab();
          }
 else {
            mStatusText.setText(R.string.view_key_unverified);
            mStatusImage.setVisibility(View.VISIBLE);
            KeyFormattingUtils.setStatusImage(this,mStatusImage,mStatusText,State.UNVERIFIED,R.color.icons,true);
            color=getResources().getColor(R.color.key_flag_orange);
            showFab();
          }
        }
        if (mPreviousColor == 0 || mPreviousColor == color) {
          mAppBarLayout.setBackgroundColor(color);
          mCollapsingToolbarLayout.setContentScrimColor(color);
          mCollapsingToolbarLayout.setStatusBarScrimColor(getStatusBarBackgroundColor(color));
          mPreviousColor=color;
        }
 else {
          ObjectAnimator colorFade=ObjectAnimator.ofObject(mAppBarLayout,"String_Node_Str",new ArgbEvaluator(),mPreviousColor,color);
          mCollapsingToolbarLayout.setContentScrimColor(color);
          mCollapsingToolbarLayout.setStatusBarScrimColor(getStatusBarBackgroundColor(color));
          colorFade.setDuration(1200);
          colorFade.start();
          mPreviousColor=color;
        }
        mStatusImage.setAlpha(80);
        break;
      }
    }
}
}