Beispiel #1
0
        private void InitFields()
        {
            this.mAddButton           = FindViewById <Button>(Resource.Id.buttonStorageAdd);
            this.mEditButton          = FindViewById <Button>(Resource.Id.buttonStorageEdit);
            this.mDeleteButton        = FindViewById <Button>(Resource.Id.buttonStorageDelete);
            this.mTextSelectedStorage = FindViewById <TextView>(Resource.Id.textViewSelectedStorage);
            this.mListViewStorage     = FindViewById <RecyclerView>(Resource.Id.recyclerViewStorages);
            this.mListViewStorage.SetLayoutManager(new LinearLayoutManager(this));

            LoadStoragesData();
            mDeleteButton.Click += (object sender, EventArgs args) =>
            {
                var progressDialog = ProgressDialog.Show(this, "Please wait...", "Deleting...", true);
                new Thread(new ThreadStart(delegate
                {
                    if (mSelectedStorage > -1)
                    {
                        var isDeleted = mStorageDataService.Delete(mSelectedStorageClass.Id);
                        RunOnUiThread(() => progressDialog.Hide());

                        if (isDeleted)
                        {
                            RunOnUiThread(() => Toast.MakeText(this, "Deleted!", ToastLength.Short).Show());
                        }
                        else
                        {
                            RunOnUiThread(() => Toast.MakeText(this, "Failed to delete, please check your connection", ToastLength.Long).Show());
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, "Select Storage First..", ToastLength.Long).Show();
                    }
                })).Start();
            };

            mEditButton.Click += (object sender, EventArgs args) =>
            {
                if (mSelectedStorage > -1)
                {
                    FragmentTransaction transaction   = FragmentManager.BeginTransaction();
                    DialogStorageDetail dialogStorage = new DialogStorageDetail(mSelectedStorageClass);
                    dialogStorage.Show(transaction, "dialogue fragment");
                    dialogStorage.OnCompleteStorageDetail += EditStorageDialog_OnStorageEdit;
                }
                else
                {
                    Toast.MakeText(this, "Select Storage First..", ToastLength.Long).Show();
                }
            };
            mAddButton.Click += (object sender, EventArgs args) =>
            {
                FragmentTransaction transaction   = FragmentManager.BeginTransaction();
                DialogAddStorage    dialogStorage = new DialogAddStorage();
                dialogStorage.Show(transaction, "dialogue fragment");
                dialogStorage.OnAddStorageComplete += AddStorageDialog_OnStorageAdd;
            };
        }
Beispiel #2
0
        private void InitFields()
        {
            this.mAddButton            = FindViewById <Button>(Resource.Id.buttonCategoriesAdd);
            this.mEditButton           = FindViewById <Button>(Resource.Id.buttonCategoriesEdit);
            this.mBackButton           = FindViewById <ImageButton>(Resource.Id.buttonCategoriesBack);
            this.mTextSelectedCategory = FindViewById <TextView>(Resource.Id.textViewSelectedCategory);
            this.mListViewCategory     = FindViewById <RecyclerView>(Resource.Id.recyclerViewCategories);
            this.mListViewCategory.SetLayoutManager(new LinearLayoutManager(this));

            LoadStoragesData();
            mEditButton.Click += (object sender, EventArgs args) =>
            {
                if (mSelectedCategory > -1)
                {
                    FragmentTransaction  transaction    = FragmentManager.BeginTransaction();
                    DialogCategoryDetail dialogCategory = new DialogCategoryDetail(mSelectedCategoryClass);
                    dialogCategory.Show(transaction, "dialogue fragment");
                    dialogCategory.OnCompleteCategoryDetail += EditCategoryDialog_OnCategoryEdit;
                }
                else
                {
                    Toast.MakeText(this, "Select Storage First..", ToastLength.Long).Show();
                }
            };
            mAddButton.Click += (object sender, EventArgs args) =>
            {
                FragmentTransaction transaction   = FragmentManager.BeginTransaction();
                DialogAddStorage    dialogStorage = new DialogAddStorage();
                dialogStorage.Show(transaction, "dialogue fragment");
                dialogStorage.OnAddStorageComplete += AddStorageDialog_OnStorageAdd;
            };
            mBackButton.Click += (object sender, EventArgs args) =>
            {
                FragmentTransaction transaction   = FragmentManager.BeginTransaction();
                DialogAddStorage    dialogStorage = new DialogAddStorage();
                dialogStorage.Show(transaction, "dialogue fragment");
                dialogStorage.OnAddStorageComplete += AddStorageDialog_OnStorageAdd;
            };
        }