Пример #1
0
        public override View OnCreateContentView()
        {
            // Get views
            View view = LayoutInflater.Inflate(Resource.Layout.Assistant, null);

            name         = view.FindViewById <TextView>(Resource.Id.Name);
            imageLayout  = view.FindViewById(Resource.Id.ImageLayout);
            image        = view.FindViewById <ImageView>(Resource.Id.Image);
            ivTable      = view.FindViewById <TableLayout>(Resource.Id.IVTable);
            arcFeedback  = view.FindViewById(Resource.Id.ArcFeedback);
            averageValue = view.FindViewById <TextView>(Resource.Id.AverageValue);

            attack  = view.FindViewById <CheckBox>(Resource.Id.textView14);
            defense = view.FindViewById <CheckBox>(Resource.Id.textView15);
            stamina = view.FindViewById <CheckBox>(Resource.Id.textView16);

            // Add listeners
            attack.Click  += (o, e) => { RefreshIVs(false); };
            defense.Click += (o, e) => { RefreshIVs(false); };
            stamina.Click += (o, e) => { RefreshIVs(false); };

            // Pokemon popup menu
            PopupMenu menu = new PopupMenu(image.Context, image);

            menu.MenuItemClick += (a, b) =>
            {
                int id = b.Item.ItemId;
                pokemon = Constants.Pokemons.First(p => p.Id == id);

                RefreshStats();
            };

            Task menuTask = Task.Run(() =>
            {
                foreach (PokemonInfo pokemon in Constants.Pokemons)
                {
                    menu.Menu.Add(1, pokemon.Id, pokemon.Id, pokemon.Id + " - " + pokemon.GetLocalizedName(Locale.Default.ToString()));
                }
            });

            #region Pokemon name

            image.Click += (s, e) =>
            {
                menuTask.Wait();
                menu.Show();
            };

            #endregion
            #region Pokemon level

            levelValue = view.FindViewById <TextView>(Resource.Id.LevelValue);
            levelSeek  = view.FindViewById <SeekBar>(Resource.Id.LevelSeek);

            levelSeek.ProgressChanged += LevelSeek_ProgressChanged;

            view.FindViewById(Resource.Id.LevelSeekLess).Click += (s, e) =>
            {
                if (levelSeek.Progress > 0)
                {
                    levelSeek.Progress--;
                }
            };
            view.FindViewById(Resource.Id.LevelSeekMore).Click += (s, e) =>
            {
                if (levelSeek.Progress < levelSeek.Max)
                {
                    levelSeek.Progress++;
                }
            };

            #endregion
            #region Pokemon CP

            cpValue = view.FindViewById <TextView>(Resource.Id.CPValue);
            cpSeek  = view.FindViewById <SeekBar>(Resource.Id.CPSeek);

            cpSeek.ProgressChanged += CPSeek_ProgressChanged;

            view.FindViewById(Resource.Id.CPSeekLess).Click += (s, e) =>
            {
                if (cpSeek.Progress > 0)
                {
                    cpSeek.Progress--;
                }
            };
            view.FindViewById(Resource.Id.CPSeekMore).Click += (s, e) =>
            {
                if (cpSeek.Progress < cpSeek.Max)
                {
                    cpSeek.Progress++;
                }
            };

            #endregion
            #region Pokemon HP

            hpValue = view.FindViewById <TextView>(Resource.Id.HPValue);
            hpSeek  = view.FindViewById <SeekBar>(Resource.Id.HPSeek);

            hpSeek.ProgressChanged += HPSeek_ProgressChanged;

            view.FindViewById(Resource.Id.HPSeekLess).Click += (s, e) =>
            {
                if (hpSeek.Progress > 0)
                {
                    hpSeek.Progress--;
                }
            };
            view.FindViewById(Resource.Id.HPSeekMore).Click += (s, e) =>
            {
                if (hpSeek.Progress < hpSeek.Max)
                {
                    hpSeek.Progress++;
                }
            };

            #endregion
            #region Player level

            playerLevelValue = view.FindViewById <TextView>(Resource.Id.PlayerLevelValue);
            playerLevelSeek  = view.FindViewById <SeekBar>(Resource.Id.PlayerLevelSeek);

            playerLevelSeek.ProgressChanged += PlayerLevelSeek_ProgressChanged;

            view.FindViewById(Resource.Id.PlayerLevelSeekLess).Click += (s, e) =>
            {
                if (playerLevelSeek.Progress > 0)
                {
                    playerLevelSeek.Progress--;
                }
            };
            view.FindViewById(Resource.Id.PlayerLevelSeekMore).Click += (s, e) =>
            {
                if (playerLevelSeek.Progress < playerLevelSeek.Max)
                {
                    playerLevelSeek.Progress++;
                }
            };

            #endregion

            // Handle transparent zone to hide
            emptyZone        = view.FindViewById(Resource.Id.EmptyZone);
            emptyZone.Click += (s, e) => Hide();

            // Adjust bottom margin according to navigation bar
            assistantLayout = view.FindViewById(Resource.Id.AssistantLayout);
            RelativeLayout.LayoutParams assistantLayoutParams = assistantLayout.LayoutParameters.JavaCast <RelativeLayout.LayoutParams>();

            int navigationBarHeight = 0;

            int navigationBarId = Context.Resources.GetIdentifier("navigation_bar_height", "dimen", "android");
            if (navigationBarId > 0)
            {
                navigationBarHeight = Context.Resources.GetDimensionPixelSize(navigationBarId);
            }

            assistantLayoutParams.BottomMargin = navigationBarHeight;

            return(view);
        }