public UpgradeGoProAdapter(Activity context)
        {
            try
            {
                ActivityContext = context;
                WoTextDecorator = new WoTextDecorator();

                //PlansList.Add(new UpgradeGoProClass { Id = 1, HexColor = "#4c7737", PlanText = Resource.String.go_pro_plan_1,PlanTime="",PlanPrice="" ImageResource = Resource.Drawable.gopro_medal });
                //<item>STAR</item>
                //<item>$3</item>
                //<item>Per Week</item>
                //<item>#4c7737</item>

                switch (ListUtils.SettingsSiteList?.ProPackagesTypes?.Count)
                {
                case > 0:
                {
                    foreach (var type in ListUtils.SettingsSiteList?.ProPackagesTypes)    //"1": "star"
                    {
                        var resourceId = ActivityContext.Resources?.GetIdentifier("ic_plan_" + type.Key, "drawable", ActivityContext.PackageName) ?? 0;
                        switch (resourceId)
                        {
                        case 0:
                            continue;

                        default:
                        {
                            var proClass = new UpgradeGoProClass
                            {
                                Id            = type.Key,
                                HexColor      = GetColor(type.Key),
                                PlanText      = type.Value,
                                PlanPrice     = GetPrice(type.Value),
                                PlanTime      = GetTime(type.Value),
                                PlanArray     = GetPlanArray(type.Value),
                                ImageResource = resourceId,
                            };

                            PlansList.Add(proClass);
                            break;
                        }
                        }
                    }

                    break;
                }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #2
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is UpgradePlansViewHolder holder)
                {
                    UpgradeGoProClass item = PlansList[position];
                    if (item != null)
                    {
                        if (AppSettings.SetTabDarkTheme)
                        {
                            holder.MainLayout.SetBackgroundResource(Resource.Drawable.ShadowLinerLayoutDark);
                            holder.RelativeLayout.SetBackgroundResource(Resource.Drawable.price_gopro_item_style_dark);
                        }

                        holder.PlanImg.SetImageResource(item.ImageResource);
                        holder.PlanImg.SetColorFilter(Color.ParseColor(item.HexColor));

                        var(currency, currencyIcon) = WoWonderTools.GetCurrency(ListUtils.SettingsSiteList?.Currency);
                        Console.WriteLine(currency);
                        if (ListUtils.SettingsSiteList != null)
                        {
                            holder.PriceText.Text = currencyIcon + item.PlanPrice;
                        }
                        else
                        {
                            holder.PriceText.Text = item.PlanPrice;
                        }

                        holder.PlanText.Text = item.PlanText;
                        holder.PerText.Text  = item.PlanTime;

                        holder.PlanText.SetTextColor(Color.ParseColor(item.HexColor));
                        holder.PriceText.SetTextColor(Color.ParseColor(item.HexColor));
                        holder.UpgradeButton.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor(item.HexColor));

                        Typeface font = Typeface.CreateFromAsset(Application.Context.Resources?.Assets, "ionicons.ttf");

                        string name       = "go_pro_array_" + item.Id;
                        int?   resourceId = ActivityContext.Resources?.GetIdentifier(name, "array", ActivityContext.ApplicationInfo.PackageName);
                        if (resourceId == 0)
                        {
                            return;
                        }

                        string[] planArray = ActivityContext.Resources?.GetStringArray(resourceId.Value);
                        if (planArray != null)
                        {
                            foreach (string options in planArray)
                            {
                                if (!string.IsNullOrEmpty(options))
                                {
                                    AppCompatTextView text = new AppCompatTextView(ActivityContext)
                                    {
                                        Text     = options,
                                        TextSize = 13
                                    };

                                    text.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.ParseColor("#444444"));
                                    text.Gravity = GravityFlags.CenterHorizontal;
                                    text.SetTypeface(font, TypefaceStyle.Normal);
                                    WoTextDecorator.Content          = options;
                                    WoTextDecorator.DecoratedContent = new Android.Text.SpannableString(options);
                                    WoTextDecorator.SetTextColor(IonIconsFonts.Checkmark, "#43a735");
                                    WoTextDecorator.SetTextColor(IonIconsFonts.Close, "#e13c4c");

                                    LinearLayout.LayoutParams paramsss = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);//height and width are inpixel
                                    paramsss.SetMargins(0, 30, 0, 5);

                                    text.LayoutParameters = paramsss;
                                    holder.OptionLinerLayout.AddView(text);
                                    WoTextDecorator.Build(text, WoTextDecorator.DecoratedContent);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }