Esempio n. 1
0
		private void setActionToView(){
			Background bgEmailProfile = new Background (this, Resource.Drawable.ic_emailprofile, Resource.Drawable.ic_emailprofile_pressed);
			imgEmailProfile.SetBackgroundDrawable (bgEmailProfile);
			imgEmailProfile.Click += (sender, e) => {
				if (constants.specialistInfo != null && constants.specialistInfo.SpecialistDetail != null) {
					SendEmailUI dialog = new SendEmailUI(this);
					dialog.actionDelegate = this;
					dialog.showEmailDialog(MApplication.getInstance ().specialistID);
				}
			};

			imgFavorite.Click += (sender, e) => {
				if (constants.specialistInfo != null && constants.specialistInfo.SpecialistDetail != null) {
					if (constants.specialistInfo.IsFavourite) {
						if(dialogFavorite == null){
							dialogFavorite = new FavoriteUI(this);
							dialogFavorite.actionFavoriteDelegate = this;
						}
						dialogFavorite.removeFavoriteRequest(MApplication.getInstance ().specialistID);
					} else {
						if(dialogFavorite == null){
							dialogFavorite = new FavoriteUI(this);
							dialogFavorite.actionFavoriteDelegate = this;
						}
						dialogFavorite.addToFavouriteRequest(MApplication.getInstance ().specialistID);
					}
				}
			};

			Background bgRating = new Background (this, Resource.Drawable.icon_feedback, Resource.Drawable.icon_feedback_pressed);
			imgRating.SetBackgroundDrawable (bgRating);
			imgRating.Click += (sender, e) => {
				if(constants.bookingInfo.IsFeedback){
					if(dialogFeedbackReview == null){
						dialogFeedbackReview = new RatingFeedbackReview(this);
					}
					dialogFeedbackReview.showFeedbackReview(constants.bookingInfo.Rating, constants.bookingInfo.Feedback);
				} else {
					if(dialogFeedback == null){
						dialogFeedback = new RatingFeedbackUI(this, constants.bookingInfo.PastBooking.CallId);
						dialogFeedback.actionRatingDelegate = this;
					}
					dialogFeedback.showRatingFeedback();
				}
			};

			llTalknow.Click += (sender, e) => {
				if (constants.specialistInfo != null && constants.specialistInfo.SpecialistDetail != null) {
					if(constants.specialistInfo.Account.CurrentAvailabilityStatus == (int)Constants.STATUS_CONSULTANT.NotAvailable){
						popupNotice.showNoticeDialog(GetString(Resource.String.title_notice), constants.specialistInfo.Account.Name +" is not available. You can't use this feature");
					} else{
						TalkNowUI dialog = new TalkNowUI(this);
						dialog.actionTalknowDelegate = this;
						dialog.ShowTalkNowEnquiry();
					}
				}
			};				

			llStandard.Click += delegate {
				if (constants.specialistInfo != null && constants.specialistInfo.SpecialistDetail != null) {
					isStandardHour = true;
					if(dialogBookPreTime == null)
						dialogBookPreTime = new BookPreTimeUI(this, isStandardHour);
					dialogBookPreTime.actionDelegate = this;
					dialogBookPreTime.showPreTimeEnquiry(isStandardHour);
				}
			};

			llSoonest.Click += delegate {
				if (constants.specialistInfo != null && constants.specialistInfo.SpecialistDetail != null) {
					BookASAPUI dialog = new BookASAPUI(this);
					dialog.actionDelegate = this;
					dialog.showASAPEnquiry();
				}
			};

			llAnother.Click += delegate {
				if (constants.specialistInfo != null && constants.specialistInfo.SpecialistDetail != null) {
					isStandardHour = false;
					if(dialogBookPreTime == null)
						dialogBookPreTime = new BookPreTimeUI(this, isStandardHour);
					dialogBookPreTime.actionDelegate = this;
					dialogBookPreTime.showPreTimeEnquiry(isStandardHour);
				}
			};
		}
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			SetContentView (Resource.Layout.customer_calling_layout);

			bloaded = false;

			ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
			ActionBar.SetTitle(Resource.String.calling_title);
			ActionBar.SetDisplayShowTitleEnabled (false);
			ActionBar.SetDisplayHomeAsUpEnabled(true);
			ActionBar.SetDisplayShowHomeEnabled (true);

			setHeadingTitle (Resource.String.calling_title);

			callingActivity = this;

			llProgress = FindViewById<LinearLayout> (Resource.Id.llProgressBar);
			llProgress.Visibility = ViewStates.Gone;

			tvName = FindViewById<TextView> (Resource.Id.tv_name_spec_calling);
			tvTimeDuration = FindViewById<TextView> (Resource.Id.tv_time_customer_calling);
			tvCostDuration = FindViewById<TextView> (Resource.Id.tv_cost_customer_calling);
			img_upfile = FindViewById<ImageView> (Resource.Id.img_upfile_calling);
			var avatar = FindViewById<ImageView> (Resource.Id.img_avatar_customer_calling);
			llFileAttach = FindViewById<LinearLayout> (Resource.Id.ll_file_attach_customer_calling);

			// Follow up action
			llGrFollowUpAction = FindViewById<LinearLayout> (Resource.Id.llGrFollowUpAction);
			imgRatingFollowUp = FindViewById<ImageView> (Resource.Id.imgRatingFolowUp);
			imgFavoriteFollowUp = FindViewById<ImageView> (Resource.Id.imgFavoriteFolowUp);
			imgEmailFollowUp = FindViewById<ImageView> (Resource.Id.imgEmailFollowUp);
			imgWaiveFeeFollowUp = FindViewById<ImageView> (Resource.Id.imgWaiveFeeFollowUp);
			imgTranscribeFollowUp = FindViewById<ImageView> (Resource.Id.imgTranscribeFollowUp);
			imgUpPhotoFollowUp = FindViewById<ImageView> (Resource.Id.imgUpPhotoFollowUp);
			imgReplayFollowUp = FindViewById<ImageView> (Resource.Id.imgReplayFollowUp);
			llRatingFollowUp = FindViewById<LinearLayout> (Resource.Id.llRatingFollowUp);
			llFavoriteFollowUp = FindViewById<LinearLayout> (Resource.Id.llFavoriteFollowUp);
			llEmailFollowUp = FindViewById<LinearLayout> (Resource.Id.llEmailFollowUp);
			llWaiveFollowUp = FindViewById<LinearLayout> (Resource.Id.llWaiveFeeFollowUp);
			llTransribeFollowUp = FindViewById<LinearLayout> (Resource.Id.llTranscribeFollowUp);
			llUpphotoFollowUp = FindViewById<LinearLayout> (Resource.Id.llUploadPhotoFollowUp);
			llReplayFollowUp = FindViewById<LinearLayout> (Resource.Id.llReplayFollowUp);
			tvWaiveFeeNotice = FindViewById<TextView> (Resource.Id.tv_notice_waived_calling);

			UrlImageViewHelper.UrlImageViewHelper.SetUrlDrawable (avatar, HttpConstants.BASE_URL + constants.durationInfo.AvatarPath, Resource.Drawable.special_home, constants.iTimeLoading, this);

			tvName.Text = constants.durationInfo.UserFullName;

			llGrFollowUpAction.Visibility = ViewStates.Gone;

			uploadPhoto = new UploadPhoto(this);
			uploadPhoto.actionUploadPhotoDelegate = this;

			deleteFile = new Teleconsult.Android.DeleteFile (this);
			deleteFile.deleteFileAction = this;

			// Action
			Background bgUpfile = new Background (this, Resource.Drawable.camera, Resource.Drawable.camera_pressed);
			img_upfile.SetBackgroundDrawable (bgUpfile);
			img_upfile.Click += (sender, e) => {
				if(uploadPhoto == null){
					uploadPhoto = new UploadPhoto(this);
					uploadPhoto.actionUploadPhotoDelegate = this;
				}
				uploadPhoto.selectActionUpload();
			};

			Background bgRating = new Background (this, Resource.Drawable.icon_feedback, Resource.Drawable.icon_feedback_pressed);
			imgRatingFollowUp.SetBackgroundDrawable (bgRating);
			imgRatingFollowUp.Click += (sender, e) => {
				if(isFeeback) {
					if(dialogFeedbackReview == null){
						dialogFeedbackReview = new RatingFeedbackReview(this);
					}
					dialogFeedbackReview.showFeedbackReview(iRatingNumber, sFeedBackContent);
				} else {
					if(dialogFeedback == null){
						dialogFeedback = new RatingFeedbackUI(this, callId);
						dialogFeedback.actionRatingDelegate = this;
					}
					dialogFeedback.showRatingFeedback();
				}
			};

			imgFavoriteFollowUp.Click += (sender, e) => {
				if (isFavorite) {
					if(dialogFavorite == null){
						dialogFavorite = new FavoriteUI(this);
						dialogFavorite.actionFavoriteDelegate = this;
					}
					dialogFavorite.removeFavoriteRequest(specId);
				} else {
					if(dialogFavorite == null){
						dialogFavorite = new FavoriteUI(this);
						dialogFavorite.actionFavoriteDelegate = this;
					}
					dialogFavorite.addToFavouriteRequest(specId);
				}
			};

			Background bgEmail = new Background (this, Resource.Drawable.ic_emailprofile, Resource.Drawable.ic_emailprofile_pressed);
			imgEmailFollowUp.SetBackgroundDrawable (bgEmail);
			imgEmailFollowUp.Click += (sender, e) => {
				SendEmailUI dialog = new SendEmailUI(this);
				dialog.actionDelegate = this;
				dialog.showEmailDialog(specId);
			};

			Background bgWaivefee = new Background (this, Resource.Drawable.ic_waive, Resource.Drawable.ic_waive_pressed);
			imgWaiveFeeFollowUp.SetBackgroundDrawable (bgWaivefee);
			imgWaiveFeeFollowUp.Click += (sender, e) => {
				if(dtEndWaiveFee != null && dtEndWaiveFee.AddMinutes (Constants.pTimeWaiveFee) >= Utils.getDateTimeNow (MApplication.getInstance ().timezoneName)){
					if (popupConfirm == null) {
						popupConfirm = new PopUpConfirm (this);
						popupConfirm.actionConfirmDelegate = this;
					}
					popupConfirm.showConfirmDialog (GetString(Resource.String.waive_fee_title), GetString(Resource.String.waive_fee_content), "Yes", "No");
				} else {
					popupNotice.showNoticeDialog(GetString(Resource.String.waive_fee_expired_title), GetString(Resource.String.waive_fee_expired));
					imgWaiveFeeFollowUp.Enabled = false;
					imgWaiveFeeFollowUp.SetBackgroundResource(Resource.Drawable.ic_waive_disable);
					imgWaiveFeeFollowUp.SetImageResource(Resource.Drawable.ic_waive_disable);
				}
			};

			Background bgTranscribe = new Background (this, Resource.Drawable.ic_transcribe, Resource.Drawable.ic_transcribe_pressed);
			imgTranscribeFollowUp.SetBackgroundDrawable (bgTranscribe);
			imgTranscribeFollowUp.Click += (sender, e) => {
				TranscribeRequest transcribe = new TranscribeRequest(this);
				transcribe.transcribeDelegate = this;
				transcribe.getTranscribe(callId, recordUrl);
			};

			Background bgUpphoto = new Background (this, Resource.Drawable.camera, Resource.Drawable.camera_pressed);
			imgUpPhotoFollowUp.SetBackgroundDrawable (bgUpphoto);
			imgUpPhotoFollowUp.Click += (sender, e) => {
				if(uploadPhoto == null){
					uploadPhoto = new UploadPhoto(this);
					uploadPhoto.actionUploadPhotoDelegate = this;
				}
				uploadPhoto.selectActionUpload();
			};

			Background bgReplay = new Background (this, Resource.Drawable.ic_replay, Resource.Drawable.ic_replay_pressed);
			imgReplayFollowUp.SetBackgroundDrawable (bgReplay);
			imgReplayFollowUp.Click += (sender, e) => {
				if(recordUrl != null){
					if(!recordUrl.Equals("")){
						Intent intent = new Intent(this, typeof(PlayAudioManager));
						intent.PutExtra(constants.pPathAudioFile, recordUrl);
						StartActivity(intent);
					} else {
						popupNotice.showNoticeDialog(GetString(Resource.String.title_notice), GetString(Resource.String.replay_not_exist_notice));
					}
				} else {
					popupNotice.showNoticeDialog(GetString(Resource.String.title_notice), GetString(Resource.String.replay_not_exist_notice));
				}
			};

			popupNotice = new PopupNoticeInfomation (this);
			popupNotice.noticeDelegate = this;

			updateCallStart (constants.durationInfo);
			TCNotificationCenter.defaultCenter.addObserver (this, Constants.kPostStopCall, new TCSelector (updateCallStop));
			TCNotificationCenter.defaultCenter.addObserver (this, Constants.kPostFolloUp, new TCSelector (onFollowUpAction));
			TCNotificationCenter.defaultCenter.addObserver (this, Constants.kPostUploadFileSuccess, new TCSelector (onUploadFileSuccess));
			TCNotificationCenter.defaultCenter.addObserver (this, Constants.kPostDeleteFileSuccess, new TCSelector (onDeleteFileSuccess));
		}
		private void SetEventForView ()
		{
			llTalkNow.Click += delegate {
				if(MApplication.getInstance().isLogedIn){
					if(MApplication.getInstance ().isCompleteProfile) {
						if(constants.specialistInfo.Account.CurrentAvailabilityStatus == (int)Constants.STATUS_CONSULTANT.NotAvailable){
							if(popupNotice == null){
								popupNotice = new PopupNoticeInfomation(this);
								popupNotice.noticeDelegate = this;
							}
							popupNotice.showNoticeDialog(GetString(Resource.String.title_notice), constants.specialistInfo.Account.Name +" is not available. You can't use this feature");
						} else{
							if(talkNowDialog == null){
								talkNowDialog = new TalkNowUI(this);
								talkNowDialog.actionTalknowDelegate = this;
							}
							talkNowDialog.ShowTalkNowEnquiry();
						}
					} else {
						showNoticeUpdateProfile();
					}
				} else {
					callLogInActivity();
				}
			};
			//ltthuc/13/08
			/*llSoonest.Click += delegate {
				if(MApplication.getInstance().isLogedIn){
					if(MApplication.getInstance ().isCompleteProfile) {
						if(asapDialog == null){
							asapDialog = new BookASAPUI(this);
							asapDialog.actionDelegate = this;
						}
						asapDialog.showASAPEnquiry();
					} else {
						showNoticeUpdateProfile();
					}
				} else {
					callLogInActivity();
				}
			};

			llStandard.Click += delegate {
				isStandardHour = true;
				if(MApplication.getInstance().isLogedIn){
					if(MApplication.getInstance ().isCompleteProfile) {
						if(dialogBookPreTime == null) {
							dialogBookPreTime = new BookPreTimeUI(this, isStandardHour);
							dialogBookPreTime.actionDelegate = this;
						}
						dialogBookPreTime.showPreTimeEnquiry(isStandardHour);
					} else {
						showNoticeUpdateProfile();
					}
				} else {
					callLogInActivity();
				}
			};*

			llAnotherTime.Click += delegate {
				isStandardHour = false;
				if(MApplication.getInstance().isLogedIn){
					if(MApplication.getInstance ().isCompleteProfile) {
						if(dialogBookPreTime == null){
							dialogBookPreTime = new BookPreTimeUI(this, isStandardHour);
							dialogBookPreTime.actionDelegate = this;
						}
						dialogBookPreTime.showPreTimeEnquiry(isStandardHour);
					} else {
						showNoticeUpdateProfile();
					}
				} else {
					callLogInActivity();
				}
			};*/

			btnAddFavorite.Click += delegate {
				if(MApplication.getInstance().isLogedIn) {
					if(dialogFavorite == null){
						dialogFavorite = new FavoriteUI(this);
						dialogFavorite.actionFavoriteDelegate = this;
					}
					if (constants.specialistInfo.IsFavourite) {
						dialogFavorite.removeFavoriteRequest(MApplication.getInstance ().specialistID);
					} else {
						dialogFavorite.addToFavouriteRequest(MApplication.getInstance ().specialistID);
					}
				} else {
					callLogInActivity();
				}
			};

			Background bgEmailProfile = new Background (this, Resource.Drawable.ic_emailprofile, Resource.Drawable.ic_emailprofile_pressed);
			btnEmailProfile.SetBackgroundDrawable (bgEmailProfile);
			btnEmailProfile.Click += delegate {
				if(emailDialog == null){
					emailDialog = new SendEmailUI(this);
					emailDialog.actionDelegate = this;
				}
				emailDialog.showEmailDialog(MApplication.getInstance ().specialistID);				
			};
		}