Exemplo n.º 1
0
        private async Task Init()
        {
            try
            {
                _connection = await Database.Connect(this);

                InitCategories();
                InitAuthenticators();

                await UpdateCategories(false);
                await UpdateAuthenticators(false);

                CreateTimer();
            }
            catch (SQLiteException)
            {
                var builder = new AlertDialog.Builder(this);
                builder.SetMessage(Resource.String.databaseError);
                builder.SetTitle(Resource.String.warning);
                builder.SetPositiveButton(Resource.String.quit, (sender, args) =>
                {
                    Finish();
                });
                builder.SetCancelable(true);

                var dialog = builder.Create();
                dialog.Show();
            }
        }
Exemplo n.º 2
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            var alert = new AlertDialog.Builder(Activity);

            alert.SetTitle(Resource.String.chooseCategories);
            alert.SetCancelable(false);
            alert.SetPositiveButton(Resource.String.ok, (EventHandler <DialogClickEventArgs>)null);

            var view = Activity.LayoutInflater.Inflate(Resource.Layout.dialogChooseCategories, null);

            _categoryList = view.FindViewById <RecyclerView>(Resource.Id.dialogChooseCategories_list);
            alert.SetView(view);

            var dialog = alert.Create();

            dialog.Show();

            var layout     = new LinearLayoutManager(Context);
            var decoration = new DividerItemDecoration(Context, layout.Orientation);

            _categoryList.AddItemDecoration(decoration);
            _categoryList.SetLayoutManager(layout);

            _categoryAdapter            = new ChooseCategoriesAdapter(_categorySource);
            _categoryAdapter.ItemClick += _itemClick;

            _categoryList.SetAdapter(_categoryAdapter);
            _categoryList.HasFixedSize = true;
            _categoryList.SetItemViewCacheSize(20);

            var okButton = dialog.GetButton((int)DialogButtonType.Positive);

            okButton.Click += _onClose.Invoke;

            var emptyText = view.FindViewById <TextView>(Resource.Id.dialogChooseCategories_empty);

            if (_categorySource.Count() == 0)
            {
                emptyText.Visibility     = ViewStates.Visible;
                _categoryList.Visibility = ViewStates.Gone;
            }

            foreach (var category in _checkedCategories)
            {
                var index = _categorySource.Categories.FindIndex(c => c.Id == category);
                _categoryAdapter.CheckedStatus[index] = true;
            }

            return(dialog);
        }
Exemplo n.º 3
0
        private void OpenDeleteDialog(int position)
        {
            var builder = new AlertDialog.Builder(this);

            builder.SetMessage(Resource.String.confirmAuthenticatorDelete);
            builder.SetTitle(Resource.String.warning);
            builder.SetPositiveButton(Resource.String.delete, async(sender, args) =>
            {
                await _authSource.Delete(position);
                _authAdapter.NotifyItemRemoved(position);
                CheckEmptyState();
            });
            builder.SetNegativeButton(Resource.String.cancel, (sender, args) => { });
            builder.SetCancelable(true);

            var dialog = builder.Create();

            dialog.Show();
        }
        public override Android.App.Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            var alert = new AlertDialog.Builder(Activity);

            alert.SetTitle(Resource.String.changeIcon);

            alert.SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null);
            alert.SetCancelable(false);

            var view = Activity.LayoutInflater.Inflate(Resource.Layout.dialogChangeIcon, null);

            _searchText = view.FindViewById <EditText>(Resource.Id.editSearch);
            _iconList   = view.FindViewById <RecyclerView>(Resource.Id.list);
            alert.SetView(view);

            var dialog = alert.Create();

            dialog.Show();

            _searchText.TextChanged += OnSearchChanged;

            _iconListAdapter              = new IconListAdapter(Context, _iconSource);
            _iconListAdapter.ItemClick   += OnItemClick;
            _iconListAdapter.HasStableIds = true;

            _iconList.SetAdapter(_iconListAdapter);
            _iconList.HasFixedSize = true;
            _iconList.SetItemViewCacheSize(20);

            var layout = new FixedGridLayoutManager(Context, 6);

            _iconList.SetLayoutManager(layout);

            var cancelButton = dialog.GetButton((int)DialogButtonType.Negative);

            cancelButton.Click += (sender, e) =>
            {
                dialog.Dismiss();
            };

            return(dialog);
        }
        private void OnDeleteClick(object item, int position)
        {
            var builder = new AlertDialog.Builder(this);

            builder.SetMessage(Resource.String.confirmCategoryDelete);
            builder.SetTitle(Resource.String.warning);
            builder.SetCancelable(true);

            builder.SetPositiveButton(Resource.String.delete, async(sender, args) =>
            {
                await _categorySource.Delete(position);
                _categoryAdapter.NotifyItemRemoved(position);
                CheckEmptyState();
            });

            builder.SetNegativeButton(Resource.String.cancel, (sender, args) => { });

            var dialog = builder.Create();

            dialog.Show();
        }
Exemplo n.º 6
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            var alert = new AlertDialog.Builder(Activity);

            alert.SetTitle(Resource.String.changeIcon);

            alert.SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null);
            alert.SetCancelable(false);

            var view = Activity.LayoutInflater.Inflate(Resource.Layout.dialogIcon, null);

            _searchText = view.FindViewById <EditText>(Resource.Id.dialogIcon_search);
            _iconList   = view.FindViewById <RecyclerView>(Resource.Id.dialogIcon_list);
            alert.SetView(view);

            var dialog = alert.Create();

            dialog.Show();
            dialog.Window.SetSoftInputMode(SoftInput.StateAlwaysVisible);

            _searchText.TextChanged += SearchChanged;

            _iconAdapter            = new IconAdapter(Context, _iconSource);
            _iconAdapter.ItemClick += ItemClick;
            _iconAdapter.SetHasStableIds(true);

            _iconList.SetAdapter(_iconAdapter);
            _iconList.HasFixedSize = true;
            _iconList.SetItemViewCacheSize(20);

            var layout = new AuthListGridLayoutManager(Context, 6);

            _iconList.SetLayoutManager(layout);

            var cancelButton = dialog.GetButton((int)DialogButtonType.Negative);

            cancelButton.Click += _negativeButtonEvent.Invoke;

            return(dialog);
        }