async void ListView_OnItemClick (object sender, AdapterView.ItemClickEventArgs e) { try { TreeNode clickedItem = foundTreeNodeChildren [e.Position]; //Hide bottom menu for favorite file if (favoriteFolderOpened) { parentActivity.HideBottomExplorerMenuItems (); } else { parentActivity.ShowBottomExplorerMenuItems (); } //Show progress dialog while loading parentActivity.ShowProgressDialog (null); if (clickedItem.IsDirectory == true) //Folder aangeklikt (NIET "Lokale favorieten") { Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction (); fragmentTransaction.SetCustomAnimations (Resource.Animation.enter, Resource.Animation.exit); ExplorerFragment explorerFragment = new ExplorerFragment (await DataLayer.Instance.GetFolder (clickedItem.Path), parentActivity); HomeActivity.openedExplorerFragments.Add(explorerFragment); fragmentTransaction.Replace (Resource.Id.fragment_container_explorer, explorerFragment, "explorerFragment"); //Add new directory to opened directories list ExplorerFragment.openedDirectories.Add (clickedItem.Path); //Used to determine custom context menu if(ExplorerFragment.openedDirectories.Count == 2){ if(clickedItem.IsShare){ openedFolderIsShare = true; }else{ openedFolderIsShare = false; } } //Used to determine upload action and icon in listview item (encrypted or unencrypted folder) if(ExplorerFragment.openedDirectories.Count == 2){ if(clickedItem.HasKeys){ openedFolderIsUnencrypted = false; }else{ openedFolderIsUnencrypted = true; } } //Add fragment to stack - needed for back button functionality fragmentTransaction.AddToBackStack (null); // Start the animated transition. fragmentTransaction.Commit (); //Show hidden buttons ImageButton buttonBackExplorer = Activity.FindViewById<ImageButton> (Resource.Id.button_back_explorer); buttonBackExplorer.Visibility = ViewStates.Visible; } else if (clickedItem.Type.Equals ("favorite")) //List item "Lokale favorieten" aangeklikt { //Hide bottom menu for favorite folder parentActivity.HideBottomExplorerMenuItems (); Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction (); fragmentTransaction.SetCustomAnimations (Resource.Animation.enter, Resource.Animation.exit); List<TreeNode> favorites = DataLayer.Instance.GetFavorites (); ExplorerFragment explorerFragment = new ExplorerFragment (favorites, parentActivity); HomeActivity.openedExplorerFragments.Add(explorerFragment); fragmentTransaction.Replace (Resource.Id.fragment_container_explorer, explorerFragment, "explorerFragment"); //Add new directory to opened directories list ExplorerFragment.openedDirectories.Add (clickedItem.Path); //Add fragment to stack - needed for back button functionality fragmentTransaction.AddToBackStack (null); // Start the animated transition. fragmentTransaction.Commit (); //Show hidden buttons ImageButton buttonBackExplorer = Activity.FindViewById<ImageButton> (Resource.Id.button_back_explorer); buttonBackExplorer.Visibility = ViewStates.Visible; } else { //Bestand aangeklikt //Afbeeldingen openen in webview - andere typen bestanden openen middels content provider string mimeTypeOfClickedItem = MimeTypeHelper.GetMimeType(clickedItem.Path); clickedItem.Type = mimeTypeOfClickedItem; if (mimeTypeOfClickedItem.Equals ("image/jpeg") || mimeTypeOfClickedItem.Equals ("image/png") || mimeTypeOfClickedItem.Equals ("application/pdf") || mimeTypeOfClickedItem.Equals ("application/vnd.oasis.opendocument.text") || mimeTypeOfClickedItem.Equals ("text/html")) { lastShownTreeNodeId = clickedItem.Id; Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction (); fragmentTransaction.SetCustomAnimations (Resource.Animation.enter, Resource.Animation.exit); DocumentFragment documentFragment = new DocumentFragment (await DataLayer.Instance.GetFilePath (clickedItem.Path), clickedItem.Name); fragmentTransaction.Replace (Resource.Id.fragment_container_document, documentFragment, "documentFragment"); // Start the animated transition. fragmentTransaction.Commit (); } else if(mimeTypeOfClickedItem.Equals("video/mp4")) { var videoPlayerActivity = new Intent (Activity, typeof(VideoPlayerActivity)); string pathToVideo = await DataLayer.Instance.GetFilePath (clickedItem.Path); videoPlayerActivity.PutExtra ("PathToVideo", pathToVideo); StartActivity (videoPlayerActivity); } //Disabled - reason: no license for PDFTron /*else if(mimeTypeOfClickedItem.Equals("application/pdf")){ var pdfIntent = new Intent (Activity, typeof(PdfActivity)); string absolutePathOfPDF = await DataLayer.Instance.GetFilePath (clickedItem.Path); pdfIntent.PutExtra ("absolutePathOfPDF", absolutePathOfPDF); pdfIntent.PutExtra ("relativePathOfPDF", clickedItem.Path); pdfIntent.PutExtra ("fileName", clickedItem.Name); StartActivity (pdfIntent); }*/ else { //Open bestand in andere app OpenFileIn (clickedItem); } } } catch (Exception ex){ Insights.Report(ex); parentActivity.HideProgressDialog (); Toast.MakeText (Activity, "Het openen is mislukt. Probeer het a.u.b. opnieuw", ToastLength.Short).Show (); } parentActivity.HideProgressDialog (); }
async void ListView_OnItemClick(object sender, AdapterView.ItemClickEventArgs e) { try { TreeNode clickedItem = foundTreeNodeChildren [e.Position]; //Hide bottom menu for favorite file if (favoriteFolderOpened) { parentActivity.HideBottomExplorerMenuItems(); } else { parentActivity.ShowBottomExplorerMenuItems(); } //Show progress dialog while loading parentActivity.ShowProgressDialog(null); if (clickedItem.IsDirectory == true) //Folder aangeklikt (NIET "Lokale favorieten") { Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction(); fragmentTransaction.SetCustomAnimations(Resource.Animation.enter, Resource.Animation.exit); ExplorerFragment explorerFragment = new ExplorerFragment(await DataLayer.Instance.GetFolder(clickedItem.Path), parentActivity); HomeActivity.openedExplorerFragments.Add(explorerFragment); fragmentTransaction.Replace(Resource.Id.fragment_container_explorer, explorerFragment, "explorerFragment"); //Add new directory to opened directories list ExplorerFragment.openedDirectories.Add(clickedItem.Path); //Used to determine custom context menu if (ExplorerFragment.openedDirectories.Count == 2) { if (clickedItem.IsShare) { openedFolderIsShare = true; } else { openedFolderIsShare = false; } } //Used to determine upload action and icon in listview item (encrypted or unencrypted folder) if (ExplorerFragment.openedDirectories.Count == 2) { if (clickedItem.HasKeys) { openedFolderIsUnencrypted = false; } else { openedFolderIsUnencrypted = true; } } //Add fragment to stack - needed for back button functionality fragmentTransaction.AddToBackStack(null); // Start the animated transition. fragmentTransaction.Commit(); //Show hidden buttons ImageButton buttonBackExplorer = Activity.FindViewById <ImageButton> (Resource.Id.button_back_explorer); buttonBackExplorer.Visibility = ViewStates.Visible; } else if (clickedItem.Type.Equals("favorite")) //List item "Lokale favorieten" aangeklikt { //Hide bottom menu for favorite folder parentActivity.HideBottomExplorerMenuItems(); Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction(); fragmentTransaction.SetCustomAnimations(Resource.Animation.enter, Resource.Animation.exit); List <TreeNode> favorites = DataLayer.Instance.GetFavorites(); ExplorerFragment explorerFragment = new ExplorerFragment(favorites, parentActivity); HomeActivity.openedExplorerFragments.Add(explorerFragment); fragmentTransaction.Replace(Resource.Id.fragment_container_explorer, explorerFragment, "explorerFragment"); //Add new directory to opened directories list ExplorerFragment.openedDirectories.Add(clickedItem.Path); //Add fragment to stack - needed for back button functionality fragmentTransaction.AddToBackStack(null); // Start the animated transition. fragmentTransaction.Commit(); //Show hidden buttons ImageButton buttonBackExplorer = Activity.FindViewById <ImageButton> (Resource.Id.button_back_explorer); buttonBackExplorer.Visibility = ViewStates.Visible; } else //Bestand aangeklikt //Afbeeldingen openen in webview - andere typen bestanden openen middels content provider { string mimeTypeOfClickedItem = MimeTypeHelper.GetMimeType(clickedItem.Path); clickedItem.Type = mimeTypeOfClickedItem; if (mimeTypeOfClickedItem.Equals("image/jpeg") || mimeTypeOfClickedItem.Equals("image/png") || mimeTypeOfClickedItem.Equals("application/pdf") || mimeTypeOfClickedItem.Equals("application/vnd.oasis.opendocument.text") || mimeTypeOfClickedItem.Equals("text/html")) { lastShownTreeNodeId = clickedItem.Id; Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction(); fragmentTransaction.SetCustomAnimations(Resource.Animation.enter, Resource.Animation.exit); DocumentFragment documentFragment = new DocumentFragment(await DataLayer.Instance.GetFilePath(clickedItem.Path), clickedItem.Name); fragmentTransaction.Replace(Resource.Id.fragment_container_document, documentFragment, "documentFragment"); // Start the animated transition. fragmentTransaction.Commit(); } else if (mimeTypeOfClickedItem.Equals("video/mp4")) { var videoPlayerActivity = new Intent(Activity, typeof(VideoPlayerActivity)); string pathToVideo = await DataLayer.Instance.GetFilePath(clickedItem.Path); videoPlayerActivity.PutExtra("PathToVideo", pathToVideo); StartActivity(videoPlayerActivity); } //Disabled - reason: no license for PDFTron /*else if(mimeTypeOfClickedItem.Equals("application/pdf")){ * * var pdfIntent = new Intent (Activity, typeof(PdfActivity)); * * string absolutePathOfPDF = await DataLayer.Instance.GetFilePath (clickedItem.Path); * pdfIntent.PutExtra ("absolutePathOfPDF", absolutePathOfPDF); * pdfIntent.PutExtra ("relativePathOfPDF", clickedItem.Path); * pdfIntent.PutExtra ("fileName", clickedItem.Name); * * StartActivity (pdfIntent); * }*/ else { //Open bestand in andere app OpenFileIn(clickedItem); } } } catch (Exception ex) { Insights.Report(ex); parentActivity.HideProgressDialog(); Toast.MakeText(Activity, "Het openen is mislukt. Probeer het a.u.b. opnieuw", ToastLength.Short).Show(); } parentActivity.HideProgressDialog(); }