コード例 #1
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View view = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.EnemyListLayout, parent, false);

            EnemyListViewHolder vh = new EnemyListViewHolder(view, OnClick);

            return(vh);
        }
コード例 #2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            EnemyListViewHolder vh = holder as EnemyListViewHolder;

            var item = items[position];

            try
            {
                int    typeIconId = 0;
                string enemyType  = "";

                switch (item.IsBoss)
                {
                default:
                case false:
                    typeIconId = Resource.Drawable.Grade_N;
                    enemyType  = "NM";
                    break;

                case true:
                    typeIconId = Resource.Drawable.Grade_S;
                    enemyType  = "Boss";
                    break;
                }
                //vh.TypeIcon.SetImageResource(typeIconId);

                vh.Type.Text = enemyType;

                if (Preferences.Get("DBListImageShow", false))
                {
                    vh.SmallImage.Visibility = ViewStates.Visible;
                    string filePath = Path.Combine(ETC.cachePath, "Enemy", "Normal_Crop", $"{item.CodeName}.gfdcache");

                    if (File.Exists(filePath))
                    {
                        vh.SmallImage.SetImageDrawable(Android.Graphics.Drawables.Drawable.CreateFromPath(filePath));
                    }
                }
                else
                {
                    vh.SmallImage.Visibility = ViewStates.Gone;
                }

                int affiliationIconId = 0;

                affiliationIconId = item.Affiliation switch
                {
                    "SANGVIS FERRI" => Resource.Drawable.SFLogo,
                    "Mind Map System" => Resource.Drawable.IOPLogo,
                    "KCCO" => Resource.Drawable.KCCOLogo,
                    "Paradeus" => Resource.Drawable.ParadeusLogo,
                    "E.L.I.D." => Resource.Drawable.ELIDLogo,
                    _ => Resource.Drawable.IOPLogo,
                };
                vh.AffiliationImage.SetImageResource(affiliationIconId);

                vh.Name.Text        = item.Name;
                vh.CodeName.Text    = item.CodeName;
                vh.Affiliation.Text = item.Affiliation;
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, context);
                Toast.MakeText(context, "Error Create View", ToastLength.Short).Show();
            }
        }