protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.layout1_image);//.test.layout.activity_main2); string url = "http://img1.dzwww.com:8080/tupian_pl/20150813/16/7858995348613407436.jpg"; ImageView imageView = FindViewById <ImageView>(Resource.Id.imgView); var requestOptions = new RequestOptions(); requestOptions.Placeholder(Resource.Drawable.I5); requestOptions.CenterCrop(); requestOptions.DontAnimate(); //requestOptions.SkipMemoryCache(true); requestOptions.Error(Resource.Drawable.I7); //Glide.With(this).Load(ImageUrl).Apply(requestOptions).Into(imageView); RequestOptions.DiskCacheStrategyOf(DiskCacheStrategy.None);//磁盘缓存 Glide.With(imageView.Context) .Load(url) //.Load(Resource.Drawable.I8) //.PlaceHolder(R.drawable.place_image)//图片加载出来前,显示的图片 //.Error(Resource.Drawable.girl)//图片加载失败后,显示的图片 .Apply(requestOptions) .Apply(RequestOptions.CircleCropTransform()) .Into(imageView); //.Into(imageView); //new GlideDrawableImageViewTarget // Create your application here }
public MyGridViewAdapter(Context context, MySimpleItemLoader mySimpleItemLoader) { _context = context; _mySimpleItemLoader = mySimpleItemLoader; requestOptions = new RequestOptions(); requestOptions.Placeholder(Resource.Drawable.Triangles); requestOptions.Error(Resource.Drawable.pumafull); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { base.OnBindViewHolder(holder, position); if (holder is ItemViewHolder) { ItemViewHolder itemViewHolder = (ItemViewHolder)holder; var relatesBean = relates[position];//.get(position); var dd = "http://d.hiphotos.baidu.com/image/pic/item/d000baa1cd11728bc4388fe7c5fcc3cec2fd2cd9.jpg"; var requestOptions = new RequestOptions(); requestOptions.Placeholder(Resource.Drawable.I1); requestOptions.CenterCrop(); requestOptions.DontAnimate(); requestOptions.Error(Resource.Drawable.I7); requestOptions.CircleCrop(); Glide.With(holder.ItemView) .Load(dd) .Apply(requestOptions) .Into(itemViewHolder.mVideoPic); //.i //.with(getContext()) // .load(relatesBean.getPic()) // .centerCrop() // .diskCacheStrategy(DiskCacheStrategy.ALL) // .placeholder(R.drawable.bili_default_image_tv) // .dontAnimate() // .into(itemViewHolder.mVideoPic); itemViewHolder.mVideoTitle.Text = "Test"; // relatesBean.getTitle();//.setText(relatesBean.getTitle()); itemViewHolder.mVideoPlayNum.Text = "10"; // relatesBean.getStat().getView().ToString();//.setText( //NumberUtil.converString(relatesBean.getStat().getView())); itemViewHolder.mVideoReviewNum.Text = "0"; // relatesBean.getStat().getView().ToString();//setText( // NumberUtil.converString(relatesBean.getStat().getDanmaku())); itemViewHolder.mUpName.Text = "Someone"; // relatesBean.getOwner().getName();// setText(relatesBean.getOwner().getName()); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { var item = SocialList[viewHolder.AdapterPosition]; if (item != null) { switch (item.TypeView) { case SocialModelType.MangedGroups: { switch (viewHolder) { case AdapterHolders.GroupsSocialViewHolder holder: { switch (GroupsAdapter) { case null: holder.GroupsRecyclerView?.SetLayoutManager(new LinearLayoutManager(ActivityContext, LinearLayoutManager.Horizontal, false)); GroupsAdapter = new UserGroupsAdapter(ActivityContext) { GroupList = new ObservableCollection <GroupClass>() }; holder.GroupsRecyclerView?.SetAdapter(GroupsAdapter); GroupsAdapter.ItemClick += GroupsAdapterOnItemClick; break; } var countList = item.MangedGroupsModel.GroupsList.Count; switch (item.MangedGroupsModel.GroupsList.Count) { case > 0 when countList > 0: { foreach (var user in from user in item.MangedGroupsModel.GroupsList let check = GroupsAdapter.GroupList.FirstOrDefault(a => a.GroupId == user.GroupId) where check == null select user) { GroupsAdapter.GroupList.Add(user); } GroupsAdapter.NotifyItemRangeInserted(countList - 1, GroupsAdapter.GroupList.Count - countList); break; } case > 0: GroupsAdapter.GroupList = new ObservableCollection <GroupClass>(item.MangedGroupsModel.GroupsList); GroupsAdapter.NotifyDataSetChanged(); break; } holder.AboutHead.Text = item.MangedGroupsModel?.TitleHead; holder.AboutMore.Text = item.MangedGroupsModel?.More; holder.AboutMore.Visibility = GroupsAdapter?.GroupList?.Count >= 5 ? ViewStates.Visible : ViewStates.Invisible; break; } } break; } case SocialModelType.JoinedGroups: { switch (viewHolder) { case GroupsAdapterViewHolder holder: { var options = new RequestOptions(); options.Transform(new MultiTransformation(new CenterCrop(), new RoundedCorners(110))); options.Error(Resource.Drawable.ImagePlacholder).Placeholder(Resource.Drawable.ImagePlacholder); GlideImageLoader.LoadImage(ActivityContext, item.GroupData.Avatar, holder.Image, ImageStyle.CenterCrop, ImagePlaceholders.Drawable, false, options); holder.Name.Text = Methods.FunString.DecodeString(item.GroupData.Name); if (WoWonderTools.IsJoinedGroup(item.GroupData)) { holder.JoinButton.Text = ActivityContext.GetString(Resource.String.Btn_Joined); holder.JoinButton.Tag = "true"; } else { holder.JoinButton.Text = ActivityContext.GetString(Resource.String.Btn_Join_Group); holder.JoinButton.Tag = "false"; } break; } } break; } case SocialModelType.Section: { if (viewHolder is not AdapterHolders.SectionViewHolder holder) { return; } holder.AboutHead.Text = item.TitleHead; break; } case SocialModelType.MangedPages: { switch (viewHolder) { case AdapterHolders.PagesSocialViewHolder holder: { switch (PagesAdapter) { case null: holder.PagesRecyclerView?.SetLayoutManager(new LinearLayoutManager(ActivityContext, LinearLayoutManager.Horizontal, false)); PagesAdapter = new UserPagesAdapter(ActivityContext) { PageList = new ObservableCollection <PageClass>() }; holder.PagesRecyclerView?.SetAdapter(PagesAdapter); PagesAdapter.ItemClick += PagesAdapterOnItemClick; break; } var countList = item.PagesModelClass.PagesList.Count; switch (item.PagesModelClass.PagesList.Count) { case > 0 when countList > 0: { foreach (var user in from user in item.PagesModelClass.PagesList let check = PagesAdapter.PageList.FirstOrDefault(a => a.PageId == user.PageId) where check == null select user) { PagesAdapter.PageList.Add(user); } PagesAdapter.NotifyItemRangeInserted(countList - 1, PagesAdapter.PageList.Count - countList); break; } case > 0: PagesAdapter.PageList = new ObservableCollection <PageClass>(item.PagesModelClass.PagesList); PagesAdapter.NotifyDataSetChanged(); break; } holder.AboutHead.Text = item.PagesModelClass?.TitleHead; holder.AboutMore.Text = item.PagesModelClass?.More; holder.AboutMore.Visibility = PagesAdapter?.PageList?.Count >= 5 ? ViewStates.Visible : ViewStates.Invisible; break; } } break; } case SocialModelType.LikedPages: { switch (viewHolder) { case PageAdapterViewHolder holder: { GlideImageLoader.LoadImage(ActivityContext, item.PageData.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); holder.About.Text = item.PageData.Category; if (!string.IsNullOrEmpty(item.PageData.PageTitle) || !string.IsNullOrWhiteSpace(item.PageData.PageTitle)) { holder.Name.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(item.PageData.PageTitle), 20); } else { holder.Name.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(item.PageData.PageName), 20); } //Set style Btn Like page if (WoWonderTools.IsLikedPage(item.PageData)) { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); holder.Button.SetTextColor(Color.ParseColor("#ffffff")); holder.Button.Text = ActivityContext.GetText(Resource.String.Btn_Unlike); holder.Button.Tag = "true"; } else { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); holder.Button.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.Button.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.Button.Tag = "false"; } break; } } break; } case SocialModelType.Pages: break; case SocialModelType.Groups: break; } } } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { var item = SocialList[viewHolder.AdapterPosition]; if (item != null) { switch (item.TypeView) { case SocialModelType.MangedGroups: { if (viewHolder is AdapterHolders.GroupsSocialViewHolder holder) { if (holder.GroupsAdapter.GroupList.Count == 0) { holder.GroupsAdapter.GroupList = new ObservableCollection <GroupClass>(item.MangedGroupsModel.GroupsList); holder.GroupsAdapter.NotifyDataSetChanged(); } else if (item.MangedGroupsModel?.GroupsList != null && holder.GroupsAdapter.GroupList.Count != item.MangedGroupsModel.GroupsList.Count) { holder.GroupsAdapter.GroupList = new ObservableCollection <GroupClass>(item.MangedGroupsModel.GroupsList); holder.GroupsAdapter.NotifyDataSetChanged(); } if (!string.IsNullOrEmpty(item.MangedGroupsModel?.TitleHead)) { holder.AboutHead.Text = item.MangedGroupsModel?.TitleHead; } holder.AboutMore.Text = item.MangedGroupsModel?.More; if (holder.GroupsAdapter?.GroupList?.Count >= 5) { holder.AboutMore.Visibility = ViewStates.Visible; holder.AboutMoreIcon.Visibility = ViewStates.Visible; } else { holder.AboutMore.Visibility = ViewStates.Invisible; holder.AboutMoreIcon.Visibility = ViewStates.Invisible; } if (!holder.AboutMore.HasOnClickListeners) { holder.AboutMore.Click += (sender, args) => { OpenAllViewer("MangedGroupsModel", item); }; holder.AboutMoreIcon.Click += (sender, args) => { OpenAllViewer("MangedGroupsModel", item); }; } } break; } case SocialModelType.JoinedGroups: { if (viewHolder is GroupsAdapterViewHolder holder) { var options = new RequestOptions(); options.Transform(new MultiTransformation(new CenterCrop(), new RoundedCorners(110))); options.Error(Resource.Drawable.ImagePlacholder).Placeholder(Resource.Drawable.ImagePlacholder); GlideImageLoader.LoadImage(ActivityContext, item.GroupData.Avatar, holder.Image, ImageStyle.CenterCrop, ImagePlaceholders.Drawable, false, options); if (!string.IsNullOrEmpty(item.GroupData.GroupTitle) || !string.IsNullOrWhiteSpace(item.GroupData.GroupTitle)) { holder.Name.Text = Methods.FunString.DecodeString(item.GroupData.GroupName); } else { holder.Name.Text = Methods.FunString.DecodeString(item.GroupData.GroupName); } if (item.GroupData.IsJoined == "true" || item.GroupData.IsJoined == "yes") { holder.JoinButton.Text = ActivityContext.GetString(Resource.String.Btn_Joined); holder.JoinButton.Tag = "true"; } else { holder.JoinButton.Text = ActivityContext.GetString(Resource.String.Btn_Join_Group); holder.JoinButton.Tag = "false"; } if (!holder.JoinButton.HasOnClickListeners) { holder.JoinButton.Click += (sender, args) => { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(ActivityContext, ActivityContext.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); return; } if (holder.JoinButton.Tag.ToString() == "false") { holder.JoinButton.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.JoinButton.Text = ActivityContext.GetString(Resource.String.Btn_Joined); holder.JoinButton.Tag = "true"; } else { holder.JoinButton.SetTextColor(Color.Black); holder.JoinButton.Text = ActivityContext.GetString(Resource.String.Btn_Join_Group); holder.JoinButton.Tag = "false"; } PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Group.Join_Group(item.GroupData.GroupId) }); } catch (Exception e) { Console.WriteLine(e); } }; } } break; } case SocialModelType.Section: { if (!(viewHolder is AdapterHolders.SectionViewHolder holder)) { return; } holder.AboutHead.Text = item.TitleHead; if (string.IsNullOrEmpty(item.MoreIcon)) { holder.AboutMoreIcon.Text = item.MoreIcon; } break; } case SocialModelType.MangedPages: { if (viewHolder is AdapterHolders.PagesSocialViewHolder holder) { if (holder.PagesAdapter.UserPagesList.Count == 0) { holder.PagesAdapter.UserPagesList = new ObservableCollection <PageClass>(item.PagesModelClass.PagesList); holder.PagesAdapter.NotifyDataSetChanged(); } else if (item.PagesModelClass?.PagesList != null && holder.PagesAdapter.UserPagesList.Count != item.PagesModelClass.PagesList.Count) { holder.PagesAdapter.UserPagesList = new ObservableCollection <PageClass>(item.PagesModelClass.PagesList); holder.PagesAdapter.NotifyDataSetChanged(); } if (!string.IsNullOrEmpty(item.PagesModelClass?.TitleHead)) { holder.AboutHead.Text = item.PagesModelClass?.TitleHead; } holder.AboutMore.Text = item.PagesModelClass?.More; if (holder.PagesAdapter?.UserPagesList?.Count >= 5) { holder.AboutMore.Visibility = ViewStates.Visible; holder.AboutMoreIcon.Visibility = ViewStates.Visible; } else { holder.AboutMore.Visibility = ViewStates.Invisible; holder.AboutMoreIcon.Visibility = ViewStates.Invisible; } if (!holder.AboutMore.HasOnClickListeners) { holder.AboutMore.Click += (sender, args) => { OpenAllViewer("MangedPagesModel", item); }; holder.AboutMoreIcon.Click += (sender, args) => { OpenAllViewer("MangedPagesModel", item); }; } } break; } case SocialModelType.LikedPages: { if (viewHolder is PageAdapterViewHolder holder) { GlideImageLoader.LoadImage(ActivityContext, item.PageData.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); holder.About.Text = item.PageData.Category; if (!string.IsNullOrEmpty(item.PageData.PageTitle) || !string.IsNullOrWhiteSpace(item.PageData.PageTitle)) { holder.Name.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(item.PageData.PageTitle), 14); } else { holder.Name.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(item.PageData.PageName), 14); } //Set style Btn Like page if (item.PageData.IsLiked == "true" || item.PageData.IsLiked == "yes") { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); holder.Button.SetTextColor(Color.ParseColor("#ffffff")); holder.Button.Text = ActivityContext.GetText(Resource.String.Btn_Unlike); holder.Button.Tag = "true"; } else { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); holder.Button.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.Button.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.Button.Tag = "false"; } if (!holder.Button.HasOnClickListeners) { holder.Button.Click += (sender, args) => { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(ActivityContext, ActivityContext.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); return; } if (holder.Button.Tag.ToString() == "false") { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); holder.Button.SetTextColor(Color.ParseColor("#ffffff")); holder.Button.Text = ActivityContext.GetText(Resource.String.Btn_Unlike); holder.Button.Tag = "true"; } else { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); holder.Button.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.Button.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.Button.Tag = "false"; } PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Page.Like_Page(item.PageData.PageId) }); } catch (Exception e) { Console.WriteLine(e); } }; } } break; } } } } catch (Exception exception) { Console.WriteLine(exception); } }