コード例 #1
0
        private void EditLocationDialog_OnLocationEdit(object sender, OnCompleteLocationDetailEventArgs e)
        {
            Location newLoc = new Location()
            {
                Name        = e.Name,
                Address     = e.Address,
                Description = e.Description,
            };
            var progressDialog = ProgressDialog.Show(this, "Please wait...", "Adding Location...", true);

            new Thread(new ThreadStart(delegate
            {
                var isAdded = mLocationDataService.Edit(mLocations[mSelectedLocation].Id, newLoc);
                RunOnUiThread(() => progressDialog.Hide());

                if (isAdded)
                {
                    RunOnUiThread(() => Toast.MakeText(this, "Location Editted", ToastLength.Long).Show());
                }
                else
                {
                    RunOnUiThread(() => Toast.MakeText(this, "Failed to Edit, please check again form's field", ToastLength.Long).Show());
                }
            })).Start();
        }
コード例 #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.LocationDetail, container, false);

            mLocationTitle            = view.FindViewById <TextView>(Resource.Id.textviewLocationDetailTitle);
            mButtonAddUser            = view.FindViewById <ImageButton>(Resource.Id.imageButtonLocationDetailAddUser);
            mButtonSave               = view.FindViewById <ImageButton>(Resource.Id.imageButtonLocationDetailSave);
            mButtonDelete             = view.FindViewById <ImageButton>(Resource.Id.imageButtonLocationDetailDelete);
            mLocationName             = view.FindViewById <EditText>(Resource.Id.editTextLocationDetailName);
            mLocationAddress          = view.FindViewById <EditText>(Resource.Id.editTextLocationDetailAddress);
            mLocationDescription      = view.FindViewById <EditText>(Resource.Id.editTextLocationDetailDescription);
            mLocationTitle.Text       = LoginPageActivity.StaticLocationClass.Name.ToString();
            mLocationName.Text        = LoginPageActivity.StaticLocationClass.Name.ToString();
            mLocationAddress.Text     = LoginPageActivity.StaticLocationClass.Address.ToString();
            mLocationDescription.Text = LoginPageActivity.StaticLocationClass.Description.ToString();
            mProgressBar              = view.FindViewById <ProgressBar>(Resource.Id.progressBarAddLocation);
            mListViewSharedLocation   = view.FindViewById <RecyclerView>(Resource.Id.recyclerViewLocationUser);
            mListViewSharedLocation.SetLayoutManager(new LinearLayoutManager(Activity));
            LoadLocationData();
            mButtonAddUser.Click += (object sender, EventArgs args) =>
            {
                ReplaceFragment(new LocationAddUserFragment(), "Add User");
            };
            mButtonSave.Click += (object sender, EventArgs args) =>
            {
                Location newLoc = new Location()
                {
                    Name        = mLocationName.Text,
                    Address     = mLocationAddress.Text,
                    Description = mLocationDescription.Text,
                };
                new Thread(new ThreadStart(delegate
                {
                    var isEdited = mLocationDataService.Edit(LocationsFragment.mSelectedLocationClass.Id, newLoc);

                    if (isEdited)
                    {
                        this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Location Editted", ToastLength.Long).Show());
                    }
                    else
                    {
                        this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed to Edit, please check again form's field", ToastLength.Long).Show());
                    }
                })).Start();
                ReplaceFragment(new LocationsFragment(), "Manage Locations");
            };
            mButtonDelete.Click += (object sender, EventArgs args) =>
            {
                ReplaceFragment(new LocationsFragment(), "Manage Locations");
            };
            return(view);
        }