Exemplo n.º 1
0
        private void InitAuthenticators()
        {
            _authSource = new AuthSource(_connection);

            var isCompact = _sharedPrefs.GetBoolean("pref_compactMode", false);

            _authAdapter = new AuthAdapter(_authSource, IsDark, isCompact);

            _authAdapter.ItemClick        += ItemClick;
            _authAdapter.ItemOptionsClick += ItemOptionsClick;
            _authAdapter.SetHasStableIds(true);

            _authList.SetAdapter(_authAdapter);
            _authList.HasFixedSize = true;
            _authList.SetItemViewCacheSize(20);

            var animation =
                AnimationUtils.LoadLayoutAnimation(this, Resource.Animation.layout_animation_fall_down);

            _authList.LayoutAnimation = animation;

            var useGrid = IsTablet();
            var layout  = new AuthListGridLayoutManager(this, useGrid ? 2 : 1);

            _authList.SetLayoutManager(layout);

            var callback    = new AuthListTouchHelperCallback(_authAdapter, useGrid);
            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(_authList);
        }
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activityEditCategories);

            var toolbar     = FindViewById <Toolbar>(Resource.Id.activityEditCategories_toolbar);
            var progressBar = FindViewById <ProgressBar>(Resource.Id.activityEditCategories_progressBar);

            SetSupportActionBar(toolbar);

            SupportActionBar.SetTitle(Resource.String.editCategories);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_action_arrow_back);

            _addButton        = FindViewById <FloatingActionButton>(Resource.Id.activityEditCategories_buttonAdd);
            _addButton.Click += OnAddClick;

            _connection = await Database.Connect(this);

            _categorySource               = new CategorySource(_connection);
            _categoryAdapter              = new CategoryAdapter(_categorySource);
            _categoryAdapter.RenameClick += OnRenameClick;
            _categoryAdapter.DeleteClick += OnDeleteClick;

            _categoryList = FindViewById <RecyclerView>(Resource.Id.activityEditCategories_list);
            _emptyState   = FindViewById <LinearLayout>(Resource.Id.activityEditCategories_emptyState);

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

            var callback    = new AuthListTouchHelperCallback(_categoryAdapter);
            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(_categoryList);

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

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

            var layoutAnimation =
                AnimationUtils.LoadLayoutAnimation(this, Resource.Animation.layout_animation_fade_in);

            _categoryList.LayoutAnimation = layoutAnimation;

            await _categorySource.UpdateTask;

            CheckEmptyState();
            _categoryAdapter.NotifyDataSetChanged();
            _categoryList.ScheduleLayoutAnimation();

            var alphaAnimation = new AlphaAnimation(1.0f, 0.0f)
            {
                Duration = 200
            };

            alphaAnimation.AnimationEnd += (sender, e) => { progressBar.Visibility = ViewStates.Gone; };
            progressBar.StartAnimation(alphaAnimation);
        }