@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); } } }
private void updateInfo(TextView tv, String preUserProfileText, String currentUserProfileText) { preUserProfileText = PlannerApplication.setDefaultValueIfNeed(preUserProfileText); currentUserProfileText = PlannerApplication.setDefaultValueIfNeed(currentUserProfileText); String resultText = tv.getText().toString(); if (mIsUserProfileUpdate) { if (!currentUserProfileText.equals(preUserProfileText)) { resultText = currentUserProfileText; } } else { resultText = preUserProfileText; } tv.setText(PlannerApplication.setDefaultValueIfNeed(resultText)); }
@Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { Calendar calendar = Calendar.getInstance(); String weddingDate = PlannerApplication.getUserProfile().getWeddingDate(); if (!PlannerApplication.isEmptyOrNull(weddingDate)) { try { calendar.setTime( DateUtils.getDate(DateUtils.DATE_FORMAT_WEDDING_DATE, weddingDate)); } catch (ParseException e) { getLogger().debug(e.getMessage()); } } mYear = calendar.get(Calendar.YEAR); mMonth = calendar.get(Calendar.MONTH); mDay = calendar.get(Calendar.DAY_OF_MONTH); PlannerEvent.Screen(PlannerEvent.EVENT_SCREEN_DATE_SELECTION_MENU); WeddingDatePickerDialog mWeddingDateDatePicker = new WeddingDatePickerDialog( getActivity(), mWeddingDateSetListener, mYear, mMonth, mDay); mWeddingDateDatePicker.setButton( DialogInterface.BUTTON_POSITIVE, getString(R.string.date_picker_done), mWeddingDateDatePicker); mWeddingDateDatePicker.setOnDismissListener( new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { mIsFired = false; Message message = new Message(); message.obj = UserAccountFragment.this; message.what = HANDLE_MSG_ID_WEDDING_DATE_CLEAR; sEventHandler.sendMessageDelayed(message, 300); } }); mWeddingDateDatePicker.setOnCancelListener( new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { Message message = new Message(); message.obj = UserAccountFragment.this; message.what = HANDLE_MSG_ID_WEDDING_DATE_CLEAR; sEventHandler.sendMessageDelayed(message, 300); } }); mWeddingDateDatePicker.show(); } }
@Override public void onRefresh(SyncedObject.LocationListSyncedObject locationListSyncedObject) { String location = locationListSyncedObject.getLocationName(); String market = locationListSyncedObject.getLocationMarket(); Resources res = getActivity().getResources(); String titlewed = res.getString(R.string.ua_wedloctitle); String titlehome = res.getString(R.string.ua_homeloctitle); mIsNotifyTextChanged = false; if (!PlannerApplication.isEmptyOrNull(location)) { if (titlewed.equals(mLocationFrom)) { mWeddingLocationEditText.setText(location); mDefaultWeddingLocation = mWeddingLocationEditText.getText().toString(); mWeddingLocationMarketCode = market; } else if (titlehome.equals(mLocationFrom)) { mCityStateEditText.setText(location); mDefaultCityState = mCityStateEditText.getText().toString(); mHomeMarketCode = market; } } else { if (titlewed.equals(mLocationFrom) && mDefaultWeddingLocation != null) { mWeddingLocationEditText.setText(mDefaultWeddingLocation); } else if (titlehome.equals(mLocationFrom) && mDefaultCityState != null) { mCityStateEditText.setText(mDefaultCityState); } } }
@Override public void onRefresh(SyncedObject.UserProfileSyncedobject userProfileSyncedobject) { UserProfile currentUserProfile = PlannerApplication.getUserProfile(); mIsUserProfileUpdate = true; setupAccountUserInfo(mUserProfile, currentUserProfile); mUserProfile = currentUserProfile; }
private void updateWeddingbudgetEditText(String wedbudget) { if (!PlannerApplication.isEmptyOrNull(wedbudget)) { wedbudget = NumberFormat.getCurrencyInstance(Locale.US).format(Double.valueOf(wedbudget)); wedbudget = Utils.getDoubleFormatValue(wedbudget); mWeddingbudgetEditText.setText(wedbudget); } }
@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(); }
@Override public void onRefresh(SyncedObject.AccountSyncedObject accountSyncedObject) { mUserProfile = PlannerApplication.getUserProfile(); if (mUserProfile != null) { updateMenuVisibility(); mRootView.setVisibility(View.VISIBLE); setupRootView(); } }
private void updateMenuVisibility() { if (mMenuItem != null) { if (PlannerApplication.getUserProfile() != null) { mMenuItem.setVisible(true); } else { mMenuItem.setVisible(false); } } }
public VendorPortfolioAdapter( Context context, List<VendorProfileMedia> mediaList, OnPortfolioVideoPlayListener onPortfolioVideoPlayListener) { mContext = context; mMediaList = mediaList; mOnPortfolioVideoPlayListener = onPortfolioVideoPlayListener; mDisplayImageOptions = PlannerApplication.getDefaultDisplayImageOptions(R.drawable.vendor_summary_item_bg_default); }
@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); }
public static FavoritesNewProvider getNewFavoritesProvider( final String userId, OnProviderDataCallBackListener onGetFavoritesLister, OnRESTLoaderListener onRESTLoaderListener) { return new FavoritesNewProvider( new FavoritesGetApiCallback(PlannerApplication.getUserProfile(), onGetFavoritesLister), onRESTLoaderListener) { @Override protected String getURL() { return String.format( URL_TEMPLATE_GET_FAVORITES, getWebServiceHost(), userId, getWebServiceApiKey()); } @Override protected RESTfulApiClient getRESTfulApiClient() { return RESTfulApiClient.getRESTfulGetClient(PlannerConfiguration.getInstance()); } }; }
public static FavoritesNewProvider deleteNewFavoritesProvider( String UserFavoriteId, OnProviderDataCallBackListener onDeleteFavoritesLister, OnRESTLoaderListener onRESTLoaderListener) { return new FavoritesNewProvider( new FavoritesDeleteApiCallback( PlannerApplication.getUserProfile(), onDeleteFavoritesLister, UserFavoriteId), onRESTLoaderListener) { @Override protected String getURL() { return String.format( URL_TEMPLATE_DELETE_FAVORITES, getWebServiceHost(), getWebServiceApiKey()); } @Override protected RESTfulApiClient getRESTfulApiClient() { return RESTfulApiClient.getRESTfulDeleteClient(PlannerConfiguration.getInstance()); } }; }
public static FavoritesNewProvider saveNewFavoritesProvider( String favoritesJson, OnProviderDataCallBackListener onSaveFavoritesLister, OnRESTLoaderListener onRESTLoaderListener) { return new FavoritesNewProvider( new FavoritesSaveApiCallback( PlannerApplication.getUserProfile(), onSaveFavoritesLister, favoritesJson), onRESTLoaderListener) { @Override protected String getURL() { return String.format( URL_TEMPLATE_SAVE_FAVORITES, getWebServiceHost(), getWebServiceApiKey()); } @Override protected RESTfulApiClient getRESTfulApiClient() { return RESTfulApiClient.getRESTfulPostClient(PlannerConfiguration.getInstance()); } }; }
public void handleMessage(Message msg) { Object object = msg.obj; if (object != null && object instanceof UserAccountFragment) { UserAccountFragment fragment = (UserAccountFragment) object; if (fragment.getActivity() != null) { switch (msg.what) { case HANDLE_MSG_ID_BUDGET_UPDATE: fragment.mUserProfile.setWeddingBudget( fragment .mWeddingbudgetEditText .getText() .toString() .replace("$", "") .replace(",", "")); fragment.doBudgetUpdateAction(); break; case HANDLE_MSG_ID_BUDGET_UI_UPDATE: fragment.mWeddingbudgetEditText.setText(fragment.mNewUser.getWeddingBudget()); fragment.setRefreshDataParam(fragment.mNewUser); if (!PlannerApplication.isEmptyOrNull(fragment.mStatus) && (fragment.mStatus.equals(PlannerApplication.PREF_DASHBOARD_FLAG) || fragment.mStatus.equals( PlannerApplication.PREF_DASHBOARD_COUPLT_PHOTO))) { syncedRefreshDataListener(new SyncedObject.DashboardSyncedObject()); fragment.getActivity().onBackPressed(); } break; case HANDLE_MSG_ID_WEDDING_DATE_CLEAR: fragment.mWeddingDateEditText.clearFocus(); break; default: break; } } } };
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); } } }
@Override protected View onPlannerCreateView( LayoutInflater layoutInflater, ViewGroup container, Bundle savedInstanceState) { mUserProfile = PlannerApplication.getUserProfile(); mRootView = (ViewGroup) layoutInflater.inflate(R.layout.fragment_useraccout, container, false); mSpinner = (RelativeLayout) mRootView.findViewById(R.id.rl_spinner); mSpinner.setOnTouchListener( new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); initView(); if (mUserProfile == null) { mRootView.setVisibility(View.GONE); } else { setupRootView(); } getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); return mRootView; }
// #106192968 public void testBudgeterItemDetailPage() { assertJoin(); assertLogInOrJoinScreen( false, String.format("*****@*****.**", Calendar.getInstance().getTimeInMillis()), "123456"); getSolo().goBack(); getSolo().sleep(WAIT_SHORT_TIME); getSolo().clickOnView(getSolo().getView(android.R.id.home)); getSolo().sleep(WAIT_LONG_TIME); // getSolo().clickOnView(getSolo().getView(R.id.menu_item_title_budgeter)); getSolo().sleep(WAIT_LONG_TIME); assertTitleEquals(getSolo().getString(R.string.fragment_title_budgeter)); getSolo().waitForDialogToOpen(); getSolo().goBack(); getSolo().sleep(WAIT_SHORT_TIME); ListView budgeterList = (ListView) getSolo().getView(R.id.budgeter_Listview); assertTrue( getSolo().waitForCondition(new ListViewNotEmptyCondition(budgeterList), WAIT_ONE_MINITUS)); getSolo().sleep(WAIT_SHORT_TIME); int budgeterCount = budgeterList.getAdapter().getCount(); int j = 1; BudgeterItemPresenter.BudgeterDefaultItemPresenter budgeterDefaultItemPresenter = null; for (int i = 0; i < budgeterCount; i++) { getSolo().scrollListToLine(budgeterList, i); getSolo().sleep(WAIT_LONG_TIME); if (budgeterList.getAdapter().getItem(i) instanceof BudgeterItemPresenter.BudgeterDefaultItemPresenter) { budgeterDefaultItemPresenter = (BudgeterItemPresenter.BudgeterDefaultItemPresenter) budgeterList.getAdapter().getItem(i); getSolo().sleep(WAIT_SHORT_TIME); getSolo().scrollListToLine(budgeterList, i - 1); getSolo().sleep(WAIT_LONG_TIME); getSolo().clickInList(2); getSolo().sleep(WAIT_LONG_TIME); break; } } assertTitleEquals(getSolo().getString(R.string.budgeter_detail_edit_item_title)); TextView itemName = (TextView) getSolo().getView(R.id.tv_item_title); assertTrue( budgeterDefaultItemPresenter .getBudgeterItem() .getName() .equals(itemName.getText().toString())); getSolo().searchText(getSolo().getString(R.string.budgeter_detail_item_budget_amount)); getSolo().searchText(getSolo().getString(R.string.budgeter_detail_item_actual)); getSolo().searchText(getSolo().getString(R.string.budgeter_detail_item_paid)); TextView etBudgetAmount = (TextView) getSolo().getView(R.id.tv_item_budgeted_amount); String budgetAmount = etBudgetAmount.getText().toString(); budgetAmount = PlannerApplication.isEmptyOrNull(budgetAmount) ? "0" : budgetAmount.replace("$", "").replace(",", ""); assertTrue( budgetAmount.equals( String.valueOf( (int) budgeterDefaultItemPresenter.getBudgeterItem().getRecommendedAmount()))); EditText etActualAmount = (EditText) getSolo().getView(R.id.et_item_actual_spend); String actualAmount = etActualAmount.getText().toString(); actualAmount = PlannerApplication.isEmptyOrNull(actualAmount) ? "0" : actualAmount.replace("$", "").replace(",", ""); assertTrue( actualAmount.equals( String.valueOf( (int) budgeterDefaultItemPresenter.getBudgeterItem().getActualAmount()))); getSolo().sleep(WAIT_LONG_TIME); }
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; }
@Override public void onUpdateWeddingLocation() { mWeddingLocationEditText.setText(PlannerApplication.getUserProfile().getWeddingLocation()); }
@Override public void onRefresh( SyncedObject.WeddingLocationUpdatedSyncedObject weddingLocationUpdatedSyncedObject) { mWeddingLocationEditText.setText( PlannerApplication.getUserProfile().getWeddingLocation()); }