Beispiel #1
0
        public override async void OnListItemClick(ListView listView, View view, int position, long id)
        {
            FileSystemInfo fileSystemInfo = fileListadapter.GetItem(position);

            if (fileSystemInfo.IsFile())
            {
                CustomProgressDialog progressDialog = new CustomProgressDialog();
                progressDialog.Show(Activity, "Bestand uploaden. Een ogenblik geduld a.u.b.");

                try {
                    //get current folder path to add file to
                    int    numberOfDirectoriesOpened   = ExplorerFragment.openedDirectories.Count;
                    string directoryNameToUploadFileTo = ExplorerFragment.openedDirectories [numberOfDirectoriesOpened - 1];

                    string fullDestinationPath = System.IO.Path.Combine(directoryNameToUploadFileTo, fileSystemInfo.Name);
                    bool   uploadedSucceeded   = await DataLayer.Instance.UploadFile(fullDestinationPath, fileSystemInfo.FullName);

                    if (!uploadedSucceeded)
                    {
                        Toast.MakeText(Activity, "Er is iets fout gegaan", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(Activity, "Bestand succesvol geupload", ToastLength.Short).Show();

                        Activity.Finish();
                    }
                } catch (Exception ex) {
                    Insights.Report(ex);
                    Toast.MakeText(Activity, "Er is iets fout gegaan", ToastLength.Short).Show();
                }
                progressDialog.Hide();
            }
            else
            {
                // Dig into this directory, and display it's contents
                Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction();
                //fragmentTransaction.SetCustomAnimations (Resource.Animation.enter, Resource.Animation.exit);

                FileListFragment fileListFragment = new FileListFragment(fileSystemInfo.FullName);
                fragmentTransaction.Replace(Resource.Id.fragment_container_filepicker, fileListFragment, "fileListFragment");

                //Add fragment to stack - needed for back button functionality
                fragmentTransaction.AddToBackStack(null);

                // Start the animated transition.
                fragmentTransaction.Commit();
            }
            base.OnListItemClick(listView, view, position, id);
        }
		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);
			SetContentView(Resource.Layout.activity_filepicker);

			FileListFragment fileListFragment = new FileListFragment (FileListFragment.DefaultInitialDirectory);
			SupportFragmentManager.BeginTransaction().Add (Resource.Id.fragment_container_filepicker, fileListFragment).Commit ();

			//Change color of action bar
			ColorDrawable colorDrawable;
			if (!String.IsNullOrEmpty (HomeActivity.colorOfSelectedLocalBox)) {
				colorDrawable = new ColorDrawable (Color.ParseColor (HomeActivity.colorOfSelectedLocalBox));
			} else {
				colorDrawable = new ColorDrawable (Color.ParseColor (Constants.lightblue));
			}
			this.ActionBar.SetBackgroundDrawable (colorDrawable); 
		}
		public override async void OnListItemClick(ListView listView, View view, int position, long id)
		{
			FileSystemInfo fileSystemInfo = fileListadapter.GetItem(position);

			if (fileSystemInfo.IsFile ()) {
				CustomProgressDialog progressDialog = new CustomProgressDialog ();
				progressDialog.Show (Activity, "Bestand uploaden. Een ogenblik geduld a.u.b.");

				try {
					//get current folder path to add file to
					int numberOfDirectoriesOpened = ExplorerFragment.openedDirectories.Count;
					string directoryNameToUploadFileTo = ExplorerFragment.openedDirectories [numberOfDirectoriesOpened - 1];

					string fullDestinationPath = System.IO.Path.Combine (directoryNameToUploadFileTo, fileSystemInfo.Name);
					bool uploadedSucceeded = await DataLayer.Instance.UploadFile (fullDestinationPath, fileSystemInfo.FullName);

					if (!uploadedSucceeded) {
						Toast.MakeText (Activity, "Er is iets fout gegaan", ToastLength.Short).Show ();
					} else {
						Toast.MakeText (Activity, "Bestand succesvol geupload", ToastLength.Short).Show ();
						
						Activity.Finish ();
					}
				} catch (Exception ex){
					Insights.Report(ex);
					Toast.MakeText (Activity, "Er is iets fout gegaan", ToastLength.Short).Show ();
				}
				progressDialog.Hide ();
			} else {
				// Dig into this directory, and display it's contents
				Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction ();
				//fragmentTransaction.SetCustomAnimations (Resource.Animation.enter, Resource.Animation.exit);

				FileListFragment fileListFragment = new FileListFragment (fileSystemInfo.FullName);
				fragmentTransaction.Replace (Resource.Id.fragment_container_filepicker, fileListFragment, "fileListFragment");

				//Add fragment to stack - needed for back button functionality
				fragmentTransaction.AddToBackStack (null);

				// Start the animated transition.
				fragmentTransaction.Commit ();
			}
			base.OnListItemClick(listView, view, position, id);
		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_filepicker);

            FileListFragment fileListFragment = new FileListFragment(FileListFragment.DefaultInitialDirectory);

            SupportFragmentManager.BeginTransaction().Add(Resource.Id.fragment_container_filepicker, fileListFragment).Commit();

            //Change color of action bar
            ColorDrawable colorDrawable;

            if (!String.IsNullOrEmpty(HomeActivity.colorOfSelectedLocalBox))
            {
                colorDrawable = new ColorDrawable(Color.ParseColor(HomeActivity.colorOfSelectedLocalBox));
            }
            else
            {
                colorDrawable = new ColorDrawable(Color.ParseColor(Constants.lightblue));
            }
            this.ActionBar.SetBackgroundDrawable(colorDrawable);
        }