Ejemplo n.º 1
0
        private void InitAuthenticatorList()
        {
            var viewModePref = PreferenceManager.GetDefaultSharedPreferences(this)
                               .GetString("pref_viewMode", "default");

            var viewMode = viewModePref switch
            {
                "compact" => AuthenticatorListAdapter.ViewMode.Compact,
                "tile" => AuthenticatorListAdapter.ViewMode.Tile,
                _ => AuthenticatorListAdapter.ViewMode.Default
            };

            _authListAdapter = new AuthenticatorListAdapter(_authSource, _customIconSource, viewMode, IsDark);

            _authListAdapter.ItemClick       += OnAuthenticatorClick;
            _authListAdapter.MenuClick       += OnAuthenticatorOptionsClick;
            _authListAdapter.MovementStarted += delegate
            {
                _bottomAppBar.PerformHide();
            };

            _authListAdapter.MovementFinished += async delegate
            {
                _bottomAppBar.PerformShow();
                await NotifyWearAppOfChange();
            };

            _authListAdapter.HasStableIds = true;

            _authList.SetAdapter(_authListAdapter);

            var minColumnWidth = viewMode switch
            {
                AuthenticatorListAdapter.ViewMode.Compact => 300,
                AuthenticatorListAdapter.ViewMode.Tile => 170,
                _ => 340
            };

            var layout = new AutoGridLayoutManager(this, minColumnWidth);

            _authList.SetLayoutManager(layout);

            _authList.AddItemDecoration(new GridSpacingItemDecoration(this, layout, 8));
            _authList.HasFixedSize = true;

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

            _authList.LayoutAnimation = animation;

            var callback    = new ReorderableListTouchHelperCallback(_authListAdapter, layout);
            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(_authList);
        }
Ejemplo n.º 2
0
        private void InitAuthenticatorList()
        {
            var isCompact = PreferenceManager.GetDefaultSharedPreferences(this)
                            .GetBoolean("pref_compactMode", false);

            _authenticatorListAdapter = new AuthenticatorListAdapter(_authenticatorSource, IsDark, isCompact);

            _authenticatorListAdapter.ItemClick       += OnAuthenticatorClick;
            _authenticatorListAdapter.MenuClick       += OnAuthenticatorOptionsClick;
            _authenticatorListAdapter.MovementStarted += (sender, i) =>
            {
                _bottomAppBar.PerformHide();
            };
            _authenticatorListAdapter.MovementFinished += async(sender, i) =>
            {
                _bottomAppBar.PerformShow();
                await NotifyWearAppOfChange();
            };

            _authenticatorListAdapter.HasStableIds = true;

            _authList.SetAdapter(_authenticatorListAdapter);

            var layout = new AutoGridLayoutManager(this, 340);

            _authList.SetLayoutManager(layout);

            _authList.AddItemDecoration(new GridSpacingItemDecoration(this, layout, 8));
            _authList.HasFixedSize = true;

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

            _authList.LayoutAnimation = animation;

            var callback    = new ReorderableListTouchHelperCallback(_authenticatorListAdapter, layout);
            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(_authList);
        }