@Override
  protected void onPlannerAttach(Activity activity) {
    super.onPlannerAttach(activity);
    if (activity != null) {
      if (activity instanceof OnUpdateLoginStatusListener) {
        mCallback = (OnUpdateLoginStatusListener) activity;
      }
      if (getArguments() != null) {
        mStatus = getArguments().getString(STATUS_DASHBOARD);
        if (!PlannerApplication.isEmptyOrNull(mStatus)
            && mStatus.equals(PlannerApplication.PREF_DASHBOARD_COUPLT_PHOTO)) {
          setRefreshDataParam(mStatus);
        }
        PlannerApplication.getInstance().setmMyAccountType(mStatus);
      } else {
        PlannerApplication.getInstance().setmMyAccountType(PlannerApplication.PREF_MYACCOUNT_PAGE);
      }

      if (activity instanceof MainActivity) {
        registerRefreshDataListener(mOnAccountRefreshListener);
        registerRefreshDataListener(mOnLocationListRefreshListener);
        registerRefreshDataListener(mOnUserProfileRefreshListener);
        registerRefreshDataListener(mOnUserAvatarRefreshListener);
        registerRefreshDataListener(mOnWeddingLocationUpdatedRefreshListener);
      }
    }
  }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    PlannerApplication.getInstance().setBackFromTakePhoto(true);
    Uri uriTempFile =
        Uri.parse(
            String.format(
                "%s%s%s",
                "file:///", Environment.getExternalStorageDirectory().getPath(), "/crop.jpg"));

    if (resultCode != 0) {
      switch (requestCode) {
        case TYPE_TAKE_PHOTO:
          File file =
              new File(
                  String.format(
                      "%s%s/%s",
                      Environment.getExternalStorageDirectory().getAbsolutePath(),
                      getString(R.string.account_image_file_name),
                      mImageName));
          if (file != null) {
            getCroppedPhoto(Uri.fromFile(file), uriTempFile);
          }
          break;

        case TYPE_CHOOSE_PHOTO:
          if (data != null) {
            getCroppedPhoto(data.getData(), uriTempFile);
          }
          break;

        case TYPE_PHOTO_RESOULT:
          try {
            mBitmap =
                BitmapFactory.decodeStream(
                    getActivity().getContentResolver().openInputStream(uriTempFile));
          } catch (FileNotFoundException e) {
          }
          ByteArrayOutputStream stream = new ByteArrayOutputStream();
          mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
          mBitmapByte = stream.toByteArray();
          mIvAvatar.setImageBitmap(mBitmap);
          break;
      }
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
 private void tipsSaveRst(boolean success) {
   isSaveRequesting = false;
   final Activity activity = getActivity();
   if (activity != null && activity instanceof MainActivity) {
     if (success) {
       PlannerApplication.getInstance().setCouplePhotoModel(null);
       String tips = getString(R.string.ua_saved);
       Toast.makeText(activity, tips, Toast.LENGTH_SHORT).show();
       new Delete().from(UserProfile.class).execute();
       mNewUser.save();
       mCallback.onUpdateLoginStatus();
       // MainActivity.sChecklistViewAdapter = null;
       Message message = new Message();
       message.obj = UserAccountFragment.this;
       message.what = HANDLE_MSG_ID_BUDGET_UI_UPDATE;
       sEventHandler.sendMessage(message);
     } else {
       String tips = getString(R.string.ua_save_failtips);
       ((MainActivity) activity).showMsgDlg(tips);
     }
   }
 }
  private UserProfile getUpdateJson() {
    String firstname = mFirstnameEditText.getText().toString().trim();
    String lastName = mLastnameEditText.getText().toString();
    String fianceFirstName = mFianceFirstnameEditText.getText().toString().trim();
    String fianceLastName = mFianceLastnameEditText.getText().toString();
    String street = mHomeaddrEditText.getText().toString();
    String homeCityAndState = mCityStateEditText.getText().toString();
    String[] homeCSArray = parseLocation(homeCityAndState);
    String city = homeCSArray[0];
    String state = homeCSArray[1];
    String zip = mZipEditText.getText().toString();

    String id = mUserProfile.getMemberId();
    String phone = mPhoneEditText.getText().toString();

    String budget = mWeddingbudgetEditText.getText().toString();
    budget =
        PlannerApplication.isEmptyOrNull(budget) ? "0" : budget.replace("$", "").replace(",", "");
    String weddingDate = mWeddingDateEditText.getText().toString();
    String wedCityAndState = mWeddingLocationEditText.getText().toString();
    String[] casArray = parseLocation(wedCityAndState);
    String wedCity = casArray[0];
    String wedState = casArray[1];
    mNewUser = new UserProfile();
    mNewUser.setMemberId(mUserProfile.getMemberId());
    mNewUser.setPath(mUserProfile.getPath());
    mNewUser.setEmail(mUserProfile.getEmail());
    mNewUser.setUsername(mUserProfile.getUsername());
    mNewUser.setFirstName(firstname);
    mNewUser.setLastName(lastName);
    if (PlannerApplication.getInstance().getCouplePhotoModel() != null
        && !PlannerApplication.isEmptyOrNull(
            PlannerApplication.getInstance().getCouplePhotoModel().get_id())) {
      mNewUser.setCouplePhotoId(PlannerApplication.getInstance().getCouplePhotoModel().get_id());
      if (!PlannerApplication.isEmptyOrNull(
          PlannerApplication.getUserProfile().getCouplePhotoUrl())) {
        String url =
            PlannerApplication.getUserProfile()
                .getCouplePhotoUrl()
                .substring(
                    0,
                    PlannerApplication.getUserProfile().getCouplePhotoUrl().lastIndexOf("/") + 1);
        mNewUser.setCouplePhotoUrl(
            String.format(
                "%s%s", url, PlannerApplication.getInstance().getCouplePhotoModel().get_id()));
      }
    } else if (!PlannerApplication.isEmptyOrNull(mUserProfile.getCouplePhotoId())) {
      mNewUser.setCouplePhotoId(mUserProfile.getCouplePhotoId());
      mNewUser.setCouplePhotoUrl(mUserProfile.getCouplePhotoUrl());
    }
    mNewUser.setFianceFirstName(fianceFirstName);
    mNewUser.setFianceLastName(fianceLastName);
    mNewUser.setHomeAddr(street);
    mNewUser.setCityState(
        (TextUtils.isEmpty(city) || TextUtils.isEmpty(state))
            ? ""
            : (city + ", " + (state.trim())));
    mNewUser.setZipCode(PlannerApplication.setDefaultValueIfNeed(zip));
    mNewUser.setPhoneNum(phone);
    mNewUser.setWeddingDate(
        (PlannerApplication.isEmptyOrNull(weddingDate)) ? getDefaultWeddingDate() : weddingDate);
    mNewUser.setWeddingBudget(budget);
    mNewUser.setWeddingLocation(
        (TextUtils.isEmpty(wedCity) || TextUtils.isEmpty(wedState))
            ? ""
            : (wedCity + ", " + (wedState.trim())));
    mNewUser.setToken(mUserProfile.getToken());
    mNewUser.setSessionToken(mUserProfile.getSessionToken());

    JSONObject rootJson = null;
    try {
      rootJson = new JSONObject();
      JSONObject memberJson = new JSONObject();
      memberJson.put("firstName", firstname);
      memberJson.put("lastName", lastName);
      memberJson.put("fianceFirstName", fianceFirstName);
      memberJson.put("fianceLastName", fianceLastName);
      JSONObject homeLocationJson = new JSONObject();
      homeLocationJson.put("street", street);
      homeLocationJson.put("street2", "");
      homeLocationJson.put("state", state == null ? "" : state.trim());
      homeLocationJson.put("city", city);
      homeLocationJson.put("zip", zip);
      memberJson.put("homeLocation", homeLocationJson);

      memberJson.put("id", id);
      memberJson.put("phone", phone);
      memberJson.put("weddingBudget", budget.replaceAll(",", ""));

      if (!TextUtils.isEmpty(weddingDate)) {
        try {
          weddingDate =
              DateUtils.getDateText(
                  DateUtils.DATE_FORMAT_WEDDING_DATE_API_POST,
                  DateUtils.getDate(DateUtils.DATE_FORMAT_WEDDING_DATE, weddingDate));
        } catch (ParseException pe) {
          getLogger().error(pe.getMessage());
        } catch (IllegalArgumentException e) {
          getLogger().error(e.getMessage());
        }
      } else {
        weddingDate =
            DateFormat.format(UPDATE_DATE_FORMAT, getDefaultWeddingDateToDate()).toString();
      }
      memberJson.put("weddingDate", weddingDate);
      JSONObject wedLocationJson = new JSONObject();
      wedLocationJson.put("city", wedCity);
      wedLocationJson.put("state", wedState == null ? "" : wedState.trim());
      memberJson.put("weddingLocation", wedLocationJson);
      rootJson.put("member", memberJson);
    } catch (JSONException e) {
      getLogger().error(e.getMessage());
    }
    mNewUser.setJsonToString(rootJson.toString());
    return mNewUser;
  }