private void LoadDataUser() { try { CollapsingToolbar.Title = DeepSoundTools.GetNameFinal(DataUser); GlideImageLoader.LoadImage(Activity, DataUser.Avatar, ImageAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); GlideImageLoader.LoadImage(Activity, DataUser.Cover, ImageCover, ImageStyle.CenterCrop, ImagePlaceholders.Drawable); TxtUserName.Text = DeepSoundTools.GetNameFinal(DataUser); TextSanitizer aboutSanitizer = new TextSanitizer(TxtAbout, Activity); aboutSanitizer.Load(DeepSoundTools.GetAboutFinal(DataUser)); IconPro.Visibility = DataUser.IsPro == 1 ? ViewStates.Visible : ViewStates.Gone; IconVerified.Visibility = DataUser.Verified == 1 ? ViewStates.Visible : ViewStates.Gone; if (DataUser.IsFollowing) // My Friend { BtnFollow.SetColor(Color.ParseColor(AppSettings.MainColor)); BtnFollow.SetImageResource(Resource.Drawable.ic_tick); BtnFollow.Tag = "friends"; } else //Not Friend { BtnFollow.SetColor(Color.ParseColor("#444444")); BtnFollow.SetImageResource(Resource.Drawable.ic_add); BtnFollow.Tag = "Add"; } } catch (Exception e) { Console.WriteLine(e); } }
public TextViewHolder(View itemView, Action <UserMessagesAdapterClickEventArgs> clickListener, Action <UserMessagesAdapterClickEventArgs> longClickListener, Activity activity) : base(itemView) { try { MainView = itemView; LytParent = itemView.FindViewById <LinearLayout>(Resource.Id.main); AutoLinkTextView = itemView.FindViewById <AutoLinkTextView>(Resource.Id.active); Time = itemView.FindViewById <TextView>(Resource.Id.time); AutoLinkTextView.SetTextIsSelectable(true); if (TextSanitizerAutoLink == null) { TextSanitizerAutoLink = new TextSanitizer(AutoLinkTextView, activity); } itemView.Click += (sender, e) => clickListener(new UserMessagesAdapterClickEventArgs { View = itemView, Position = AdapterPosition }); itemView.LongClick += (sender, e) => longClickListener(new UserMessagesAdapterClickEventArgs { View = itemView, Position = AdapterPosition }); } catch (Exception e) { Console.WriteLine(e + "Error"); } }
private void SetDataSong() { try { if (DataObject != null) { GlideImageLoader.LoadImage(ActivityContext, DataObject.Thumbnail, ImageSong, ImageStyle.CenterCrop, ImagePlaceholders.Drawable); TxtNameSong.Text = DataObject.Title; TxtGenres.Text = DataObject.CategoryName; TxtDate.Text = DataObject.TimeFormatted; TxtPublisherName.Text = DeepSoundTools.GetNameFinal(DataObject.Publisher); CountLike.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(DataObject.CountLikes)); CountStars.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(DataObject.CountFavorite)); CountViews.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(DataObject.CountViews.Replace("K", "").Replace("M", ""))); CountShare.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(DataObject.CountShares)); CountComment.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(DataObject.CountComment)); TextSanitizer aboutSanitizer = new TextSanitizer(TxtAbout, ActivityContext); aboutSanitizer.Load(Methods.FunString.DecodeString(DataObject.Description)); TextSanitizer tagsSanitizer = new TextSanitizer(TxtTags, ActivityContext); tagsSanitizer.Load(ActivityContext.GetText(Resource.String.Lbl_Tags) + " : \n \n" + Methods.FunString.DecodeString(DataObject.Tags.Replace(",", " #"))); TextSanitizer lyricsSanitizer = new TextSanitizer(TxtLyrics, ActivityContext); lyricsSanitizer.Load(ActivityContext.GetText(Resource.String.Lbl_Lyrics) + " : \n \n" + Methods.FunString.DecodeString(DataObject.Lyrics)); } } catch (Exception e) { Console.WriteLine(e); } }
private void GetReply() { try { if (UserinfoComment != null) { TextSanitizer changer = new TextSanitizer(CommentText, Activity); changer.Load(Methods.FunString.DecodeString(UserinfoComment.Text)); TimeTextView.Text = Methods.Time.TimeAgo(Convert.ToInt32(UserinfoComment.Time)); GlideImageLoader.LoadImage(Activity, UserinfoComment.Avatar, Image, ImageStyle.CircleCrop, ImagePlaceholders.Color); ReplyButton.Visibility = ViewStates.Invisible; LikeCount.Text = Activity.GetString(Resource.String.Lbl_Likes) + " " + "(" + UserinfoComment.Likes + ")"; LikeIcon.SetImageResource(UserinfoComment.IsLiked ? Resource.Drawable.ic_action_like_2 : Resource.Drawable.ic_action_like_1); } StartApiService(); } catch (Exception e) { Console.WriteLine(e); } }
public void Sanitizer_ReplacesInvalidCharacters(string input, string expected) { var sanitizer = new TextSanitizer(); var output = sanitizer.Process(input); Assert.Equal(expected, output); }
public void Sanitizer_StripsWhitespace() { var sanitizer = new TextSanitizer(); var output = sanitizer.Process(" \n \tA\n\t "); Assert.Equal("A", output); }
public void DisplayData(string fullname, string description, string avatar, string time, string videofile, int likesCount, bool isliked, bool isSaved, int votesCount) { try { Fullname.Text = fullname; TimeTextView.Text = time; GlideImageLoader.LoadImage(Activity, avatar, UserAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); var textSanitizer = new TextSanitizer(Description, Activity); if (!string.IsNullOrEmpty(description)) { ReadMoreOption.AddReadMoreTo(Description, Methods.FunString.DecodeString(description)); textSanitizer.Load(Methods.FunString.DecodeString(description)); } else { Description.Visibility = ViewStates.Gone; } CommentIcon.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#888888") : Color.ParseColor("#444444")); LikeCount.Text = likesCount + " " + Context.GetText(Resource.String.Lbl_Likes); LikeIcon.Tag = "Like"; if (isliked) { LikeIcon.SetTextColor(Color.ParseColor("#ed4856")); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, LikeIcon, IonIconsFonts.IosHeart); LikeIcon.Tag = "Liked"; } if (!isSaved) { Favicon.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#888888") : Color.ParseColor("#444444")); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, Favicon, IonIconsFonts.IosStarOutline); Favicon.Tag = "Add"; } else { Favicon.SetTextColor(Color.ParseColor("#FFCE00")); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, Favicon, IonIconsFonts.AndroidStar); Favicon.Tag = "Added"; } CommentCount.Text = votesCount + " " + Context.GetText(Resource.String.Lbl_Comments); if (votesCount <= 4) { ViewCommentsButton.Visibility = ViewStates.Gone; } } catch (Exception e) { Console.WriteLine(e); } }
private void LoadReplies() { try { if (Comment == null) { return; } GlideImageLoader.LoadImage(ActivityContext, Comment.CommentUserData.Avatar, Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); TextSanitizer chnager = new TextSanitizer(CommentText, ActivityContext); chnager.Load(Methods.FunString.DecodeString(Comment.Text)); TimeTextView.Text = Comment.TextTime; UsernameTextView.Text = AppTools.GetNameFinal(Comment.CommentUserData); LikeNumber.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(Comment.Likes)); UnLikeNumber.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(Comment.DisLikes)); RepliesCount.Text = Comment.RepliesCount.ToString(); if (Comment.IsLikedComment == 1) { LikeiconView.SetColorFilter(Color.ParseColor(AppSettings.MainColor)); LikeButton.Tag = "1"; } else { LikeButton.Tag = "0"; } if (Comment.IsDislikedComment == 1) { UnLikeiconView.SetColorFilter(Color.ParseColor(AppSettings.MainColor)); UnLikeButton.Tag = "1"; } else { UnLikeButton.Tag = "0"; } if (Comment.CommentReplies?.Count > 0) { ReplyAdapter.ReplyList = new ObservableCollection <ReplyObject>(Comment.CommentReplies); ReplyAdapter.NotifyDataSetChanged(); EmptyStateLayout.Visibility = ViewStates.Gone; } string offset = ReplyAdapter.ReplyList.LastOrDefault()?.Id.ToString() ?? "0"; StartApiService(offset); } catch (Exception e) { Console.WriteLine(e); } }
public void On_NullInput_ThrowsArgumentException() { var sanitizer = new TextSanitizer(); void Act() { sanitizer.Process(null); } Assert.Throws <ArgumentException>((Action)Act); }
public void InitComponent() { try { QualityIcon = FindViewById <TextView>(Resource.Id.Qualityicon); ViewsIcon = FindViewById <TextView>(Resource.Id.Viewsicon); ShareIcon = FindViewById <TextView>(Resource.Id.Shareicon); MoreIcon = FindViewById <TextView>(Resource.Id.Moreicon); ShowMoreDescriptionIcon = FindViewById <TextView>(Resource.Id.video_ShowDiscription); VideoDescriptionLayout = FindViewById <LinearLayout>(Resource.Id.videoDescriptionLayout); ShareButton = FindViewById <LinearLayout>(Resource.Id.ShareButton); ShareButton.Click += VideoActionsController.ShareIcon_Click; MoreButton = FindViewById <LinearLayout>(Resource.Id.moreButton); MoreButton.Click += VideoActionsController.MoreButton_OnClick; VideoTittle = FindViewById <TextView>(Resource.Id.video_Titile); VideoQualityTextView = FindViewById <TextView>(Resource.Id.QualityTextView); VideoViewsNumber = FindViewById <TextView>(Resource.Id.ViewsNumber); VideoVideoDate = FindViewById <TextView>(Resource.Id.videoDate); VideoVideoDescription = FindViewById <AutoLinkTextView>(Resource.Id.videoDescriptionTextview); VideoVideoCategory = FindViewById <TextView>(Resource.Id.videoCategorytextview); VideoStars = FindViewById <TextView>(Resource.Id.videoStarstextview); VideoTag = FindViewById <TextView>(Resource.Id.videoTagtextview); TextSanitizerAutoLink = new TextSanitizer(VideoVideoDescription, this); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, QualityIcon, IonIconsFonts.Ribbon); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ViewsIcon, IonIconsFonts.Eye); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ShareIcon, IonIconsFonts.ShareAlt); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, MoreIcon, IonIconsFonts.AddCircle); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ShowMoreDescriptionIcon, IonIconsFonts.ArrowDown); ShowMoreDescriptionIcon.Visibility = ViewStates.Gone; VideoDescriptionLayout.Visibility = ViewStates.Visible; MAdView = FindViewById <AdView>(Resource.Id.adView); AdsGoogle.InitAdView(MAdView, null); MRecycler = FindViewById <RecyclerView>(Resource.Id.recyler); TxtComment = FindViewById <EditText>(Resource.Id.commenttext); ImgSent = FindViewById <ImageView>(Resource.Id.send); TxtComment.Text = ""; Methods.SetColorEditText(TxtComment, AppSettings.SetTabDarkTheme ? Color.White : Color.Black); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void InitComponent(View view) { try { QualityIcon = view.FindViewById <TextView>(Resource.Id.Qualityicon); ViewsIcon = view.FindViewById <TextView>(Resource.Id.Viewsicon); ShareIcon = view.FindViewById <TextView>(Resource.Id.Shareicon); MoreIcon = view.FindViewById <TextView>(Resource.Id.Moreicon); ShowMoreDescriptionIcon = view.FindViewById <TextView>(Resource.Id.video_ShowDiscription); VideoDescriptionLayout = view.FindViewById <LinearLayout>(Resource.Id.videoDescriptionLayout); ShareButton = view.FindViewById <LinearLayout>(Resource.Id.ShareButton); ShareButton.Click += GlobalContext.VideoActionsController.ShareIcon_Click; MoreButton = view.FindViewById <LinearLayout>(Resource.Id.moreButton); MoreButton.Click += GlobalContext.VideoActionsController.MoreButton_OnClick; VideoTittle = view.FindViewById <TextView>(Resource.Id.video_Titile); VideoQualityTextView = view.FindViewById <TextView>(Resource.Id.QualityTextView); VideoViewsNumber = view.FindViewById <TextView>(Resource.Id.ViewsNumber); VideoVideoDate = view.FindViewById <TextView>(Resource.Id.videoDate); VideoVideoDescription = view.FindViewById <AutoLinkTextView>(Resource.Id.videoDescriptionTextview); VideoVideoCategory = view.FindViewById <TextView>(Resource.Id.videoCategorytextview); VideoStars = view.FindViewById <TextView>(Resource.Id.videoStarstextview); VideoTag = view.FindViewById <TextView>(Resource.Id.videoTagtextview); TextSanitizerAutoLink = new TextSanitizer(VideoVideoDescription, Activity); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, QualityIcon, IonIconsFonts.RibbonA); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ViewsIcon, IonIconsFonts.Eye); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ShareIcon, IonIconsFonts.ReplyAll); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, MoreIcon, IonIconsFonts.PlusCircled); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ShowMoreDescriptionIcon, IonIconsFonts.ArrowDownB); ShowMoreDescriptionIcon.Visibility = ViewStates.Gone; VideoDescriptionLayout.Visibility = ViewStates.Visible; MAdView = view.FindViewById <AdView>(Resource.Id.adView); AdsGoogle.InitAdView(MAdView, null); } catch (Exception e) { Console.WriteLine(e); } }
public List <string> OnChannelMessage(IrcBot ircBot, string server, string channel, IrcMessage m) { var key = server + channel; var message = m.Text; var botName = ircBot.Nickname; var botNameMatch = string.Format("^{0}[:,;]", botName); if (!_brains.ContainsKey(key)) { _brains.Add(key, new Chain(_settings.WindowSize)); } var brain = _brains[key]; if (Regex.IsMatch(message, botNameMatch)) { var regex = new Regex(botNameMatch); message = regex.Replace(message, ""); var response = TextSanitizer.FixInputEnds(brain.GenerateSentenceFromSentence(message)); if (!string.IsNullOrWhiteSpace(response)) { return(new List <string> { response }); } response = RandomResponse.Reponse(m.Sender); return(new List <string> { response }); } if (message.Split(' ').Length > _settings.WindowSize) { message = TextSanitizer.SanitizeInput(message); brain.Learn(message); SaveLine(key, message); } return(null); }
public async Task Message(string message, SocketMessage m) { if (_brain == null) { return; } var brain = _brain; bool mentioned = false; foreach (var user in m.MentionedUsers) { if (user.Id == DiscordClient.CurrentUser.Id) { mentioned = true; } } if (mentioned) { TextSanitizer.FixMiscelanious(message = Regex.Replace(message, "<.+>", "")); var response = TextSanitizer.FixInputEnds(brain.GenerateSentenceFromSentence(message)); if (!string.IsNullOrWhiteSpace(response)) { await m.Channel.SendMessageAsync(response); return; } response = RandomResponse.Reponse(m.Author.Username); await m.Channel.SendMessageAsync(response); return; } if (message[0] != ClientConfig.CommandSymbol && message.Split(' ').Length > _settings.WindowSize) { message = TextSanitizer.SanitizeInput(message); brain.Learn(message); SaveLine(message); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (viewHolder is CommentAdapterViewHolder holder) { var item = CommentList[position]; if (item != null) { GlideImageLoader.LoadImage(ActivityContext, item.UserData.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); TextSanitizer changer = new TextSanitizer(holder.CommentText, ActivityContext); changer.Load(Methods.FunString.DecodeString(item.Value)); holder.TimeTextView.Text = item.SecondsFormated; holder.LikeNumber.Text = Methods.FunString.FormatPriceValue(item.CountLiked); holder.LikeiconView.Tag = item.IsLikedComment ? "Like" : "Liked"; SetLike(holder.LikeiconView); holder.LikeButton.Tag = item.IsLikedComment ? "1" : "0"; if (!holder.Image.HasOnClickListeners) { holder.Image.Click += (sender, e) => AvatarClick(new AvatarCommentAdapterClickEventArgs { Class = item, Position = position, View = holder.MainView }); } if (!holder.LikeButton.HasOnClickListeners) { holder.LikeButton.Click += (sender, e) => OnLikeButtonClick(holder, new CommentAdapterClickEventArgs { Class = item, Position = position, View = holder.MainView }); } } } } catch (Exception exception) { Console.WriteLine(exception); } }
private void LoadBrain() { using (var stream = new FileStream(BrainPath, FileMode.Open)) using (var reader = new StreamReader(stream)) { var brain = new Chain(_settings.WindowSize); string line; var i = 0; while ((line = reader.ReadLine()) != null) { brain.Learn(TextSanitizer.SanitizeInput(line)); i++; } _brain = brain; Log.Information("Patternspider - Sentience: Loaded Brain, Parsed {i} Lines", i); } }
private void LoadDataUser() { try { var dataUser = ListUtils.MyUserInfoList.FirstOrDefault(a => a.Id == UserDetails.UserId); if (dataUser != null) { CollapsingToolbar.Title = DeepSoundTools.GetNameFinal(dataUser); GlideImageLoader.LoadImage(Activity, dataUser.Avatar, ImageAvatar, ImageStyle.CenterCrop, ImagePlaceholders.Drawable); GlideImageLoader.LoadImage(Activity, dataUser.Cover, ImageCover, ImageStyle.CenterCrop, ImagePlaceholders.Drawable); TxtFullName.Text = DeepSoundTools.GetNameFinal(dataUser); TxtUserName.Text = "@" + dataUser.Username; TextSanitizer aboutSanitizer = new TextSanitizer(TxtAbout, Activity); aboutSanitizer.Load(DeepSoundTools.GetAboutFinal(dataUser)); //var readMoreOption = new XTextViewAdvanced.Builder(Activity) // .SetTextLength(200, XTextViewAdvanced.TypeCharacter) // .SetMoreLabel(Context.GetText(Resource.String.Lbl_ReadMore)) // .SetLessLabel(Context.GetText(Resource.String.Lbl_ReadLess)) // .SetMoreLabelColor(Color.ParseColor(AppSettings.MainColor)) // .SetLessLabelColor(Color.ParseColor(AppSettings.MainColor)) // .SetLabelUnderLine(true) // .SetAutoLink(true) // .Build(); //readMoreOption.AddReadMoreTo(TxtAbout, new Java.Lang.String(IMethods.FunString.DecodeString(DeepSoundTools.GetAboutFinal(dataUser)))); IconPro.Visibility = dataUser.IsPro == 1 ? ViewStates.Visible : ViewStates.Gone; IconVerified.Visibility = dataUser.Verified == 1 ? ViewStates.Visible : ViewStates.Gone; } } catch (Exception e) { Console.WriteLine(e); } }
private void LoadBrains() { var brainFiles = Directory.EnumerateFiles(BrainPath, "*.brain"); foreach (var brainfile in brainFiles) { var sr = new StreamReader(brainfile); var brain = new Chain(_settings.WindowSize); string line; var key = brainfile.Replace(".brain", ""); key = key.Replace(BrainPath, ""); while ((line = sr.ReadLine()) != null) { brain.Learn(TextSanitizer.SanitizeInput(line)); } _brains.Add(key, brain); sr.Close(); Console.WriteLine("Sentience: Loaded {0}", key); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (viewHolder is ReplyAdapterViewHolder holder) { var item = ReplyList[position]; if (item != null) { TextSanitizer changer = new TextSanitizer(holder.CommentText, ActivityContext); changer.Load(Methods.FunString.DecodeString(item.Text)); holder.TimeTextView.Text = Methods.Time.TimeAgo(Convert.ToInt32(item.Time)); GlideImageLoader.LoadImage(ActivityContext, item.UserData.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Color); holder.ReplyButton.Text = ActivityContext.GetString(Resource.String.Lbl_Reply); holder.LikeCount.Text = ActivityContext.GetString(Resource.String.Lbl_Likes) + " " + "(" + item.Likes + ")"; if (!holder.Image.HasOnClickListeners) { holder.Image.Click += (sender, e) => OnAvatarClick(new AvatarReplyAdapterClickEventArgs { Class = item.UserData, Position = position, View = holder.MainView }); } holder.LikeIcon.SetImageResource(item.IsLiked == 1 ? Resource.Drawable.ic_action_like_2 : Resource.Drawable.ic_action_like_1); if (!holder.LikeIcon.HasOnClickListeners) { MyBounceInterpolator interpolator = new MyBounceInterpolator(0.2, 20); var animationScale = AnimationUtils.LoadAnimation(ActivityContext, Resource.Animation.scale); animationScale.Interpolator = interpolator; holder.LikeIcon.Click += (sender, args) => { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(ActivityContext, ActivityContext.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show(); } else { item.IsLiked = item.IsLiked == 0 ? 1 : 0; holder.LikeIcon.SetImageResource(item.IsLiked == 1 ? Resource.Drawable.ic_action_like_2 : Resource.Drawable.ic_action_like_1); holder.LikeIcon.StartAnimation(animationScale); if (item.IsLiked == 1) { Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("reaction.mp3"); item.Likes++; holder.LikeCount.Text = ActivityContext.GetString(Resource.String.Lbl_Likes) + " " + "(" + item.Likes + ")"; } else { if (item.Likes > 0) { item.Likes--; } else { item.Likes = 0; } holder.LikeCount.Text = ActivityContext.GetString(Resource.String.Lbl_Likes) + " " + "(" + item.Likes + ")"; } RequestsAsync.Post.LikeReply(item.Id.ToString()).ConfigureAwait(false); } } catch (Exception e) { Console.WriteLine(e); } }; } if (!holder.ReplyButton.HasOnClickListeners) { holder.ReplyButton.Click += (sender, args) => { try { //ActivityContext.TxtComment.Text = ""; //ActivityContext.TxtComment.Text = "@" + item.Publisher.Username + " "; } catch (Exception e) { Console.WriteLine(e); } } } ; } } } catch (Exception exception) { Console.WriteLine(exception); } }
private async Task <ResponseImageViewModel> ProcessImage(UploadImageViewModel model, DigitDetectionOptions options, ModelStateDictionary modelState) { int expectedNumber = continuityManager.GetCurrentNumber(); if (!modelState.IsValid) { var errors = modelState.SelectMany(pair => pair.Value.Errors.Select(error => error.ErrorMessage)) .ToList(); return(ResponseImageViewModelSimpleFactory.GenerateFailureResponse(null, expectedNumber, errors)); } //preprocess image var bitmap = bitmapUtility.FromFormFile(model.File); if (!imageRatioValidator.Validate(bitmap)) { return(ResponseImageViewModelSimpleFactory.GenerateFailureResponse(null, expectedNumber, imageRatioValidator.ErrorMessage)); } //extract text string recognizedText = await TryRecognizeText(options, bitmap); if (recognizedText == null) { return(ResponseImageViewModelSimpleFactory.GenerateFailureResponse(null, expectedNumber, ErrorMessages.SERVER_OVERLOADED)); } //preprocess text var sanitizer = new TextSanitizer(); recognizedText = sanitizer.Process(recognizedText); var expectedText = continuityManager.GetCurrentNumber().ToString(); if (expectedText == recognizedText) { int recognizedAsNumber = int.Parse(recognizedText); var bytes = bitmapUtility.ToByteArray(bitmapUtility.Resize(bitmap)); var entry = new ImageEntry(bytes, recognizedAsNumber); if (await continuityManager.TryIncrementCurrentNumber(entry)) { return(ResponseImageViewModelSimpleFactory.GenerateSuccessResponse(recognizedText, expectedNumber)); } else { //correct the expected number, as it must've changed expectedNumber = continuityManager.GetCurrentNumber(); return(ResponseImageViewModelSimpleFactory.GenerateFailureResponse(null, expectedNumber, ErrorMessages.CONCURRENCY)); } } else { string error = string.Format(ErrorMessages.INVALID_NUMBER, expectedText); return(ResponseImageViewModelSimpleFactory.GenerateFailureResponse(recognizedText, expectedNumber, error)); } }
private void LoadCommentMovies() { try { if (MoviesObject == null) { return; } if (AppSettings.FlowDirectionRightToLeft) { BubbleLayout.LayoutDirection = LayoutDirection.Rtl; } var changer = new TextSanitizer(CommentText, Activity); changer.Load(Methods.FunString.DecodeString(MoviesObject.Text)); TimeTextView.Text = Methods.Time.TimeAgo(int.Parse(MoviesObject.Posted)); UserName.Text = MoviesObject.UserData.Name; GlideImageLoader.LoadImage(Activity, MoviesObject.UserData.Avatar, Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); var textHighLighter = MoviesObject.UserData.Name; var textIsPro = string.Empty; if (MoviesObject.UserData.Verified == "1") { textHighLighter += " " + IonIconsFonts.CheckmarkCircled; } if (MoviesObject.UserData.IsPro == "1") { textIsPro = " " + IonIconsFonts.Flash; textHighLighter += textIsPro; } var decorator = TextDecorator.Decorate(UserName, textHighLighter).SetTextStyle((int)TypefaceStyle.Bold, 0, MoviesObject.UserData.Name.Length); if (MoviesObject.UserData.Verified == "1") { decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled); } if (MoviesObject.UserData.IsPro == "1") { decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro); } decorator.Build(); if (MoviesObject.Replies?.Count > 0) { ReplyTextView.Text = Activity.GetText(Resource.String.Lbl_Reply) + " " + "(" + MoviesObject.Replies + ")"; } if (MoviesObject.IsCommentLiked) { LikeTextView.Text = Activity.GetText(Resource.String.Btn_Liked); LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); LikeTextView.Tag = "Liked"; } else { LikeTextView.Text = Activity.GetText(Resource.String.Btn_Like); LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff") : Color.ParseColor("#000000")); LikeTextView.Tag = "Like"; } TimeTextView.Tag = "true"; if (Image.HasOnClickListeners) { return; } //Create an Event Image.Click += (sender, args) => { try { WoWonderTools.OpenProfile(Activity, MoviesObject.UserData.UserId, MoviesObject.UserData); } catch (Exception e) { Console.WriteLine(e); } }; LikeTextView.Click += delegate { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); return; } if (LikeTextView.Tag.ToString() == "Liked") { LikeTextView.Text = Activity.GetText(Resource.String.Btn_Like); LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff") : Color.ParseColor("#000000")); LikeTextView.Tag = "Like"; MoviesObject.IsCommentLiked = false; //sent api Dislike comment PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Movies.LikeUnLikeCommentAsync(MoviesObject.MovieId, MoviesObject.Id, false) }); } else { LikeTextView.Text = Activity.GetText(Resource.String.Btn_Liked); LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); LikeTextView.Tag = "Liked"; MoviesObject.IsCommentLiked = true; //sent api Dislike comment PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Movies.LikeUnLikeCommentAsync(MoviesObject.MovieId, MoviesObject.Id, false) }); } } catch (Exception e) { Console.WriteLine(e); } }; } catch (Exception e) { Console.WriteLine(e); } }
private static void LoadCommentData(CommentsArticlesObject item, RecyclerView.ViewHolder viewHolder, int position = 0) { try { if (!(viewHolder is ArticlesCommentAdapterViewHolder holder)) { return; } if (AppSettings.FlowDirectionRightToLeft) { holder.BubbleLayout.LayoutDirection = LayoutDirection.Rtl; } var changer = new TextSanitizer(holder.CommentText, ActivityContext); changer.Load(Methods.FunString.DecodeString(item.Text)); holder.TimeTextView.Text = Methods.Time.TimeAgo(int.Parse(item.Posted)); holder.UserName.Text = item.UserData.Name; GlideImageLoader.LoadImage(ActivityContext, item.UserData.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); var textHighLighter = item.UserData.Name; var textIsPro = string.Empty; if (item.UserData.Verified == "1") { textHighLighter += " " + IonIconsFonts.CheckmarkCircled; } if (item.UserData.IsPro == "1") { textIsPro = " " + IonIconsFonts.Flash; textHighLighter += textIsPro; } var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter).SetTextStyle((int)TypefaceStyle.Bold, 0, item.UserData.Name.Length); if (item.UserData.Verified == "1") { decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled); } if (item.UserData.IsPro == "1") { decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro); } decorator.Build(); if (item.Replies?.Count > 0) { holder.ReplyTextView.Text = ActivityContext.GetText(Resource.String.Lbl_Reply) + " " + "(" + item.Replies.Count + ")"; } if (item.IsCommentLiked) { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; } else { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff"): Color.ParseColor("#000000")); holder.LikeTextView.Tag = "Like"; } holder.TimeTextView.Tag = "true"; if (holder.Image.HasOnClickListeners) { return; } var postEventListener = new ArticlesCommentClickListener(ActivityContext, Type); //Create an Event holder.MainView.LongClick += (sender, e) => postEventListener.MoreCommentReplyPostClick(new CommentReplyArticlesClickEventArgs { CommentObject = item, Position = position, View = holder.MainView }); holder.Image.Click += (sender, args) => postEventListener.ProfileClick(new CommentReplyArticlesClickEventArgs { Holder = holder, CommentObject = item, Position = position, View = holder.MainView }); switch (Type) { case "Comment": holder.ReplyTextView.Click += (sender, args) => ArticlesViewActivity.GetInstance()?.CommentReplyClick(item); break; case "Reply": holder.ReplyTextView.Click += (sender, args) => ArticlesViewActivity.GetInstance()?.ReplyOnReplyClick(item); break; } holder.LikeTextView.Click += delegate { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); return; } if (holder.LikeTextView.Tag.ToString() == "Liked") { item.IsCommentLiked = false; holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme? Color.ParseColor("#ffffff"): Color.ParseColor("#000000")); holder.LikeTextView.Tag = "Like"; //sent api Dislike comment reply_like switch (Type) { case "Comment": PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Article.LikeUnLikeCommentAsync(item.BlogId, item.Id, false) }); break; case "Reply": PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Article.LikeUnLikeCommentAsync(item.BlogId, item.Id, false, "reply_like") }); break; } } else { item.IsCommentLiked = true; holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; //sent api like comment switch (Type) { case "Comment": PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Article.LikeUnLikeCommentAsync(item.BlogId, item.Id, true) }); break; case "Reply": PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Article.LikeUnLikeCommentAsync(item.BlogId, item.Id, true, "reply_like") }); break; } } } catch (Exception e) { Console.WriteLine(e); } }; } catch (Exception e) { Console.WriteLine(e); } }
//Click save data and sent api private async void BtnSaveOnClick(object sender, EventArgs e) { try { if (Methods.CheckConnectivity()) { //Show a progress AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading)); var dictionary = new Dictionary <string, string> { { "name", EdtFullName.Text }, { "about_me", EdtAbout.Text }, { "facebook", EdtFacebook.Text }, { "website", EdtWebsite.Text }, }; if (string.IsNullOrEmpty(dictionary["website"])) { dictionary["website"] = "https://www.example.com/"; } (int apiStatus, var respond) = await RequestsAsync.User.UpdateProfileAsync(UserDetails.UserId.ToString(), dictionary); if (apiStatus == 200) { if (respond is MessageObject result) { Console.WriteLine(result.Message); var local = ListUtils.MyUserInfoList.FirstOrDefault(a => a.Id == UserDetails.UserId); if (local != null) { local.Name = EdtFullName.Text; local.About = EdtAbout.Text; local.Facebook = EdtFacebook.Text; local.Website = EdtWebsite.Text; TextSanitizer aboutSanitizer = new TextSanitizer(HomeActivity.GetInstance()?.ProfileFragment.TxtAbout, this); aboutSanitizer.Load(Methods.FunString.DecodeString(EdtAbout.Text)); SqLiteDatabase database = new SqLiteDatabase(); database.InsertOrUpdate_DataMyInfo(local); database.Dispose(); } Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Short).Show(); AndHUD.Shared.Dismiss(this); Intent returnIntent = new Intent(); returnIntent.PutExtra("name", dictionary["name"]); returnIntent.PutExtra("about_me", dictionary["about_me"]); returnIntent.PutExtra("facebook", dictionary["facebook"]); returnIntent.PutExtra("website", dictionary["website"]); SetResult(Result.Ok, returnIntent); Finish(); } } else { if (respond is ErrorObject error) { var errorText = error.Error.Replace("'", "'"); AndHUD.Shared.ShowError(this, errorText, MaskType.Clear, TimeSpan.FromSeconds(2)); } Methods.DisplayReportResult(this, respond); } AndHUD.Shared.Dismiss(this); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception exception) { Console.WriteLine(exception); AndHUD.Shared.Dismiss(this); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (viewHolder.ItemViewType == 666) { if (!(viewHolder is MainHolders.EmptyStateAdapterViewHolder emptyHolder)) { return; } emptyHolder.EmptyText.Text = "No Replies to be displayed"; return; } if (!(viewHolder is ReplyCommentAdapterViewHolder holder)) { return; } var item = ReplyCommentList[position]; if (item == null) { return; } if (AppSettings.FlowDirectionRightToLeft) { holder.BubbleLayout.LayoutDirection = LayoutDirection.Rtl; } if (!string.IsNullOrEmpty(item.Text) || !string.IsNullOrWhiteSpace(item.Text)) { var changer = new TextSanitizer(holder.CommentText, ActivityContext); changer.Load(Methods.FunString.DecodeString(item.Text)); } else { holder.CommentText.Visibility = ViewStates.Gone; } if (holder.TimeTextView.Tag?.ToString() == "true") { return; } holder.TimeTextView.Text = Methods.Time.TimeAgo(int.Parse(item.Time)); holder.UserName.Text = item.Publisher.Name; GlideImageLoader.LoadImage(ActivityContext, item.Publisher.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Color); var textHighLighter = item.Publisher.Name; var textIsPro = string.Empty; if (item.Publisher.Verified == "1") { textHighLighter += " " + IonIconsFonts.CheckmarkCircled; } if (item.Publisher.IsPro == "1") { textIsPro = " " + IonIconsFonts.Flash; textHighLighter += textIsPro; } var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter) .SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length); if (item.Publisher.Verified == "1") { decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled); } if (item.Publisher.IsPro == "1") { decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro); } decorator.Build(); if (holder.ItemViewType == 1) { if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/"))) { File file2 = new File(item.CFile); var photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2); Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage); //GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color); } else { GlideImageLoader.LoadImage(ActivityContext, Client.WebsiteUrl + "/" + item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color); } } if (item.IsCommentLiked) { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; } else { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); if (AppSettings.SetTabDarkTheme) { holder.LikeTextView.SetTextColor(Color.ParseColor("#ffffff")); } else { holder.LikeTextView.SetTextColor(Color.ParseColor("#000000")); } holder.LikeTextView.Tag = "Like"; } holder.TimeTextView.Tag = "true"; if (holder.Image.HasOnClickListeners) { return; } var postEventListener = new CommentClickListener(ActivityContext, "Reply"); //Create an Event holder.MainView.LongClick += (sender, e) => postEventListener.MoreCommentReplyPostClick(new CommentReplyClickEventArgs { CommentObject = item, Position = position, View = holder.MainView }); holder.Image.Click += (sender, args) => postEventListener.ProfilePostClick(new ProfileClickEventArgs { Holder = holder, CommentClass = item, Position = position, View = holder.MainView }); holder.ReplyTextView.Click += (sender, args) => { try { ActivityContext.TxtComment.Text = ""; ActivityContext.TxtComment.Text = "@" + item.Publisher.Username + " "; } catch (Exception e) { Console.WriteLine(e); } }; holder.LikeTextView.Click += delegate { try { if (holder.LikeTextView.Tag.ToString() == "Liked") { item.IsCommentLiked = false; holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); if (AppSettings.SetTabDarkTheme) { holder.LikeTextView.SetTextColor(Color.ParseColor("#ffffff")); } else { holder.LikeTextView.SetTextColor(Color.ParseColor("#000000")); } holder.LikeTextView.Tag = "Like"; //sent api Dislike comment PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Comment.LikeUnLikeCommentAsync(item.Id, false) }); } else { item.IsCommentLiked = true; holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; //sent api like comment PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Comment.LikeUnLikeCommentAsync(item.Id, true) }); } } catch (Exception e) { Console.WriteLine(e); } }; holder.CommentImage.Click += (sender, args) => postEventListener.OpenImageLightBox(item); } catch (Exception exception) { Console.WriteLine(exception); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (viewHolder is ReplyAdapterViewHolder holder) { var item = ReplyList[position]; if (item != null) { holder.UnLikeButton.Visibility = ViewStates.Gone; GlideImageLoader.LoadImage(ActivityContext, item.ReplyUserData.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); TextSanitizer chnager = new TextSanitizer(holder.CommentText, ActivityContext); chnager.Load(Methods.FunString.DecodeString(item.Text)); holder.TimeTextView.Text = item.TextTime; holder.UsernameTextView.Text = AppTools.GetNameFinal(item.ReplyUserData); holder.LikeNumber.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(item.ReplyLikes)); holder.UnLikeNumber.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(item.ReplyDislikes)); holder.RepliesCount.Visibility = ViewStates.Invisible; if (item.IsLikedReply == 1) { holder.LikeiconView.SetColorFilter(Color.ParseColor(AppSettings.MainColor)); holder.LikeButton.Tag = "1"; } else { holder.LikeButton.Tag = "0"; } if (item.IsDislikedReply == 1) { holder.UnLikeiconView.SetColorFilter(Color.ParseColor(AppSettings.MainColor)); holder.UnLikeButton.Tag = "1"; } else { holder.UnLikeButton.Tag = "0"; } if (!holder.Image.HasOnClickListeners) { holder.Image.Click += (sender, e) => OnAvatarClick(new AvatarReplyAdapterClickEventArgs { Class = item, Position = position, View = holder.MainView }); } if (!holder.LikeButton.HasOnClickListeners) { holder.LikeButton.Click += (sender, e) => OnLikeButtonClick(holder, new ReplyAdapterClickEventArgs { Class = item, Position = position, View = holder.MainView }); } if (!holder.UnLikeButton.HasOnClickListeners) { holder.UnLikeButton.Click += (sender, e) => OnUnLikeButtonClick(holder, new ReplyAdapterClickEventArgs { Class = item, Position = position, View = holder.MainView }); } if (!holder.ReplyButton.HasOnClickListeners) { holder.ReplyButton.Click += (sender, e) => OnReplyClick(new ReplyAdapterClickEventArgs { Class = item, Position = position, View = holder.MainView }); } } } } catch (Exception exception) { Console.WriteLine(exception); } }
private void InitComponent(View view) { try { ProfileFeedRecylerView = (RecyclerView)view.FindViewById(Resource.Id.RecylerFeed); AppBarLayoutView = (AppBarLayout)view.FindViewById(Resource.Id.appBarLayout); CollapsingToolbarLayoutView = (CollapsingToolbarLayout)view.FindViewById(Resource.Id.collapsingToolbarLayout); FeedTextView = (TextView)view.FindViewById(Resource.Id.feed); ProgressBarLoader = (ProgressBar)view.FindViewById(Resource.Id.sectionProgress); EmptyStateLayout = view.FindViewById <ViewStub>(Resource.Id.viewStub); LinFollowers = view.FindViewById <LinearLayout>(Resource.Id.layoutFollowers); LinFollowing = view.FindViewById <LinearLayout>(Resource.Id.layoutFollowing); UserProfileImage = (ImageView)view.FindViewById(Resource.Id.user_pic); Fullname = (TextView)view.FindViewById(Resource.Id.fullname); Username = (TextView)view.FindViewById(Resource.Id.username); TxtCountFollowers = (TextView)view.FindViewById(Resource.Id.CountFollowers); TxtCountFollowing = (TextView)view.FindViewById(Resource.Id.CountFollowing); TxtCountFav = (TextView)view.FindViewById(Resource.Id.CountFav); TxtFollowers = view.FindViewById <TextView>(Resource.Id.txtFollowers); TxtFollowing = view.FindViewById <TextView>(Resource.Id.txtFollowing); TxtFav = view.FindViewById <TextView>(Resource.Id.txtFav); SocialGoogle = view.FindViewById <Button>(Resource.Id.social1); SocialFacebook = view.FindViewById <Button>(Resource.Id.social2); SocialTwitter = view.FindViewById <Button>(Resource.Id.social3); SocialLinkedIn = view.FindViewById <Button>(Resource.Id.social4); WebsiteButton = view.FindViewById <Button>(Resource.Id.website); FollowButton = view.FindViewById <Button>(Resource.Id.followButton); MessageButton = view.FindViewById <Button>(Resource.Id.messageButton); About = view.FindViewById <AutoLinkTextView>(Resource.Id.aboutdescUser); AboutLiner = view.FindViewById <LinearLayout>(Resource.Id.aboutliner); Morebutton = view.FindViewById <ImageButton>(Resource.Id.morebutton); IconVerified = (TextView)view.FindViewById(Resource.Id.verified); IconBusiness = (TextView)view.FindViewById(Resource.Id.business); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, IconVerified, IonIconsFonts.CheckmarkCircled); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, IconBusiness, IonIconsFonts.SocialUsd); IconVerified.Visibility = ViewStates.Gone; IconBusiness.Visibility = ViewStates.Gone; Morebutton.SetColorFilter(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); //UserProfileImage.SetBackgroundResource(AppSettings.SetTabDarkTheme ? Resource.Drawable.layout_bg_profile_friends_dark : Resource.Drawable.layout_bg_profile_friends); TextSanitizerAutoLink = new TextSanitizer(About, Activity); TextView viewboxText = view.FindViewById <TextView>(Resource.Id.Appname); viewboxText.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); TxtCountFollowers.Text = "0"; TxtCountFollowing.Text = "0"; TxtCountFav.Text = "0"; SocialLinkedIn.Visibility = ViewStates.Gone; AppBarLayoutView.AddOnOffsetChangedListener(this); } catch (Exception e) { Console.WriteLine(e); } }
public void SetDataDynamicForViewHolder(View itemView, TextView username, ImageView userAvatar, AutoLinkTextView description, TextView likeIcon, TextView favIcon, TextView commentCount, TextView likeCount, TextView viewMoreComments, TextView timeText, TextView commentIcon, TextView moreIcon, TextView shareIcon, TextView isBoostedIcon, PostsObject item) { try { if (item == null) { return; } TextSanitizerAutoLink = new TextSanitizer(description, ActivityContext); GlideImageLoader.LoadImage(ActivityContext, item.Avatar, userAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); username.Text = item.Username; string time = Methods.Time.TimeAgo(Convert.ToInt32(item.Time)); timeText.Text = time; if (!string.IsNullOrEmpty(description.Text)) { ReadMoreOption.AddReadMoreTo(description, item.Description); TextSanitizerAutoLink.Load(item.Description); } else { description.Visibility = ViewStates.Gone; } if (item.Boosted == "1") { FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, isBoostedIcon, IonIconsFonts.RibbonA); isBoostedIcon.Text += " " + ActivityContext.GetString(Resource.String.Lbl_Promoted); isBoostedIcon.Visibility = ViewStates.Visible; } likeIcon.Tag = item.IsLiked ? "Like" : "Liked"; ClickListeners.SetLike(likeIcon); favIcon.Tag = item.IsSaved ? "Add" : "Added"; ClickListeners.SetFav(favIcon); commentCount.Text = item.Votes + " " + ActivityContext.GetString(Resource.String.Lbl_Comments); likeCount.Text = item.Likes + " " + ActivityContext.GetString(Resource.String.Lbl_Likes); if (item.Votes > 0) { viewMoreComments.Visibility = ViewStates.Visible; viewMoreComments.Text = ActivityContext.GetString(Resource.String.Lbl_ShowAllComments); } else { viewMoreComments.Visibility = ViewStates.Gone; } if (!commentCount.HasOnClickListeners) { commentCount.Click += (sender, e) => ClickListeners.OnCommentPostClick(new CommentFeedClickEventArgs { View = itemView, NewsFeedClass = item }, "NewsFeedPost"); } if (!likeCount.HasOnClickListeners) { likeCount.Click += (sender, e) => ClickListeners.OnLikedPostClick(new LikeNewsFeedClickEventArgs { View = itemView, NewsFeedClass = item, LikeButton = likeCount }); } if (!likeIcon.HasOnClickListeners) { likeIcon.Click += (sender, e) => ClickListeners.OnLikeNewsFeedClick(new LikeNewsFeedClickEventArgs { View = itemView, NewsFeedClass = item, LikeButton = likeIcon }); } if (!favIcon.HasOnClickListeners) { favIcon.Click += (sender, e) => ClickListeners.OnFavNewsFeedClick(new FavNewsFeedClickEventArgs { NewsFeedClass = item, FavButton = favIcon }); } if (!userAvatar.HasOnClickListeners) { userAvatar.Click += (sender, e) => ClickListeners.OnAvatarImageFeedClick(new AvatarFeedClickEventArgs { NewsFeedClass = item, Image = userAvatar, View = itemView }, "NewsFeedPost"); } if (!commentIcon.HasOnClickListeners) { commentIcon.Click += (sender, e) => ClickListeners.OnCommentClick(new CommentFeedClickEventArgs { NewsFeedClass = item, View = itemView }, "NewsFeedPost"); } if (!viewMoreComments.HasOnClickListeners) { viewMoreComments.Click += (sender, e) => ClickListeners.OnCommentClick(new CommentFeedClickEventArgs { NewsFeedClass = item, View = itemView }, "NewsFeedPost"); } if (!moreIcon.HasOnClickListeners) { moreIcon.Click += (sender, e) => ClickListeners.OnMoreClick(new MoreFeedClickEventArgs { NewsFeedClass = item, View = itemView, IsOwner = item.IsOwner }, true, "NewsFeedPost"); } if (!shareIcon.HasOnClickListeners) { shareIcon.Click += (sender, e) => ClickListeners.OnShareClick(new ShareFeedClickEventArgs { NewsFeedClass = item, View = itemView }); } } catch (Exception e) { Console.WriteLine(e); } }
public void LoadCommentData(CommentObjectExtra item, CommentAdapterViewHolder holder, int position = 0, bool hasClickEvents = true) { try { if (!string.IsNullOrEmpty(item.Text) || !string.IsNullOrWhiteSpace(item.Text)) { var changer = new TextSanitizer(holder.CommentText, ActivityContext); changer.Load(Methods.FunString.DecodeString(item.Text)); } else { holder.CommentText.Visibility = ViewStates.Gone; } holder.TimeTextView.Text = Methods.Time.TimeAgo(int.Parse(item.Time)); holder.UserName.Text = item.Publisher.Name; GlideImageLoader.LoadImage(ActivityContext, item.Publisher.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); var textHighLighter = item.Publisher.Name; var textIsPro = string.Empty; if (item.Publisher.Verified == "1") { textHighLighter += " " + IonIconsFonts.CheckmarkCircled; } if (item.Publisher.IsPro == "1") { textIsPro = " " + IonIconsFonts.Flash; textHighLighter += textIsPro; } var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter).SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length); if (item.Publisher.Verified == "1") { decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled); } if (item.Publisher.IsPro == "1") { decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro); } decorator.Build(); //Image if (holder.ItemViewType == 1 || holder.CommentImage != null) { if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/"))) { File file2 = new File(item.CFile); var photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2); Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage); //GlideImageLoader.LoadImage(ActivityContext,item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color); } else { if (!item.CFile.Contains(Client.WebsiteUrl)) { item.CFile = WoWonderTools.GetTheFinalLink(item.CFile); } GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color); } } //Voice if (holder.VoiceLayout != null && !string.IsNullOrEmpty(item.Record)) { LoadAudioItem(holder, position, item); } if (item.Replies != "0" && item.Replies != null) { holder.ReplyTextView.Text = ActivityContext.GetText(Resource.String.Lbl_Reply) + " " + "(" + item.Replies + ")"; } if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine) { item.Reaction ??= new WoWonderClient.Classes.Posts.Reaction(); if ((bool)(item.Reaction != null & item.Reaction?.IsReacted)) { if (!string.IsNullOrEmpty(item.Reaction.Type)) { switch (item.Reaction.Type) { case "1": case "Like": ReactionComment.SetReactionPack(holder, ReactConstants.Like); holder.LikeTextView.Tag = "Liked"; break; case "2": case "Love": ReactionComment.SetReactionPack(holder, ReactConstants.Love); holder.LikeTextView.Tag = "Liked"; break; case "3": case "HaHa": ReactionComment.SetReactionPack(holder, ReactConstants.HaHa); holder.LikeTextView.Tag = "Liked"; break; case "4": case "Wow": ReactionComment.SetReactionPack(holder, ReactConstants.Wow); holder.LikeTextView.Tag = "Liked"; break; case "5": case "Sad": ReactionComment.SetReactionPack(holder, ReactConstants.Sad); holder.LikeTextView.Tag = "Liked"; break; case "6": case "Angry": ReactionComment.SetReactionPack(holder, ReactConstants.Angry); holder.LikeTextView.Tag = "Liked"; break; default: holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.LikeTextView.Tag = "Like"; break; } } } else { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.LikeTextView.Tag = "Like"; } } else if (AppSettings.PostButton == PostButtonSystem.Wonder || AppSettings.PostButton == PostButtonSystem.DisLike) { if ((bool)(item.Reaction != null & !item.Reaction?.IsReacted)) { ReactionComment.SetReactionPack(holder, ReactConstants.Default); } if (item.IsCommentLiked) { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; } switch (AppSettings.PostButton) { case PostButtonSystem.Wonder when item.IsCommentWondered: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_wondered); holder.DislikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.DislikeTextView.Tag = "Disliked"; break; } case PostButtonSystem.Wonder: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Wonder); holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.DislikeTextView.Tag = "Dislike"; break; } case PostButtonSystem.DisLike when item.IsCommentWondered: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_disliked); holder.DislikeTextView.SetTextColor(Color.ParseColor("#f89823")); holder.DislikeTextView.Tag = "Disliked"; break; } case PostButtonSystem.DisLike: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Dislike); holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.DislikeTextView.Tag = "Dislike"; break; } } } else { if (item.IsCommentLiked) { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; } else { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.LikeTextView.Tag = "Like"; } } holder.TimeTextView.Tag = "true"; } catch (Exception e) { Console.WriteLine(e); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (viewHolder is CommentAdapterViewHolder holder) { var item = CommentList[position]; if (item != null) { TextSanitizer changer = new TextSanitizer(holder.CommentText, ActivityContext); changer.Load(Methods.FunString.DecodeString(item.Text)); holder.TimeTextView.Text = Methods.Time.TimeAgo(Convert.ToInt32(item.Time)); GlideImageLoader.LoadImage(ActivityContext, item.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Color); if (item.Replies != 0) { holder.ReplyButton.Text = ActivityContext.GetString(Resource.String.Lbl_Reply) + " " + "(" + item.Replies + ")"; } else { holder.ReplyButton.Text = ActivityContext.GetString(Resource.String.Lbl_Reply); } holder.LikeCount.Text = ActivityContext.GetString(Resource.String.Lbl_Likes) + " " + "(" + item.Likes + ")"; if (!holder.Image.HasOnClickListeners) { holder.Image.Click += (sender, e) => OnAvatarClick(new AvatarCommentAdapterClickEventArgs { Class = item, Position = position, View = holder.MainView }); } holder.LikeIcon.SetImageResource(item.IsLiked ? Resource.Drawable.ic_action_like_2 : Resource.Drawable.ic_action_like_1); if (!holder.LikeIcon.HasOnClickListeners) { MyBounceInterpolator interpolator = new MyBounceInterpolator(0.2, 20); var animationScale = AnimationUtils.LoadAnimation(ActivityContext, Resource.Animation.scale); animationScale.Interpolator = interpolator; holder.LikeIcon.Click += (sender, args) => { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(ActivityContext, ActivityContext.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show(); } else { item.IsLiked = !item.IsLiked; holder.LikeIcon.SetImageResource(item.IsLiked? Resource.Drawable.ic_action_like_2: Resource.Drawable.ic_action_like_1); holder.LikeIcon.StartAnimation(animationScale); if (item.IsLiked) { Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("reaction.mp3"); int x = int.Parse(item.Likes) + 1; holder.LikeCount.Text = ActivityContext.GetString(Resource.String.Lbl_Likes) + " " + "(" + x.ToString() + ")"; } else { int x = int.Parse(item.Likes); if (x > 0) { x--; } else { x = 0; } item.Likes = x.ToString(); holder.LikeCount.Text = ActivityContext.GetString(Resource.String.Lbl_Likes) + " " + "(" + item.Likes + ")"; } RequestsAsync.Post.LikeComment(item.Id.ToString()).ConfigureAwait(false); } } catch (Exception e) { Console.WriteLine(e); } }; } if (!holder.ReplyButton.HasOnClickListeners) { holder.ReplyButton.Click += (sender, args) => ClickListeners.CommentReplyPostClick(new CommentReplyClickEventArgs { CommentObject = item, Position = position, View = holder.MainView }); } } if (AppSettings.SetTabDarkTheme) { holder.LikeIcon.SetBackgroundResource(Resource.Drawable.Shape_Circle_Black); } } } catch (Exception exception) { Console.WriteLine(exception); } }
private async Task LoadDataAsync() { if (Methods.CheckConnectivity()) { var channel = await ApiRequest.GetChannelData(Activity, IdChannel); if (channel != null) { TextSanitizer text = new TextSanitizer(TxtAboutChannel, Activity, GlobalContext); text.Load(AppTools.GetAboutFinal(channel)); if (channel.Gender == "male" || channel.Gender == "Male") { TxtGender.Text = GetText(Resource.String.Radio_Male); } else { TxtGender.Text = GetText(Resource.String.Radio_Female); } TxtEmail.Text = channel.Email; Facebook = channel.Facebook; Google = channel.Google; Twitter = channel.Twitter; if (string.IsNullOrEmpty(channel.Facebook)) { BtnFacebook.Enabled = false; BtnFacebook.SetColor(Color.ParseColor("#8c8a8a")); } else { BtnFacebook.Enabled = true; } if (string.IsNullOrEmpty(channel.Twitter)) { BtnTwitter.Enabled = false; BtnTwitter.SetColor(Color.ParseColor("#8c8a8a")); } else { BtnTwitter.Enabled = true; } if (string.IsNullOrEmpty(channel.Google)) { BtnGoogle.Enabled = false; BtnGoogle.SetColor(Color.ParseColor("#8c8a8a")); } else { BtnGoogle.Enabled = true; } if (IdChannel == UserDetails.UserId) { var idCurrency = ListUtils.MySettingsList?.PaymentCurrency; var(currency, currencyIcon) = AppTools.GetCurrency(idCurrency); Console.WriteLine(currencyIcon); TxtMonetization.Text = channel.Balance + " " + currency; } } } else { Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } }
private void InitComponent(View view) { try { UserProfileImage = (ImageView)view.FindViewById(Resource.Id.user_pic); ImgSetting = (ImageView)view.FindViewById(Resource.Id.settingsbutton); ImgChange = (TextView)view.FindViewById(Resource.Id.IconAdd); ImgSetting.SetColorFilter(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); SwipeRefreshLayout = (SpringView)view.FindViewById(Resource.Id.material_style_ptr_frame); TxtName = (TextView)view.FindViewById(Resource.Id.card_name); TxtUsername = (TextView)view.FindViewById(Resource.Id.card_dist); BtnEditProfile = (Button)view.FindViewById(Resource.Id.cont); TxtCountFollowers = (TextView)view.FindViewById(Resource.Id.CountFollowers); TxtCountFollowing = (TextView)view.FindViewById(Resource.Id.CountFollowing); TxtCountFav = (TextView)view.FindViewById(Resource.Id.CountFav); TxtFollowers = view.FindViewById <TextView>(Resource.Id.txtFollowers); TxtFollowing = view.FindViewById <TextView>(Resource.Id.txtFollowing); TxtFav = view.FindViewById <TextView>(Resource.Id.txtFav); LinFollowers = view.FindViewById <LinearLayout>(Resource.Id.layoutFollowers); LinFollowing = view.FindViewById <LinearLayout>(Resource.Id.layoutFollowing); LinFavorites = view.FindViewById <LinearLayout>(Resource.Id.layoutFavorites); IconVerified = (TextView)view.FindViewById(Resource.Id.verified); IconBusiness = (TextView)view.FindViewById(Resource.Id.business); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, IconVerified, IonIconsFonts.CheckmarkCircled); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, IconBusiness, IonIconsFonts.SocialUsd); IconVerified.Visibility = ViewStates.Gone; IconBusiness.Visibility = ViewStates.Gone; Layoutfriends = (RelativeLayout)view.FindViewById(Resource.Id.layoutfriends); //Layoutfriends.SetBackgroundResource(AppSettings.SetTabDarkTheme ? Resource.Drawable.layout_bg_profile_friends_dark : Resource.Drawable.layout_bg_profile_friends); TxtAbout = (AutoLinkTextView)view.FindViewById(Resource.Id.description); TextSanitizerAutoLink = new TextSanitizer(TxtAbout, Activity); TxtCountFollowers.Text = "0"; TxtCountFollowing.Text = "0"; TxtCountFav.Text = "0"; EmptyStateLayout = (ViewStub)view.FindViewById(Resource.Id.viewStub); SwipeRefreshLayout = (SpringView)view.FindViewById(Resource.Id.material_style_ptr_frame); SwipeRefreshLayout.SetType(SpringView.Type.Overlap); SwipeRefreshLayout.Header = new PixelDefaultHeader(Activity); SwipeRefreshLayout.Footer = new PixelDefaultFooter(Activity); SwipeRefreshLayout.Enable = true; SwipeRefreshLayout.SetListener(this); } catch (Exception e) { Console.WriteLine(e); } }