// Create new views (invoked by the layout manager) public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { try { //Setup your layout here >> Style_HContact_view var itemView = LayoutInflater.From(parent.Context) .Inflate(Resource.Layout.Style_HContact_view, parent, false); var vh = new MyContacts_AdapterViewHolder(itemView, OnClick, OnLongClick); return(vh); } catch (Exception exception) { Crashes.TrackError(exception); return(null); } }
public void Initialize(MyContacts_AdapterViewHolder holder, Classes.UserContacts.User users) { try { var AvatarSplit = users.avatar.Split('/').Last(); var getImage_Avatar = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskImage, AvatarSplit); if (getImage_Avatar != "File Dont Exists") { ImageServiceLoader.Load_Image(holder.Image, "no_profile_image.png", getImage_Avatar, 1); } else { IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskImage, users.avatar); ImageServiceLoader.Load_Image(holder.Image, "no_profile_image.png", users.avatar, 1); } var CoverSplit = users.cover.Split('/').Last(); var getImage_Cover = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskImage, CoverSplit); if (getImage_Cover == "File Dont Exists") { IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskImage, users.cover); } string name = IMethods.Fun_String.DecodeString(IMethods.Fun_String.DecodeStringWithEnter(users.name)); holder.Name.Text = IMethods.Fun_String.SubStringCutOf(name, 25); var dataabout = IMethods.Fun_String.StringNullRemover(users.about); if (dataabout != "Empty") { var about = IMethods.Fun_String.DecodeString(IMethods.Fun_String.DecodeStringWithEnter(dataabout)); holder.About.Text = IMethods.Fun_String.SubStringCutOf(about, 25); } else { var about = Activity_Context.GetText(Resource.String.Lbl_DefaultAbout) + " " + Settings.Application_Name; holder.About.Text = IMethods.Fun_String.SubStringCutOf(about, 25); } //Set All My Contacts if (users.is_following == "1") // My Friend { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); holder.Button.SetTextColor(Color.ParseColor("#ffffff")); if (Settings.ConnectivitySystem == "1") // Following { holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Following); } else // Friend { holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Friends); } holder.Button.Tag = "friends"; } else if (users.is_following == "2") // Request { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); holder.Button.SetTextColor(Color.ParseColor("#444444")); holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Request); holder.Button.Tag = "Request"; } else if (users.is_following == "0") //Not Friend { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); holder.Button.SetTextColor(Color.ParseColor(Settings.MainColor)); if (Settings.ConnectivitySystem == "1") // Following { holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Follow); } else // Friend { holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_AddFriends); } holder.Button.Tag = "false"; var dbDatabase = new SqLiteDatabase(); dbDatabase.Delete_UsersContact(users.user_id); dbDatabase.Dispose(); } else { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); holder.Button.SetTextColor(Color.ParseColor("#ffffff")); if (Settings.ConnectivitySystem == "1") // Following { holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Following); } else // Friend { holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Friends); } users.is_following = "1"; } holder.Button.Tag = "true"; if (!holder.Button.HasOnClickListeners) { holder.Button.Click += (sender, args) => { try { if (!IMethods.CheckConnectivity()) { Toast.MakeText(Activity_Context, Activity_Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } else { if (holder.Button.Tag.ToString() == "false") { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); holder.Button.SetTextColor(Color.ParseColor("#ffffff")); if (Settings.ConnectivitySystem == "1") // Following { holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Following); holder.Button.Tag = "true"; } else // Request Friend { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); holder.Button.SetTextColor(Color.ParseColor("#444444")); holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Request); holder.Button.Tag = "Request"; } } else { holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); holder.Button.SetTextColor(Color.ParseColor(Settings.MainColor)); if (Settings.ConnectivitySystem == "1") // Following { holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_Follow); } else // Friend { holder.Button.Text = Activity_Context.GetText(Resource.String.Lbl_AddFriends); } holder.Button.Tag = "false"; var dbDatabase = new SqLiteDatabase(); dbDatabase.Delete_UsersContact(users.user_id); dbDatabase.Dispose(); } var result = Client.Global.Follow_User(users.user_id).ConfigureAwait(false); } } catch (Exception e) { Crashes.TrackError(e); } } } ; } catch (Exception e) { Crashes.TrackError(e); } }