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;
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            mWearableActionDrawer = FindViewById <WearableActionDrawerView>(Resource.Id.bottom_action_drawer);
            mWearableActionDrawer.SetOnMenuItemClickListener(this);
            mWearableActionDrawer.PeekOnScrollDownEnabled = true;

            mWearableNavigationDrawer = FindViewById <WearableNavigationDrawerView>(Resource.Id.top_nav_drawer);
            mWearableNavigationDrawer.AddOnItemSelectedListener(this);
            mWearableNavigationDrawer.PeekOnScrollDownEnabled = true;
            mNavDrawerAdapter = new NavDrawerAdapter(this);
            mWearableNavigationDrawer.SetAdapter(mNavDrawerAdapter);

            mBroadcastReceiver = new LocalBroadcastReceiver();
            mBroadcastReceiver.BroadcastReceived += (context, intent) =>
            {
                if (WearableDataListenerService.ACTION_SHOWSTORELISTING.Equals(intent?.Action))
                {
                    var intentAndroid = new Intent(Intent.ActionView)
                                        .AddCategory(Intent.CategoryBrowsable)
                                        .SetData(WearableHelper.PlayStoreURI);

                    RemoteIntent.StartRemoteActivity(this, intentAndroid,
                                                     new ConfirmationResultReceiver(this));
                }
                else if (WearableDataListenerService.ACTION_OPENONPHONE.Equals(intent?.Action))
                {
                    bool success = (bool)intent?.GetBooleanExtra(WearableDataListenerService.EXTRA_SUCCESS, false);

                    new ConfirmationOverlay()
                    .SetType(success ? ConfirmationOverlay.OpenOnPhoneAnimation : ConfirmationOverlay.FailureAnimation)
                    .ShowOn(this);
                }
            };
            var filter = new IntentFilter();

            filter.AddAction(WearableDataListenerService.ACTION_SHOWSTORELISTING);
            filter.AddAction(WearableDataListenerService.ACTION_OPENONPHONE);
            LocalBroadcastManager.GetInstance(this).RegisterReceiver(mBroadcastReceiver, filter);

            // Create your application here
            Fragment fragment = FragmentManager.FindFragmentById(Resource.Id.fragment_container);

            // Check if fragment exists
            if (fragment == null)
            {
                fragment = new WeatherNowFragment();

                // Navigate to WeatherNowFragment
                FragmentManager.BeginTransaction()
                .Replace(Resource.Id.fragment_container, fragment, "home")
                .Commit();
            }
        }
        private void InitViews()
        {
            _circularProgressLayout = FindViewById <CircularProgressLayout>(Resource.Id.layoutCircularProgress);
            _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(_authView, _customIconCache);
            _authListAdapter.ItemClicked     += OnItemClicked;
            _authListAdapter.ItemLongClicked += OnItemLongClicked;
            _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 (_authView.CategoryId == null)
            {
                return;
            }

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

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

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