Ejemplo n.º 1
0
        public override async void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            switch (holder.ItemViewType)
            {
            case homeTop:
                HomeTopViewHolder vh = holder as HomeTopViewHolder;
                //vh2.totalInspire.Text = vh2.totalInspire.Text.Replace("xx", contentCollection[position].ToString());
                break;

            case gradeBox:
                GradeBoxViewHolder vh2 = holder as GradeBoxViewHolder;
                break;

            case subject:
                SubjectViewHolder vh3         = holder as SubjectViewHolder;
                List <Subject>    subjectList = contentCollection[position] as List <Subject>;

                #region Constructing the subject buttons
                foreach (Subject subject in subjectList)
                {
                    Button _subjectBtn  = new Button(mContext);
                    var    layoutParams = new FlexboxLayout.LayoutParams(0, FlexboxLayout.LayoutParams.WrapContent);
                    layoutParams.TopMargin        = ValueConverter.DpToPx(10);
                    layoutParams.FlexBasisPercent = 0.33F;
                    layoutParams.Order            = 2;
                    _subjectBtn.LayoutParameters  = layoutParams;
                    _subjectBtn.SetPadding(0, ValueConverter.DpToPx(10), 0, 0);
                    _subjectBtn.SetBackgroundColor(Color.Transparent);
                    _subjectBtn.Text = subject.Title;
                    _subjectBtn.SetCompoundDrawablesWithIntrinsicBounds(0, subject.IconId, 0, 0);

                    SubjectClick clickAndFocus = new SubjectClick();
                    _subjectBtn.SetOnClickListener(clickAndFocus);
                    _subjectBtn.OnFocusChangeListener = clickAndFocus;

                    vh3.flexLayout.AddView(_subjectBtn);
                }
                #region Adding smart tutor btn
                //View smartTutorBtn = LayoutInflater.From(mContext).Inflate(Resource.Layout.customview_smartTutorButton, vh3.flexLayout, false);
                //var smartTutorParams = new FlexboxLayout.LayoutParams(0, FlexboxLayout.LayoutParams.WrapContent);
                //smartTutorParams.TopMargin = ValueConverter.DpToPx(10);
                //smartTutorParams.FlexBasisPercent = 0.63F;
                //smartTutorParams.Order = 2;
                //smartTutorBtn.LayoutParameters = smartTutorParams;
                //vh3.flexLayout.AddView(smartTutorBtn);
                #endregion
                #endregion
                break;

            case banner:
                BannerViewHolder vh4 = holder as BannerViewHolder;
                break;
            }
        }
Ejemplo n.º 2
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            RecyclerView.ViewHolder vh = null;
            switch (viewType)
            {
            case homeTop:
                vh = new HomeTopViewHolder(LayoutInflater.From(parent.Context).Inflate(Resource.Layout.customview_homeTop, parent, false));
                break;

            case gradeBox:
                vh = new GradeBoxViewHolder(LayoutInflater.From(parent.Context).Inflate(Resource.Layout.customview_gradeButton, parent, false));
                break;

            case subject:
                SubjectViewHolder viewHolder = new SubjectViewHolder(LayoutInflater.From(parent.Context).Inflate(Resource.Layout.container_flexBox, parent, false));
                vh = viewHolder;
                break;

            case banner:
                vh = new BannerViewHolder(LayoutInflater.From(parent.Context).Inflate(Resource.Layout.customview_banner, parent, false));
                break;
            }
            return(vh);
        }