Example #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = base.OnCreateView(inflater, container, savedInstanceState);

            SetupToolbar(view, Resource.String.changeIcon, true);

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

            _searchText.TextChanged += OnSearchChanged;

            var customIconButton = view.FindViewById <MaterialButton>(Resource.Id.buttonUseCustomIcon);

            customIconButton.Click += (s, e) =>
            {
                UseCustomIconClick?.Invoke(s, e);
                Dismiss();
            };

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

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

            var layout = new AutoGridLayoutManager(Context, 140);

            _iconList.SetLayoutManager(layout);

            return(view);
        }
Example #2
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)
            {
                HasStableIds = true
            };

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

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

            _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);
        }
        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);
        }