Esempio n. 1
0
		void ListView_OnItemLongClick (object sender, AdapterView.ItemLongClickEventArgs e)
		{
			LocalBox clickedItem = foundLocalBoxes [e.Position];

			LayoutInflater inflater = (LayoutInflater)Activity.GetSystemService (Context.LayoutInflaterService); 
			View popupView;
			popupView = inflater.Inflate (Resource.Layout.custom_popup_root, null);

			PopupWindow popupWindow = new PopupWindow (popupView, e.View.Width, e.View.Height);

			//Hide popup window when clicking outside its view
			popupWindow.Focusable = true;
			popupWindow.Update ();
			popupWindow.SetBackgroundDrawable(new BitmapDrawable());

			popupWindow.ShowAsDropDown (e.View, 0, - e.View.Height);

			ImageButton buttonDelete = (ImageButton) popupView.FindViewById(Resource.Id.button_popup_root_delete);

			buttonDelete.Click += delegate {
				popupWindow.Dismiss();

				var alertDialogConfirmDelete = new Android.App.AlertDialog.Builder (Activity);
				alertDialogConfirmDelete.SetTitle("Waarschuwing");
				alertDialogConfirmDelete.SetMessage("Weet u zeker dat u deze Pleiobox wilt verwijderen? \nDeze actie is niet terug te draaien.");

				alertDialogConfirmDelete.SetPositiveButton ("Verwijderen", async delegate { 
					try{
						DataLayer.Instance.DeleteLocalBox(clickedItem.Id);
						ResetUIToBeginState(true);
						UpdateLocalBoxes();

						List<LocalBox> registeredLocalBoxes = await DataLayer.Instance.GetLocalBoxes ();
						if (registeredLocalBoxes.Count == 0) {
							HomeActivity homeActivity = (HomeActivity)Activity;
							homeActivity.ShowLoginDialog();
						}
						//Reset logo
						//imageViewLogo.SetImageResource (Resource.Drawable.beeldmerk_belastingdienst);
					}catch (Exception ex){
						Insights.Report(ex);
						Toast.MakeText (Android.App.Application.Context, "Het verwijderen van de Pleiobox is mislukt", ToastLength.Short).Show ();
					}
				});
				alertDialogConfirmDelete.SetNegativeButton ("Annuleren", delegate { 
					alertDialogConfirmDelete.Dispose();
				});
				alertDialogConfirmDelete.Create ().Show ();
			};
		}
		void ListView_OnItemLongClick (object sender, AdapterView.ItemLongClickEventArgs e)
		{
			LayoutInflater inflater = (LayoutInflater)Activity.GetSystemService (Context.LayoutInflaterService); 
			View popupView;

			TreeNode selectedItem = foundTreeNodeChildren [e.Position];

			int numberOfDirectoriesOpened = ExplorerFragment.openedDirectories.Count;
			string currentDirectoryName = ExplorerFragment.openedDirectories [numberOfDirectoriesOpened - 1];

			if (selectedItem.IsDirectory == true) { //Directory clicked - so open folder popup layout
				if (!currentDirectoryName.Equals ("/")) {
					popupView = inflater.Inflate (Resource.Layout.custom_popup_folder_subfolder, null);
					ClickHandlersFolderSubFolderPopupMenu (popupView, selectedItem);
				} else {
					popupView = inflater.Inflate (Resource.Layout.custom_popup_folder_root, null);
				}
			} 
			else 
			{  	//File clicked - so open file popup layout
				if (openedFolderIsShare || favoriteFolderOpened) {
					popupView = inflater.Inflate (Resource.Layout.custom_popup_file_share, null);
				} 
				else if (openedFolderIsUnencrypted) {
					popupView = inflater.Inflate (Resource.Layout.custom_popup_file_unencrypted, null);
				}
				else {
					popupView = inflater.Inflate (Resource.Layout.custom_popup_file_encrypted, null);
				}
				ClickHandlersFilePopupMenu (popupView, selectedItem);
			}

			popupWindow = new PopupWindow (popupView, e.View.Width, e.View.Height);

			//Hide popup window when clicking outside its view
			popupWindow.Focusable = true;
			popupWindow.Update ();
			popupWindow.SetBackgroundDrawable (new BitmapDrawable ());

			//Menu alleen tonen als het niet list item "Lokale favorieten" betreft
			if (selectedItem.Type == null) {//Directory selected so show menu (alleen als het niet een share van een ander is)

				if (currentDirectoryName.Equals ("/")) {
					if (!selectedItem.IsShare) {
						popupWindow.ShowAsDropDown (e.View, 0, -e.View.Height);
					}
				} else {
					if (openedFolderIsShare == false) { 
						popupWindow.ShowAsDropDown (e.View, 0, -e.View.Height);
					}
				}
			}
			else if (!selectedItem.Type.Equals ("favorite")) {//File selected so show menu
				popupWindow.ShowAsDropDown (e.View, 0, -e.View.Height);
			}
		}