コード例 #1
0
        public async void ShowAlert(string messege, PreviewItem toDelete)
        {
            var alert = await DisplayAlert(Constants.ALERT_TITLE, messege, Constants.ALERT_OK, "Cancel");
            if (alert)
            {
				try {
					FeelingsSecondPage.actionPreviewListSource.Remove (toDelete);
                	
					var selectedItem = actionlist.FirstOrDefault (ac => ac.Name == toDelete.Name);
					actionIndex = actionlist.IndexOf(selectedItem);
					if(actionIndex >= 0)
					{
						actionlist.Remove (selectedItem);
					}

					selectedItem.Source = Device.OnPlatform ("tick_box.png", "tick_box.png", "//Assets//tick_box.png");

					if(actionIndex >= 0)
					{
						actionlist.Insert(actionIndex, selectedItem);
					}else {
						actionlist.Insert(0, selectedItem);
					}
					aePicker.listView.ItemsSource = null;
					aePicker.listView.ItemsSource = actionlist;
					if(Device.OS == TargetPlatform.iOS)
						aePicker.listView.ScrollTo(selectedItem,ScrollToPosition.Center,false);
					
				} catch (Exception ex) {
                	
				}
            }
        }
        public  async  void ShowAlert( string messege, PreviewItem toDelete )
        {
            try
            {

				
                var alert = await DisplayAlert(Constants.ALERT_TITLE, messege, Constants.ALERT_OK, "Cancel");

                if (alert)
                {
                    MediaItem media = App.MediaArray.FirstOrDefault(med => med.Name == toDelete.Name);

                    if (media == null || toDelete.Name == toDelete.Path)
                    {
                        #region DELETE FROM SERVER.
                        // delete from view and delete from db by api call.
                        IProgressBar progress = DependencyService.Get<IProgressBar>();
                        progress.ShowProgressbar("deleting media");
                        string responseCode = await ServiceHelper.DeleteMediaFromGem(currentGemId, currentGemType, toDelete.Name);
                        if (responseCode == "200")
                        {
                            App.PreviewListSource.Remove(toDelete);
                            progress.HideProgressbar();
                        }
                        else
                        {
                            progress.HideProgressbar();
                            progress.ShowToast("Could not delete the media now.");
                        }

                        #endregion
                    }
                    else
                    {
                        // delete from view and local memory
                        App.PreviewListSource.Remove(toDelete);
                        if (media != null)
                        {
                            App.MediaArray.Remove(media);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var test = ex.Message;
            }
        }