Пример #1
0
 // Load the adapter with the data set (photo album) at construction time:
 public PhotoAlbumAdapter(PhotoAlbum photoAlbum)
 {
     mPhotoAlbum = photoAlbum;
 }
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Instantiate the photo album:
            mPhotoAlbum = new PhotoAlbum();

            // Set our view from the "main" layout resource:
            SetContentView(Resource.Layout.Main);
            interstitialAds = new InterstitialAd(this);
            mAdView         = FindViewById <AdView>(Resource.Id.adView);
            var adRequest = new AdRequest.Builder().Build();

            mAdView.LoadAd(adRequest);

            interstitialAds.AdUnitId = "ca-app-pub-1120846610061033/5377390906";
            // loading test ad using adrequest
            interstitialAds.LoadAd(adRequest);

            interstitialAds.AdListener = new AdListener(this);


            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "BEST TIPSTARS";

            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);


            myfab = FindViewById <FloatingActionButton>(Resource.Id.fab);


            // Get our RecyclerView layout:
            mRecyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            //............................................................
            // Layout Manager Setup:

            // Use the built-in linear layout manager:
            mLayoutManager = new LinearLayoutManager(this);


            // Or use the built-in grid layout manager (two horizontal rows):
            // mLayoutManager = new GridLayoutManager
            //        (this, 2, GridLayoutManager.Horizontal, false);

            // Plug the layout manager into the RecyclerView:
            mRecyclerView.SetLayoutManager(mLayoutManager);

            myswipeRefresh = FindViewById <SwipeRefreshLayout>(Resource.Id.refresher);
            myswipeRefresh.SetColorScheme(Resource.Color.Red, Resource.Color.Orange,
                                          Resource.Color.Yellow, Resource.Color.Green,
                                          Resource.Color.Blue, Resource.Color.Indigo,
                                          Resource.Color.Violet);
            myswipeRefresh.Refresh += MyswipeRefresh_Refresh;

            //............................................................
            // Adapter Setup:

            // Create an adapter for the RecyclerView, and pass it the
            // data set (the photo album) to manage:
            mAdapter = new PhotoAlbumAdapter(mPhotoAlbum);

            // Register the item click handler (below) with the adapter:
            mAdapter.ItemClick += OnItemClick;

            // Plug the adapter into the RecyclerView:
            mRecyclerView.SetAdapter(mAdapter);

            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);
                Intent intent = null;
                switch (e.MenuItem.ItemId)
                {
                case
                    Resource.Id.nav_about:
                    intent = new Intent(this, typeof(About));
                    break;

                case
                    Resource.Id.nav_share:
                    intent = new Intent(Intent.ActionSend);
                    intent.SetType("text/plain");
                    intent.PutExtra(Intent.ExtraText, "https://play.google.com/store/apps/details?id=com.hamsempire.bestpredictions");
                    break;
                }
                if (intent != null)
                {
                    StartActivity(intent);
                }
                drawerLayout.CloseDrawers();
            };


            myfab.Click += async delegate(object sender, EventArgs e)
            {
                myswipeRefresh.Refreshing = true;
                await Task.Delay(5000);

                myswipeRefresh.Refreshing = false;
            };
        }