private int GetLastVisibleItem(RecyclerView.LayoutManager layoutManager) { if (layoutManager is StaggeredGridLayoutManager) return (layoutManager as StaggeredGridLayoutManager).FindLastVisibleItemPositions(null).Max(); if (layoutManager is LinearLayoutManager) return (layoutManager as LinearLayoutManager).FindLastVisibleItemPosition(); if (layoutManager is GridLayoutManager) return (layoutManager as GridLayoutManager).FindLastVisibleItemPosition(); throw new InvalidOperationException($"Can't find last item from {layoutManager.GetType().Name}"); }
public override void OnBindViewHolder (RecyclerView.ViewHolder holder, int position) { if (holder.GetType () == typeof(MyHealth_BodyWeight_ViewHolder)) { MyHealth_BodyWeight_ViewHolder vh = holder as MyHealth_BodyWeight_ViewHolder; vh.tvMHBWCLIDateTime.Text = mData [position].mDateTime; vh.tvMHBWCLIWeight.Text = mData [position].mWeight; vh.tvMHBWCLINettWeight.Text = mData [position].mNettWeight; vh.tvMHBWCLIBMI.Text = mData [position].mBMI; vh.tvMHBWCLIBoneMass.Text = mData [position].mBoneMass; vh.tvMHBWCLIFat.Text = mData [position].mFat; } }
public override void OnBindViewHolder (RecyclerView.ViewHolder holder, int position) { if (holder.GetType () == typeof(MySoal_PetiMasuk_ViewHolder)) { MySoal_PetiMasuk_ViewHolder vh = holder as MySoal_PetiMasuk_ViewHolder; vh.tvTitle.Text = mData [position].title; vh.tvContent.Text = mData [position].content; } //vh.IVLike.SetImageResource (mData[position].like); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var unused = new RecyclerView(this); var asd = unused.GetType().Name; SetContentView(Resource.Layout.activity_main); RecyclerView recyclerView = FindViewById <RecyclerView>(Resource.Id.recycler_view); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); recyclerView.SetLayoutManager(layoutManager); MainListAdapter mainListAdapter = new MainListAdapter(getMealList()); recyclerView.SetAdapter(mainListAdapter); }
public override void OnBindViewHolder (RecyclerView.ViewHolder holder, int position) { if (holder.GetType () == typeof(MyVote_ViewHolder)) { var vh = holder as MyVote_ViewHolder; string tempURL = mVoteData [position].imageString; //call the local picasso function //set a tag for the button to the current clicked position vh.IVDetail.SetTag (Resource.Id.ivDetails, position); vh.IVPoster.SetTag (Resource.Id.ivPoster, position); vh.IVVote.SetTag (Resource.Id.ivVote, position); vh.PBimgVote.Visibility = ViewStates.Invisible; intialButton (vh.IVVote, vh.PBimgVote, mVoteData [position].voteStat); PicassoSetImage (tempURL, vh.IVPoster, vh); //define a handle click vh.IVVote.Click += IVVote_Click; vh.IVDetail.Click += IVDetail_Click; vh.IVPoster.Click += IVPoster_Click; vh.TVLike.Visibility = ViewStates.Invisible; vh.IVDetail.Visibility = ViewStates.Invisible; } }
public override void OnBindViewHolder (RecyclerView.ViewHolder holder, int position) { if (holder.GetType () == typeof(MyHealth_BloodPressure_ViewHolder)) { MyHealth_BloodPressure_ViewHolder vh = holder as MyHealth_BloodPressure_ViewHolder; vh.tvMHBPCLIDateTime.Text = mData[position].mDateTime; vh.tvMHBPCLIPressure.Text = mData[position].mPressure; vh.tvMHBPCLIPulse.Text = mData[position].mPulse; vh.llMHBWCLIBgColor.SetBackgroundColor(Color.ParseColor(mData[position].mBgColor.ToString())); vh.tvMHBPCLIStatus.Text = mData [position].mStatus; } }
public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { ((CardBaseViewHolder) viewHolder).Title.SetText(Data[position].Title, TextView.BufferType.Normal); ((CardBaseViewHolder) viewHolder).Description.SetText(Data[position].Description, TextView.BufferType.Normal); if (viewHolder.GetType() == typeof (CardImageViewHolder)) { ((CardImageViewHolder) viewHolder).LoadImage(((FeedItemImage) Data[position]).Image, context); } else if (viewHolder.GetType() == typeof (CardPercentViewHolder)) { ((CardPercentViewHolder) viewHolder).AnimatePercentage( ((FeedItemPercentage) Data[position]).Percentage, 1200); } else if (viewHolder.GetType() == typeof (CardGraphViewHolder)) { PlotModel model = ((FeedItemGraph) Data[position]).CreatePlotModel(); ((CardGraphViewHolder) viewHolder).PlotGraph(model); } else if (viewHolder.GetType() == typeof (CardPersonViewHolder)) { ((CardPersonViewHolder) viewHolder).LoadData(((FeedItemUser) Data[position]).UserAccount, context); } else if (viewHolder.GetType() == typeof (CardActivityViewHolder)) { ((CardActivityViewHolder) viewHolder).LoadData((FeedItemActivity) Data[position], context); } else if (viewHolder.GetType() == typeof (CardRatingViewHolder)) { ((CardRatingViewHolder) viewHolder).RatingBar.Rating = ((FeedItemStarRating) Data[position]).Rating; } if (Data[position].Interaction == null || Data[position].Interaction.Type == FeedItemInteraction.InteractionType.None) { ((CardBaseViewHolder) viewHolder).Interact.Visibility = ViewStates.Gone; return; } ((CardBaseViewHolder) viewHolder).Interact.Visibility = ViewStates.Visible; ((CardBaseViewHolder) viewHolder).Interact.Text = Data[position].Interaction.Label; FeedItemInteraction interaction = Data[position].Interaction; switch (interaction.Type) { case FeedItemInteraction.InteractionType.Url: ((CardBaseViewHolder) viewHolder).Interact.Click += delegate { Intent i = new Intent(Intent.ActionView, Android.Net.Uri.Parse(interaction.Value)); context.StartActivity(i); }; break; case FeedItemInteraction.InteractionType.Assessment: ((CardBaseViewHolder) viewHolder).Interact.Click += delegate { int actId = int.Parse(interaction.Value); if (!AndroidUtils.IsConnected() && !AndroidUtils.IsActivityAvailableOffline(actId, context)) { AndroidUtils.OfflineAlert(context, "This assessment has not been downloaded yet and requires an Internet connection to prepare!"); return; } try { Intent intent = new Intent(context, typeof(AssessmentActivity)); intent.PutExtra("ActivityId", actId); context.StartActivity(intent); } catch (Exception ex) { AndroidUtils.OfflineAlert(context, "Error launching assessment activity"); return; } }; break; case FeedItemInteraction.InteractionType.Activity: ((CardBaseViewHolder) viewHolder).Interact.Click += delegate { int actId = int.Parse(interaction.Value); if (!AndroidUtils.IsConnected() && !AndroidUtils.IsActivityAvailableOffline(actId, context)) { AndroidUtils.OfflineAlert(context, "This practiceActivity has not been downloaded yet and requires an Internet connection to prepare!"); return; } Intent intent = new Intent(context, typeof (ScenarioActivity)); intent.PutExtra("ActivityId", actId); context.StartActivity(intent); }; break; } }
public override void OnBindViewHolder (RecyclerView.ViewHolder holder, int position) { if (holder.GetType () == typeof(Product_ViewHolder)) { DateTime dt = Convert.ToDateTime (prodList [position].created_at); string ProdDate = dt.ToString ("MMM dd, yyyy"); var h = holder as Product_ViewHolder; h.txtPrice.Text = prodList [position].price; h.txtProdName.Text = prodList [position].title; h.txtProdDate.Text = ProdDate; h.View.SetTag (Resource.Id.recyclerView, Int32.Parse (prodList [position].id)); h.View.Click += Product_Click; PicassoSetImage (prodList [position].url_photo_thumb, h.ImageView, h); } }
public override void OnBindViewHolder (RecyclerView.ViewHolder holder, int position) { //int item = mData[position]; //IWindowManager windowManager = context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>(); //MyKomuniti_ViewHolder vh = holder as MyKomuniti_ViewHolder; /*//calculate the phone screen DisplayMetrics dm = new DisplayMetrics (); windowManager.DefaultDisplay.GetMetrics (dm); int width = dm.WidthPixels; int height = dm.HeightPixels; int dens = (int)dm.DensityDpi; double wi = (double)width / (double)dens; double hi = (double)height / (double)dens; double x = Math.Pow (wi,2); double y = Math.Pow (hi,2); double screenInches = Math.Sqrt (x + y);*/ //vh.tvTitle.Text = mData[position].title; //vh.tvContent.Text = mData[position].content; //vh.IVLike.SetImageResource (mData[position].like); if (holder.GetType () == typeof(MyKomuniti_ViewHolder)) { MyKomuniti_ViewHolder vh = holder as MyKomuniti_ViewHolder; vh.tvTitle.Text = mData[position].title; //vh.tvContent.Text = mData[position].content; vh.tvDescription.Text = Html.FromHtml(mData[position].content).ToString(); //vh.tvDescription.Text = mData[position].content.Replace("s/<(.*?)>//g",""); vh.tvMKVLIDate.Text = mData [position].date; vh.tvMKVLISender.Text = mData [position].sender; } }