private void RefreshDirectory(object sender, EventArgs e)
        {
            Task.Run(() => {
                try
                {
                    items = directory.EnumerateFileSystemInfos()
                            .Where(x => !x.Attributes.HasFlag(FileAttributes.Hidden) && !x.Attributes.HasFlag(FileAttributes.System))
                            .OrderByDescending(x => x.Attributes.HasFlag(FileAttributes.Directory))
                            .ThenBy(x => x.Name)
                            .ToList();
                }
                catch (IOException)
                {
                    items = null;
                    this.ShowAlert(GetString(Resource.String.error_folder_title), GetString(Resource.String.error_folder_message));
                }

                var models = new List <IFlexible>();
                if (depth != 0)
                {
                    var parentPath = directory.Parent.Name;
                    models.Add(new FolderGoBack(parentPath));
                }
                models.AddRange(items.Select(x => new FileFolder(x)));
                RunOnUiThread(() => {
                    adapter.UpdateDataSet(models, true);
                    if (R.list_reloader.Refreshing)
                    {
                        R.list_reloader.Refreshing = false;
                    }
                });
            });
        }
        private void RefreshFunctions(object sender, EventArgs e)
        {
            if (!R.list_reloader.Refreshing)
            {
                R.list_reloader.Refreshing = true;
            }

            items = Globals.CloudManager.PersonalClouds[0].Apps;
            var models = items.Select(x => new WebApp(x)).ToList();

            adapter.UpdateDataSet(models, true);
            if (R.list_reloader.Refreshing)
            {
                R.list_reloader.Refreshing = false;
            }
        }
예제 #3
0
        private void RefreshDirectory(object sender, EventArgs e)
        {
            if (!R.list_reloader.Refreshing)
            {
                R.list_reloader.Refreshing = true;
            }

            Task.Run(async() => {
                var models = new List <IFlexible>();
                if (workingPath.Length != 1)
                {
                    var parentPath = Path.GetFileName(Path.GetDirectoryName(workingPath.TrimEnd(Path.AltDirectorySeparatorChar)).TrimEnd(Path.AltDirectorySeparatorChar));
                    models.Add(new FolderGoBack(parentPath));
                }

                try
                {
                    var files = await fileSystem.EnumerateChildrenAsync(workingPath).ConfigureAwait(false);
                    items     = files.Where(x => x.IsDirectory && !x.Attributes.HasFlag(FileAttributes.Hidden) && !x.Attributes.HasFlag(FileAttributes.System))
                                .OrderBy(x => x.Name).ToList();

                    models.AddRange(items.Select(x => new FileFolder(x)));
                }
                catch (HttpRequestException exception)
                {
                    RunOnUiThread(() => this.ShowAlert(GetString(Resource.String.error_remote), exception.Message));
                }
                catch (Exception exception)
                {
                    RunOnUiThread(() => this.ShowAlert(GetString(Resource.String.error_folder_title), exception.GetType().Name));
                }

                RunOnUiThread(() => {
                    adapter.UpdateDataSet(models, true);
                    if (R.list_reloader.Refreshing)
                    {
                        R.list_reloader.Refreshing = false;
                    }
                });
            });
        }
        private void RefreshDirectory(object sender, EventArgs e)
        {
            if (!R.list_reloader.Refreshing)
            {
                R.list_reloader.Refreshing = true;
            }

            if (!workingPath.EndsWith(Path.AltDirectorySeparatorChar))
            {
                workingPath += Path.AltDirectorySeparatorChar;
            }

            var activity = (MainActivity)Activity;

            if (workingPath.Length == 1)
            {
                activity.SetActionBarTitle(Resource.String.personal_cloud);
                try { Globals.CloudManager.StartNetwork(false); }
                catch { } // Ignored.
            }

            Task.Run(async() => {
                string title = null;
                if (workingPath.Length != 1)
                {
                    var deviceNameEnd = workingPath.IndexOf(Path.AltDirectorySeparatorChar, 1);
                    if (deviceNameEnd != -1)
                    {
                        title = workingPath.Substring(1, deviceNameEnd).Trim(Path.AltDirectorySeparatorChar);
                    }
                }

                var models = new List <IFlexible>();
                if (workingPath.Length != 1)
                {
                    var parentPath = Path.GetFileName(Path.GetDirectoryName(workingPath.TrimEnd(Path.AltDirectorySeparatorChar)).TrimEnd(Path.AltDirectorySeparatorChar));
                    models.Add(new FolderGoBack(parentPath));
                }

                try
                {
                    var files = await fileSystem.EnumerateChildrenAsync(workingPath).ConfigureAwait(false);
                    items     = files.Where(x => !x.Attributes.HasFlag(FileAttributes.Hidden) && !x.Attributes.HasFlag(FileAttributes.System))
                                .OrderByDescending(x => x.IsDirectory).ThenBy(x => x.Name).ToList();
                    models.AddRange(items.Select(x => new FileFolder(x)));
                }
                catch (HttpRequestException exception)
                {
                    items = null;
                    Activity.RunOnUiThread(() => {
                        Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message);
                    });
                }
                catch (Exception exception)
                {
                    Activity.RunOnUiThread(() => {
                        Activity.ShowAlert(GetString(Resource.String.error_folder_title), exception.GetType().Name);
                    });
                }

                Activity.RunOnUiThread(() => {
                    adapter.UpdateDataSet(models, true);
                    if (!string.IsNullOrEmpty(title))
                    {
                        activity.SetActionBarTitle(title);
                    }
                    if (R.list_reloader.Refreshing)
                    {
                        R.list_reloader.Refreshing = false;
                    }
                    Activity.InvalidateOptionsMenu();
                });
            });
        }