예제 #1
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            if (id == Resource.Id.nav_camera)
            {
                // Handle the camera action
            }
            else if (id == Resource.Id.nav_gallery)
            {
                var storageStatsManager = (StorageStatsManager)BaseContext.GetSystemService(Context.StorageStatsService);
                RunOnUiThread(async() =>
                {
                    try
                    {
                        var apps      = await new AppsService().GetInstalledApps(PackageManager, storageStatsManager);
                        _adapter      = new AppsAdapter(this, apps);
                        _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);
                        _recyclerView.SetAdapter(_adapter);
                        _layoutManager = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false);
                        _recyclerView.SetLayoutManager(_layoutManager);
                    }
                    catch (Exception ex)
                    {
                    }
                });
            }
            else if (id == Resource.Id.nav_slideshow)
            {
            }
            else if (id == Resource.Id.nav_manage)
            {
            }
            else if (id == Resource.Id.nav_share)
            {
            }
            else if (id == Resource.Id.nav_send)
            {
            }

            DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            drawer.CloseDrawer(GravityCompat.Start);
            return(true);
        }
예제 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            Console.WriteLine ("Is Amazon FireTV: " + Settings.IsFireTV ());

            RequestWindowFeature (WindowFeatures.NoTitle);
            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            textDate = FindViewById<TextView> (Resource.Id.textViewDate);
            textTime = FindViewById<TextView> (Resource.Id.textViewTime);
            gridView = FindViewById<GridView> (Resource.Id.gridView);
            frameTopBar = FindViewById<FrameLayout> (Resource.Id.frameTopBar);
            wallpaper = FindViewById<ImageView> (Resource.Id.imageWallpaper);

            StartService (new Intent (this, typeof(ExcuseMeService)));

            adapter = new AppsAdapter () { Context = this };

            gridViewTopPadding = gridView.PaddingTop;

            gridView.ItemClick += (sender, e) => {

                var app = adapter[e.Position];

                // If we're launching home, tell the service that checks
                // for intercepting this that it's ok
                if (app.PackageName == Settings.HOME_PACKAGE_NAME)
                    ExcuseMeService.AllowFireTVHome = true;

                if (app.PackageName == "APP_SETTINGS") {
                    StartActivity (typeof(SettingsActivity));
                    return;
                }

                StartActivity (app.LaunchIntent);

                if (app.PackageName == Android.Provider.Settings.ActionSettings)
                    Toast.MakeText (this, "You may need to press 'UP' on your remote", ToastLength.Long).Show ();
            };

            gridView.Adapter = adapter;

            timerUpdate = new Timer (state => Setup (true), null, Timeout.Infinite, Timeout.Infinite);

            RegisterForContextMenu (gridView);
        }