private void doUploadAvatar() { if (mBitmapByte != null && mBitmapByte.length > 0) { final Activity activity = getActivity(); if (activity != null) { if (mSpinner != null) { mSpinner.setVisibility(View.VISIBLE); } initLoader( CouplePhotoProvider.uploadCouplePhotoProvider( mBitmapByte, UserAccountFragment.this, new OnProviderDataCallBackListener<CouplePhotoModel>() { @Override protected Activity getActivity() { return UserAccountFragment.this.getActivity(); } @Override protected void onErrorUIUpdate(String string) { if (mSpinner != null) { mSpinner.setVisibility(View.GONE); } tipsSaveRst(false); } @Override protected void onSuccessDataFetch(CouplePhotoModel couplePhotoModel) { PlannerApplication.getInstance().setCouplePhotoModel(couplePhotoModel); } @Override protected Runnable getOnSuccessUIUpdateRunnable() { return new Runnable() { @Override public void run() { doSaveAction(); mBitmapByte = null; } }; } })); } } else { doSaveAction(); } }
@Override public void onDeleteAvatarPhoto() { ImageLoader.getInstance() .displayImage( String.format("drawable://%s", R.drawable.dashboard_backgroud_picture), mIvAvatar, PlannerApplication.getDefaultDisplayImageOptions( R.drawable.dashboard_backgroud_picture), null); final Activity activity = getActivity(); if (activity != null && activity instanceof MainActivity) { initLoader( CouplePhotoProvider.removeCouplePhotoProvider( PlannerApplication.getUserProfile().getCouplePhotoId(), UserAccountFragment.this, null)); UserProfile userProfile = PlannerApplication.getUserProfile(); userProfile.setCouplePhotoId(UserProfile.COUPLE_ID); new UserProfileProvider() .updateAccount( userProfile, mWeddingLocationMarketCode, mHomeMarketCode, new OnProviderDataCallBackListener<UserProfile>() { @Override protected Activity getActivity() { return UserAccountFragment.this.getActivity(); } }, UserAccountFragment.this, activity); UserProfile.updateUserCouplePhoto(PlannerApplication.getUserProfile().getCouplePhotoUrl()); SyncedObject.DashboardPhotoChangedSyncedObject dashboardPhotoChangedSyncedObject = new SyncedObject.DashboardPhotoChangedSyncedObject(); dashboardPhotoChangedSyncedObject.setUrl(null); syncedRefreshDataListener(dashboardPhotoChangedSyncedObject); if (!PlannerApplication.isEmptyOrNull(mStatus) && mStatus.equals(PlannerApplication.PREF_DASHBOARD_FLAG)) { activity.onBackPressed(); } } PlannerEvent.getAvatarAction(DELETE_PHOTO_ACTION).track(); }