Пример #1
0
        private void SetRecyclerViewAdapters()
        {
            try
            {
                MAdapter = new GamesAdapter(Activity)
                {
                    GamesList = new ObservableCollection <GamesDataObject>()
                };
                MAdapter.ItemClick += MAdapterOnItemClick;
                LayoutManager       = new GridLayoutManager(Context, 2);
                LayoutManager.SetSpanSizeLookup(new MySpanSizeLookup(4, 1, 1)); //5, 1, 2
                MRecycler.SetLayoutManager(LayoutManager);
                var sizeProvider = new FixedPreloadSizeProvider(10, 10);
                var preLoader    = new RecyclerViewPreloader <GamesDataObject>(Activity, MAdapter, sizeProvider, 10 /*maxPreload*/);
                MRecycler.AddOnScrollListener(preLoader);
                MRecycler.SetAdapter(MAdapter);
                MRecycler.HasFixedSize = true;
                MRecycler.SetItemViewCacheSize(10);
                MRecycler.GetLayoutManager().ItemPrefetchEnabled = true;

                RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(LayoutManager);
                MainScrollEvent = xamarinRecyclerViewOnScrollListener;
                MainScrollEvent.LoadMoreEvent += LoadMoreEventOnLoadMoreGames;
                MRecycler.AddOnScrollListener(xamarinRecyclerViewOnScrollListener);
                MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            Button   buscarjuego = FindViewById <Button>(Resource.Id.buttonBuscar);
            EditText nombrejuego = FindViewById <EditText>(Resource.Id.editTextGame);
            ListView lista       = FindViewById <ListView>(Resource.Id.listViewGames);

            progress = new Android.App.ProgressDialog(this);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetMessage("Espere...");
            progress.SetCancelable(false);

            buscarjuego.Click += async delegate
            {
                progress.Show();
                listajuegos = await serviceclient.GetGamesAsync(nombrejuego.Text);

                if (listajuegos.Count > 0)
                {
                    adapter       = new GamesAdapter(this, listajuegos, Resource.Layout.listview_item, Resource.Id.textViewGameName, Resource.Id.textViewIdGame, Resource.Id.imageViewGame);
                    lista.Adapter = adapter;
                    progress.Hide();
                }
                else
                {
                    Toast.MakeText(this, "Error", ToastLength.Long).Show();
                    progress.Hide();
                }
            };

            lista.ItemClick += Lista_ItemClick;
        }
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                RequestWindowFeature(WindowFeatures.NoTitle);

                base.OnCreate(bundle);
                LoggerMobile.Instance.logMessage("Opening GamesActivity", LoggerEnum.message);
                SetContentView(Resource.Layout.PublicGames);
                LegacyBar = FindViewById<LegacyBar.Library.Bar.LegacyBar>(Resource.Id.actionbar);
                LegacyBar.SeparatorColor = Color.Purple;

                AddHomeAction(typeof(Main), Resource.Drawable.icon);
                // Get our button from the layout resource,
                // and attach an event to it

                LegacyBar.ProgressBarVisibility = ViewStates.Visible;
                //currentGamesList = FindViewById<ListView>(Resource.Id.currentGamesList);
                pastGamesList = FindViewById<ListView>(Resource.Id.pastGamesList);
                LegacyBarAction loginAction = new RefreshAction(this, null, Resource.Drawable.ic_action_refresh, this);
                LegacyBar.AddAction(loginAction);

                initialPastArray = new GamesJson();
                //initialCurrentArray = new GamesJson();
                Action pullMorePast = new Action(PullMorePast);
                //Action pullCurrent = new Action(PullMorePast);

                PastGamesAdapter = new GamesAdapter(this, initialPastArray.Games, pullMorePast);
                //CurrentGamesAdapter = new GamesAdapter(this, initialCurrentArray.Games, null);

                //currentGamesList.Adapter = CurrentGamesAdapter;
                pastGamesList.Adapter = PastGamesAdapter;
                Game.PullCurrentGames(this, UpdateCurrentAdapter);
                Game.PullPastGames(PAGE_COUNT, lastPagePulled, this, UpdatePastAdapter);

                //currentGamesList.ItemClick += currentGamesList_ItemClick;
                pastGamesList.ItemClick += pastGamesList_ItemClick;
                var myString = new SpannableStringBuilder("lol");
                Selection.SelectAll(myString); // needs selection or Index Out of bounds

                LegacyBarAction infoAction = new DefaultLegacyBarAction(this, CreateInfoIntent(), Resource.Drawable.action_about);
                LegacyBar.AddAction(infoAction);

                m_AdView = FindViewById(Resource.Id.adView);
                if (SettingsMobile.Instance.User != null && SettingsMobile.Instance.User.IsValidSub)
                {
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.Android, (Context)this);
            }
        }