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

            FairyListViewHolder vh = new FairyListViewHolder(view, OnClick);

            return(vh);
        }
Beispiel #2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            FairyListViewHolder vh = holder as FairyListViewHolder;

            var item = items[position];

            try
            {
                int TypeIconId = 0;
                switch (item.Type)
                {
                case string s when s == ETC.Resources.GetString(Resource.String.Common_FairyType_Combat):
                    TypeIconId = Resource.Drawable.Fairy_Combat;
                    break;

                case string s when s == ETC.Resources.GetString(Resource.String.Common_FairyType_Strategy):
                    TypeIconId = Resource.Drawable.Fairy_Strategy;
                    break;

                default:
                    TypeIconId = Resource.Drawable.Fairy_Combat;
                    break;
                }
                vh.TypeIcon.SetImageResource(TypeIconId);

                if (Preferences.Get("DBListImageShow", false))
                {
                    vh.SmallImage.Visibility = ViewStates.Visible;
                    string FilePath = System.IO.Path.Combine(ETC.cachePath, "Fairy", "Normal_Crop", $"{item.DicNumber}.gfdcache");
                    if (System.IO.File.Exists(FilePath) == true)
                    {
                        vh.SmallImage.SetImageDrawable(Android.Graphics.Drawables.Drawable.CreateFromPath(FilePath));
                    }
                }
                else
                {
                    vh.SmallImage.Visibility = ViewStates.Gone;
                }

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