Example #1
0
        private void InitViews()
        {
            _loadingLayout = FindViewById <RelativeLayout>(Resource.Id.layoutLoading);
            _emptyLayout   = FindViewById <RelativeLayout>(Resource.Id.layoutEmpty);
            _offlineLayout = FindViewById <LinearLayout>(Resource.Id.layoutOffline);

            _authList = FindViewById <WearableRecyclerView>(Resource.Id.list);
            _authList.EdgeItemsCenteringEnabled = true;
            _authList.HasFixedSize = true;
            _authList.SetItemViewCacheSize(12);
            _authList.SetItemAnimator(null);

            var layoutCallback = new AuthenticatorListLayoutCallback(this);

            _authList.SetLayoutManager(new WearableLinearLayoutManager(this, layoutCallback));

            _authListAdapter              = new AuthenticatorListAdapter(_authSource, _customIconCache);
            _authListAdapter.ItemClick   += OnItemClick;
            _authListAdapter.HasStableIds = true;
            _authList.SetAdapter(_authListAdapter);

            var categoriesDrawer = FindViewById <WearableNavigationDrawerView>(Resource.Id.drawerCategories);

            _categoryListAdapter = new CategoryListAdapter(this, _categoryCache);
            categoriesDrawer.SetAdapter(_categoryListAdapter);
            categoriesDrawer.ItemSelected += OnCategorySelected;
        }
Example #2
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activityMain);

            try
            {
                await WearableClass.GetMessageClient(this).AddListenerAsync(this);
                await FindServerNode();
            }
            catch (ApiException) { }

            _loadingLayout = FindViewById <RelativeLayout>(Resource.Id.layoutLoading);
            _emptyLayout   = FindViewById <RelativeLayout>(Resource.Id.layoutEmpty);
            _offlineLayout = FindViewById <LinearLayout>(Resource.Id.layoutOffline);

            _authList = FindViewById <WearableRecyclerView>(Resource.Id.list);
            _authList.EdgeItemsCenteringEnabled = true;
            _authList.HasFixedSize = true;
            _authList.SetItemViewCacheSize(12);
            _authList.SetItemAnimator(null);

            var layoutCallback = new AuthenticatorListLayoutCallback(this);

            _authList.SetLayoutManager(new WearableLinearLayoutManager(this, layoutCallback));

            _authCache       = new ListCache <WearAuthenticator>("authenticators", this);
            _categoryCache   = new ListCache <WearCategory>("categories", this);
            _customIconCache = new CustomIconCache(this);

            await _authCache.Init();

            _authSource = new AuthenticatorSource(_authCache);

            _authListAdapter              = new AuthenticatorListAdapter(_authSource, _customIconCache);
            _authListAdapter.ItemClick   += OnItemClick;
            _authListAdapter.HasStableIds = true;
            _authList.SetAdapter(_authListAdapter);

            if (_authCache.GetItems().Count > 0 || _serverNode == null)
            {
                UpdateViewState();
            }

            await _categoryCache.Init();

            var categoriesDrawer = FindViewById <WearableNavigationDrawerView>(Resource.Id.drawerCategories);

            _categoryListAdapter = new CategoryListAdapter(this, _categoryCache);
            categoriesDrawer.SetAdapter(_categoryListAdapter);
            categoriesDrawer.ItemSelected += OnCategorySelected;

            await Refresh();
        }
        private void InitViews()
        {
            _loadingLayout = FindViewById <RelativeLayout>(Resource.Id.layoutLoading);
            _emptyLayout   = FindViewById <RelativeLayout>(Resource.Id.layoutEmpty);
            _offlineLayout = FindViewById <LinearLayout>(Resource.Id.layoutOffline);

            _authList = FindViewById <WearableRecyclerView>(Resource.Id.list);
            _authList.EdgeItemsCenteringEnabled = true;
            _authList.HasFixedSize = true;
            _authList.SetItemViewCacheSize(12);
            _authList.SetItemAnimator(null);

            var layoutCallback = new AuthenticatorListLayoutCallback(this);

            _authList.SetLayoutManager(new WearableLinearLayoutManager(this, layoutCallback));

            _authListAdapter                = new AuthenticatorListAdapter(_authSource, _customIconCache);
            _authListAdapter.ItemClick     += OnItemClick;
            _authListAdapter.ItemLongClick += OnItemLongClick;
            _authListAdapter.HasStableIds   = true;
            _authListAdapter.DefaultAuth    = _preferences.DefaultAuth;
            _authList.SetAdapter(_authListAdapter);

            _categoryList        = FindViewById <WearableNavigationDrawerView>(Resource.Id.drawerCategories);
            _categoryListAdapter = new CategoryListAdapter(this, _categoryCache);
            _categoryList.SetAdapter(_categoryListAdapter);
            _categoryList.ItemSelected += OnCategorySelected;

            if (_authSource.CategoryId == null)
            {
                return;
            }

            var categoryPosition = _categoryCache.FindIndex(c => c.Id == _authSource.CategoryId) + 1;

            if (categoryPosition <= -1)
            {
                return;
            }

            _preventCategorySelectEvent = true;
            _categoryList.SetCurrentItem(categoryPosition, false);
        }