コード例 #1
0
        public override View OnCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle)
        {
            View view = layoutInflater.Inflate(Resource.Layout.fragment_explorer, viewGroup, false);

            explorerAdapter = new ExplorerAdapter(Activity, foundTreeNodeChildren, false);
            ListAdapter     = explorerAdapter;

            return(view);
        }
コード例 #2
0
        private async void UnFavoriteFile(TreeNode selectedItem)
        {
            try {
                popupWindow.Dismiss();

                parentActivity.ShowProgressDialog("Bestanden verwijderen uit favorieten");

                bool unFavoriteSucceed = await DataLayer.Instance.UnFavoriteFile(selectedItem);

                if (!unFavoriteSucceed)
                {
                    Toast.MakeText(Android.App.Application.Context, "Mislukt om bestand uit favorieten te verwijderen", ToastLength.Short).Show();
                }
                else
                {
                    Toast.MakeText(Android.App.Application.Context, "Bestand succesvol uit favorieten verwijderd", ToastLength.Short).Show();
                }
                parentActivity.HideProgressDialog();

                //Refresh listview
                int numberOfDirectoriesOpened = ExplorerFragment.openedDirectories.Count;
                if (numberOfDirectoriesOpened >= 1)
                {
                    if (ExplorerFragment.openedDirectories [numberOfDirectoriesOpened - 1] != null)                     //Favorite folder niet geopend
                    {
                        RefreshData();
                    }
                    else
                    {
                        //Favorite folder opened so refresh favorite list
                        List <TreeNode> favorites = DataLayer.Instance.GetFavorites();

                        explorerAdapter = new ExplorerAdapter(Activity, favorites, false);
                        ListAdapter     = explorerAdapter;

                        //UPDATE UI
                        Activity.RunOnUiThread(new Action(() => {
                            explorerAdapter.NotifyDataSetChanged();
                            explorerListView.InvalidateViews();
                        }));
                    }
                }
                else
                {
                    RefreshData();
                }
            } catch (Exception ex) {
                Insights.Report(ex);
                parentActivity.HideProgressDialog();
                Toast.MakeText(Android.App.Application.Context, "Mislukt om bestand uit favorieten te verwijderen", ToastLength.Short).Show();
            }
        }
コード例 #3
0
        public async void RefreshData()
        {
            parentActivity.HideProgressDialog();
            parentActivity.ShowProgressDialog(null);

            try {
                //Get current opened directory name

                int numberOfDirectoriesOpened = ExplorerFragment.openedDirectories.Count;
                if (numberOfDirectoriesOpened >= 1)
                {
                    string currentDirectoryName = ExplorerFragment.openedDirectories [numberOfDirectoriesOpened - 1];

                    foundTreeNodeChildren = new List <TreeNode> ();
                    foundTreeNodeChildren = (await DataLayer.Instance.GetFolder(currentDirectoryName, true)).Children;

                    parentActivity.RunOnUiThread(new Action(() => {
                        //Add favorite list item in root listview of local box
                        if (openedDirectories.Count == 1)
                        {
                            foundTreeNodeChildren.Insert(0, new TreeNode()
                            {
                                Name = "Lokale favorieten", Type = "favorite"
                            });
                        }

                        explorerAdapter = new ExplorerAdapter(Activity, foundTreeNodeChildren, false);
                        ListAdapter     = explorerAdapter;

                        //Update UI
                        explorerAdapter.NotifyDataSetChanged();
                        explorerListView.InvalidateViews();
                    }));
                }
                parentActivity.HideProgressDialog();
            }
            catch (Exception ex) {
                Insights.Report(ex);
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);

                parentActivity.HideProgressDialog();
                if (!SslValidator.CertificateErrorRaised)
                {
                    Toast.MakeText(Android.App.Application.Context, "Data verversen mislukt. Probeer het a.u.b. opnieuw", ToastLength.Short).Show();
                }
            }
        }
コード例 #4
0
        public override View OnCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle)
        {
            Dialog.SetTitle(treeNodeToMove.Name);

            View view = layoutInflater.Inflate(Resource.Layout.fragment_move_file, viewGroup, false);

            //Set color
            LinearLayout customActionBar = view.FindViewById <LinearLayout> (Resource.Id.custom_actionbar_fragment_move_file);

            customActionBar.SetBackgroundColor(Color.ParseColor(HomeActivity.colorOfSelectedLocalBox));

            buttonMoveFileToSelectedFolder         = view.FindViewById <Button> (Resource.Id.button_move_file_to_selected_folder);
            buttonMoveFileToSelectedFolder.Enabled = false;
            buttonMoveFileToSelectedFolder.Click  += delegate
            {
                MoveFileToOpenedFolder();
            };

            openedDirectories.Add("/");

            explorerAdapter = new ExplorerAdapter(Activity, foundDirectoryTreeNodes, true);

            listViewMoveFile            = view.FindViewById <ListView> (Resource.Id.listViewMoveFile);
            listViewMoveFile.Adapter    = explorerAdapter;
            listViewMoveFile.ItemClick += async(object sender, Android.Widget.AdapterView.ItemClickEventArgs e) => {              //List item select event
                ShowProgressDialog(Activity, null);

                try{
                    List <TreeNode> foundDirectories = new List <TreeNode>();

                    pathOfCurrentOpenedFolder = explorerAdapter.foundTreeNodes[e.Position].Path;

                    TreeNode selectedTreeNode = await DataLayer.Instance.GetFolder(pathOfCurrentOpenedFolder);

                    foreach (TreeNode foundTreeNode in selectedTreeNode.Children)
                    {
                        if (foundTreeNode.IsDirectory)
                        {
                            foundDirectories.Add(foundTreeNode);
                        }
                    }
                    openedDirectories.Add(selectedTreeNode.Path);
                    selectedTreeNodes.Add(selectedTreeNode);
                    buttonBack.Visibility = ViewStates.Visible;

                    //Used to determine folder icon
                    if (openedDirectories.Count == 2)
                    {
                        if (selectedTreeNode.HasKeys)
                        {
                            openedFolderIsUnencrypted = false;
                        }
                        else
                        {
                            openedFolderIsUnencrypted = true;
                        }
                    }

                    explorerAdapter          = new ExplorerAdapter(Activity, foundDirectories, true);
                    listViewMoveFile.Adapter = explorerAdapter;

                    Activity.RunOnUiThread(new Action(() => {
                        explorerAdapter.NotifyDataSetChanged();
                        buttonMoveFileToSelectedFolder.Enabled = true;
                        HideProgressDialog();

                        Console.WriteLine("Current opened folder; " + pathOfCurrentOpenedFolder);
                    }));
                }
                catch (Exception ex) {
                    Insights.Report(ex);
                    HideProgressDialog();
                    Toast.MakeText(Activity, "Er is iets fout gegaan. Probeer het a.u.b. opnieuw", ToastLength.Short).Show();
                }
            };


            buttonBack            = view.FindViewById <ImageButton> (Resource.Id.imagebutton_back_move_file);
            buttonBack.Visibility = ViewStates.Invisible;
            buttonBack.Click     += delegate
            {
                int directoriesOpened = selectedTreeNodes.Count;

                if (directoriesOpened > 0)
                {
                    selectedTreeNodes.RemoveAt(directoriesOpened - 1);

                    if (selectedTreeNodes.Count == 0)
                    {
                        explorerAdapter          = new ExplorerAdapter(Activity, foundDirectoryTreeNodes, true);
                        listViewMoveFile.Adapter = explorerAdapter;

                        buttonBack.Visibility = ViewStates.Invisible;

                        //Set path of destination folder
                        pathOfCurrentOpenedFolder = "/";

                        buttonMoveFileToSelectedFolder.Enabled = false;
                    }
                    else
                    {
                        List <TreeNode> foundDirectories = new List <TreeNode>();

                        //Set path of destination folder
                        pathOfCurrentOpenedFolder = selectedTreeNodes[directoriesOpened - 2].Path;

                        foreach (TreeNode foundTreeNode in selectedTreeNodes[directoriesOpened - 2].Children)
                        {
                            if (foundTreeNode.IsDirectory)
                            {
                                foundDirectories.Add(foundTreeNode);
                            }
                        }
                        explorerAdapter          = new ExplorerAdapter(Activity, foundDirectories, true);
                        listViewMoveFile.Adapter = explorerAdapter;
                    }
                }

                //UPDATE UI
                Activity.RunOnUiThread(new Action(() => {
                    explorerAdapter.NotifyDataSetChanged();
                }));

                int count = openedDirectories.Count;
                openedDirectories.RemoveAt(count - 1);
            };
            return(view);
        }