private void PresenterSourceChanged(Status status) { if (!IsInitialized) { return; } Activity.RunOnUiThread(() => { _adapter.NotifyDataSetChanged(); }); }
private void SwipeRefreshLayoutOnRefresh(object sender, EventArgs e) { try { CommentsAdapter.CommentList.Clear(); CommentsAdapter.NotifyDataSetChanged(); StartApiService(); } catch (Exception exception) { Console.WriteLine(exception); } }
private async Task LoadDataComment(string offset = "0") { switch (MainScrollEvent.IsLoading) { case true: return; } if (Methods.CheckConnectivity()) { MainScrollEvent.IsLoading = true; var(apiStatus, respond) = await RequestsAsync.Comment.GetPostCommentsAsync(PostId, "10", offset); if (apiStatus != 200 || respond is not CommentObject result || result.CommentList == null) { MainScrollEvent.IsLoading = false; Methods.DisplayReportResult(this, respond); } else { var respondList = result.CommentList?.Count; switch (respondList) { case > 0: { foreach (var item in result.CommentList) { CommentObjectExtra check = MAdapter.CommentList.FirstOrDefault(a => a.Id == item.Id); switch (check) { case null: { var db = ClassMapper.Mapper?.Map <CommentObjectExtra>(item); if (db != null) { MAdapter.CommentList.Add(db); } break; } default: check = ClassMapper.Mapper?.Map <CommentObjectExtra>(item); check.Replies = item.Replies; check.RepliesCount = item.RepliesCount; break; } } RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); break; } } } RunOnUiThread(ShowEmptyPage); }
private async Task LoadDataComment(string offset) { if (Methods.CheckConnectivity()) { int countList = MAdapter.CommentList.Count; (int apiStatus, var respond) = await RequestsAsync.Comment.GetPostComments(PostId, "10", offset); if (apiStatus != 200 || !(respond is CommentObject result) || result.CommentList == null) { Methods.DisplayReportResult(this, respond); } else { var respondList = result.CommentList?.Count; if (respondList > 0) { foreach (var item in from item in result.CommentList let check = MAdapter.CommentList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { var db = ClassMapper.Mapper?.Map <CommentObjectExtra>(item); if (db != null) { MAdapter.CommentList.Add(db); } } if (countList > 0) { RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList, MAdapter.CommentList.Count - countList); }); } else { RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); }); } } } RunOnUiThread(ShowEmptyPage2); } }
//Refresh private void SwipeRefreshLayoutOnRefresh(object sender, EventArgs e) { try { MAdapter.CommentList.Clear(); MAdapter.NotifyDataSetChanged(); MainScrollEvent.IsLoading = false; StartApiService(); } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
private void LoadPost() { try { PostObject = JsonConvert.DeserializeObject <PostDataObject>(Intent?.GetStringExtra("PostObject")); if (PostObject != null) { var readMoreOption = new StReadMoreOption.Builder() .TextLength(200, StReadMoreOption.TypeCharacter) .MoreLabel(GetText(Resource.String.Lbl_ReadMore)) .LessLabel(GetText(Resource.String.Lbl_ReadLess)) .MoreLabelColor(Color.ParseColor(AppSettings.MainColor)) .LessLabelColor(Color.ParseColor(AppSettings.MainColor)) .LabelUnderLine(true) .Build(); if (SecondReactionButton != null) { switch (AppSettings.PostButton) { case PostButtonSystem.ReactionDefault: case PostButtonSystem.ReactionSubShine: case PostButtonSystem.Like: MainSectionButton.WeightSum = 3; SecondReactionButton.Visibility = ViewStates.Gone; break; case PostButtonSystem.Wonder: MainSectionButton.WeightSum = 4; SecondReactionButton.Visibility = ViewStates.Visible; SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_action_wowonder, 0, 0, 0); SecondReactionButton.Text = Application.Context.GetText(Resource.String.Btn_Wonder); break; case PostButtonSystem.DisLike: MainSectionButton.WeightSum = 4; SecondReactionButton.Visibility = ViewStates.Visible; SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_action_dislike, 0, 0, 0); SecondReactionButton.Text = Application.Context.GetText(Resource.String.Btn_Dislike); break; default: MainSectionButton.WeightSum = 3; SecondReactionButton.Visibility = ViewStates.Gone; break; } } var publisher = PostObject.Publisher ?? PostObject.UserData; if (publisher != null) { if (PostObject.PostPrivacy == "4") { Username.Text = GetText(Resource.String.Lbl_Anonymous); GlideImageLoader.LoadImage(this, "user_anonymous", UserAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); } else { GlideImageLoader.LoadImage(this, publisher.Avatar, UserAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); var postDataDecoratedContent = new WoTextDecorator().SetupStrings(PostObject, this); Username.SetText(postDataDecoratedContent, TextView.BufferType.Spannable); } if (PostExtrasLayout != null) { PostExtrasLayout.Visibility = PostObject.IsPostBoosted == "0" ? ViewStates.Gone : ViewStates.Visible; } if (string.IsNullOrEmpty(PostObject.Orginaltext)) { if (Description.Visibility != ViewStates.Gone) { Description.Visibility = ViewStates.Gone; } } else { if (Description.Visibility != ViewStates.Visible) { Description.Visibility = ViewStates.Visible; } if (!Description.Text.Contains(GetText(Resource.String.Lbl_ReadMore)) && !Description.Text.Contains(GetText(Resource.String.Lbl_ReadLess))) { if (PostObject.RegexFilterList != null & PostObject.RegexFilterList?.Count > 0) { Description.SetAutoLinkOnClickListener(this, PostObject.RegexFilterList); } else { Description.SetAutoLinkOnClickListener(this, new Dictionary <string, string>()); } readMoreOption.AddReadMoreTo(Description, new String(PostObject.Orginaltext)); } else if (Description.Text.Contains(GetText(Resource.String.Lbl_ReadLess))) { readMoreOption.AddReadLess(Description, new String(PostObject.Orginaltext)); } else { Description.Text = PostObject.Orginaltext; } } bool success = int.TryParse(PostObject.Time, out var number); TimeText.Text = success ? Methods.Time.TimeAgo(number, false) : PostObject.Time; if (PrivacyPostIcon != null && !string.IsNullOrEmpty(PostObject.PostPrivacy) && publisher.UserId == UserDetails.UserId) { if (PostObject.PostPrivacy == "0") //Everyone { FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, PrivacyPostIcon, FontAwesomeIcon.Globe); } else if (PostObject.PostPrivacy.Contains("ifollow") || PostObject.PostPrivacy == "2") //People_i_Follow { FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, PrivacyPostIcon, FontAwesomeIcon.User); } else if (PostObject.PostPrivacy.Contains("me") || PostObject.PostPrivacy == "1") //People_Follow_Me { FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, PrivacyPostIcon, FontAwesomeIcon.UserFriends); } else if (PostObject.PostPrivacy == "4") //Anonymous { FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeSolid, PrivacyPostIcon, FontAwesomeIcon.UserSecret); } else //No_body) { FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, PrivacyPostIcon, FontAwesomeIcon.Lock); } PrivacyPostIcon.Visibility = ViewStates.Visible; } if (CommentCount != null) { CommentCount.Text = PostObject.PostComments; } } if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine) { PostObject.Reaction ??= new WoWonderClient.Classes.Posts.Reaction(); if (LikeCount != null) { LikeCount.Text = PostObject?.Reaction?.Count + " " + GetString(Resource.String.Btn_Likes); } if (PostObject.Reaction.IsReacted != null && PostObject.Reaction.IsReacted.Value) { if (!string.IsNullOrEmpty(PostObject.Reaction.Type)) { var react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Id == PostObject.Reaction.Type).Value?.Id ?? ""; switch (react) { case "1": LikeButton.SetReactionPack(ReactConstants.Like); break; case "2": LikeButton.SetReactionPack(ReactConstants.Love); break; case "3": LikeButton.SetReactionPack(ReactConstants.HaHa); break; case "4": LikeButton.SetReactionPack(ReactConstants.Wow); break; case "5": LikeButton.SetReactionPack(ReactConstants.Sad); break; case "6": LikeButton.SetReactionPack(ReactConstants.Angry); break; default: LikeButton.SetReactionPack(ReactConstants.Default); break; } } } else { LikeButton.SetReactionPack(ReactConstants.Default); } } else { if (PostObject.IsLiked != null && PostObject.IsLiked.Value) { LikeButton.SetReactionPack(ReactConstants.Like); } if (LikeCount != null) { LikeCount.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(PostObject.PostLikes)) + " " + GetString(Resource.String.Btn_Likes); } if (SecondReactionButton != null) { switch (AppSettings.PostButton) { case PostButtonSystem.Wonder when PostObject.IsWondered != null && PostObject.IsWondered.Value: { Drawable unwrappedDrawable = AppCompatResources.GetDrawable(this, Resource.Drawable.ic_action_wowonder); Drawable wrappedDrawable = DrawableCompat.Wrap(unwrappedDrawable); if (Build.VERSION.SdkInt <= BuildVersionCodes.Lollipop) { DrawableCompat.SetTint(wrappedDrawable, Color.ParseColor("#f89823")); } else { wrappedDrawable = wrappedDrawable.Mutate(); wrappedDrawable.SetColorFilter(new PorterDuffColorFilter(Color.ParseColor("#f89823"), PorterDuff.Mode.SrcAtop)); } SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(wrappedDrawable, null, null, null); SecondReactionButton.Text = GetString(Resource.String.Lbl_wondered); SecondReactionButton.SetTextColor(Color.ParseColor(AppSettings.MainColor)); break; } case PostButtonSystem.Wonder: { Drawable unwrappedDrawable = AppCompatResources.GetDrawable(this, Resource.Drawable.ic_action_wowonder); Drawable wrappedDrawable = DrawableCompat.Wrap(unwrappedDrawable); if (Build.VERSION.SdkInt <= BuildVersionCodes.Lollipop) { DrawableCompat.SetTint(wrappedDrawable, Color.ParseColor("#666666")); } else { wrappedDrawable = wrappedDrawable.Mutate(); wrappedDrawable.SetColorFilter(new PorterDuffColorFilter(Color.ParseColor("#666666"), PorterDuff.Mode.SrcAtop)); } SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(wrappedDrawable, null, null, null); SecondReactionButton.Text = GetString(Resource.String.Btn_Wonder); SecondReactionButton.SetTextColor(Color.ParseColor("#444444")); break; } case PostButtonSystem.DisLike when PostObject.IsWondered != null && PostObject.IsWondered.Value: { Drawable unwrappedDrawable = AppCompatResources.GetDrawable(this, Resource.Drawable.ic_action_dislike); Drawable wrappedDrawable = DrawableCompat.Wrap(unwrappedDrawable); if (Build.VERSION.SdkInt <= BuildVersionCodes.Lollipop) { DrawableCompat.SetTint(wrappedDrawable, Color.ParseColor("#f89823")); } else { wrappedDrawable = wrappedDrawable.Mutate(); wrappedDrawable.SetColorFilter(new PorterDuffColorFilter(Color.ParseColor("#f89823"), PorterDuff.Mode.SrcAtop)); } SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(wrappedDrawable, null, null, null); SecondReactionButton.Text = GetString(Resource.String.Lbl_disliked); SecondReactionButton.SetTextColor(Color.ParseColor("#f89823")); break; } case PostButtonSystem.DisLike: { Drawable unwrappedDrawable = AppCompatResources.GetDrawable(this, Resource.Drawable.ic_action_dislike); Drawable wrappedDrawable = DrawableCompat.Wrap(unwrappedDrawable); if (Build.VERSION.SdkInt <= BuildVersionCodes.Lollipop) { DrawableCompat.SetTint(wrappedDrawable, Color.ParseColor("#666666")); } else { wrappedDrawable = wrappedDrawable.Mutate(); wrappedDrawable.SetColorFilter(new PorterDuffColorFilter(Color.ParseColor("#666666"), PorterDuff.Mode.SrcAtop)); } SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(wrappedDrawable, null, null, null); SecondReactionButton.Text = GetString(Resource.String.Btn_Dislike); SecondReactionButton.SetTextColor(Color.ParseColor("#444444")); break; } } } } if (PostObject?.GetPostComments?.Count > 0) { var db = ClassMapper.Mapper?.Map <List <CommentObjectExtra> >(PostObject.GetPostComments); MAdapter.CommentList = new ObservableCollection <CommentObjectExtra>(db); } else { MAdapter.CommentList = new ObservableCollection <CommentObjectExtra>(); } MAdapter.NotifyDataSetChanged(); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void LoadDataPost() { try { if (PostObject != null) { PostObject.Reaction ??= new Reaction(); if (PostObject.Reaction != null) { LikeCountBox.Text = PostObject.Reaction.Count + " " + GetString(Resource.String.Btn_Likes); } else { LikeCountBox.Text = "0 " + GetString(Resource.String.Btn_Likes); } if (PostObject.CommentsStatus == "0") { MAdapter.CommentList.Clear(); MAdapter.CommentList.Add(new CommentObjectExtra() { Id = MAdapter.EmptyState, Text = MAdapter.EmptyState, Orginaltext = GetText(Resource.String.Lbl_CommentsAreDisabledBy) + " " + WoWonderTools.GetNameFinal(PostObject.Publisher), }); MAdapter.NotifyDataSetChanged(); CommentLayout.Visibility = ViewStates.Gone; } else { if (PostObject?.GetPostComments?.Count > 0) { var db = Mapper.Map <List <CommentObjectExtra> >(PostObject.GetPostComments); MAdapter.CommentList = new ObservableCollection <CommentObjectExtra>(db); } else { MAdapter.CommentList = new ObservableCollection <CommentObjectExtra>(); } Methods.SetColorEditText(TxtComment, AppSettings.SetTabDarkTheme ? Color.White : Color.Black); if (MAdapter.CommentList.Count > 0) { MAdapter?.NotifyDataSetChanged(); } StartApiService(); } } if (Type == "Normal_Gallery") { // Check if we're running on Android 5.0 or higher if ((int)Build.VERSION.SdkInt < 23) { if (AppSettings.ImageCropping) { OpenDialogGallery(); //requestCode >> 500 => Image Gallery } else { new IntentController(this).OpenIntentImageGallery(GetText(Resource.String.Lbl_SelectPictures)); //requestCode >> 500 => Image Gallery } } else { if (CheckSelfPermission(Manifest.Permission.Camera) == Permission.Granted && CheckSelfPermission(Manifest.Permission.ReadExternalStorage) == Permission.Granted && CheckSelfPermission(Manifest.Permission.WriteExternalStorage) == Permission.Granted) { if (AppSettings.ImageCropping) { OpenDialogGallery(); //requestCode >> 500 => Image Gallery } else { new IntentController(this).OpenIntentImageGallery(GetText(Resource.String.Lbl_SelectPictures)); //requestCode >> 500 => Image Gallery } } else { new PermissionsController(this).RequestPermission(108); } } } } catch (Exception e) { Console.WriteLine(e); } }
private void GetDataPost() { try { if (PostObject != null) { if (PostObject.Reaction == null) { PostObject.Reaction = new Reaction(); } if (PostObject.Reaction != null) { LikeCountBox.Text = PostObject.Reaction.Count + " " + GetString(Resource.String.Btn_Likes); } else { LikeCountBox.Text = "0 " + GetString(Resource.String.Btn_Likes); } if (PostObject.CommentsStatus == "0") { CommentsAdapter.CommentList.Clear(); CommentsAdapter.CommentList.Add(new CommentObjectExtra() { Id = CommentsAdapter.EmptyState, Text = CommentsAdapter.EmptyState, Orginaltext = GetText(Resource.String.Lbl_CommentsAreDisabledBy) + " " + ObeeNetworkTools.GetNameFinal(PostObject.Publisher), }); CommentsAdapter.NotifyDataSetChanged(); CommentLayout.Visibility = ViewStates.Gone; } else { if (PostObject?.GetPostComments?.Count > 0) { var db = Mapper.Map <List <CommentObjectExtra> >(PostObject.GetPostComments); CommentsAdapter.CommentList = new ObservableCollection <CommentObjectExtra>(db); } else { CommentsAdapter.CommentList = new ObservableCollection <CommentObjectExtra>(); } Methods.SetColorEditText(TxtComment, AppSettings.SetTabDarkTheme ? Color.White : Color.Black); if (CommentsAdapter.CommentList.Count > 0) { CommentsAdapter?.NotifyDataSetChanged(); } if (CommentsAdapter.CommentList.Count == 0) { StartApiService(); } } } } catch (Exception e) { Console.WriteLine(e); } }
private void LoadDataPost() { try { if (PostObject != null) { PostObject.Reaction ??= new Reaction(); if (PostObject.Reaction != null) { LikeCountBox.Text = PostObject.Reaction.Count + " " + GetString(Resource.String.Btn_Likes); } else { LikeCountBox.Text = "0 " + GetString(Resource.String.Btn_Likes); } if (PostObject.CommentsStatus == "0") { MAdapter.CommentList.Clear(); MAdapter.CommentList.Add(new CommentObjectExtra { Id = MAdapter.EmptyState, Text = MAdapter.EmptyState, Orginaltext = GetText(Resource.String.Lbl_CommentsAreDisabledBy) + " " + WoWonderTools.GetNameFinal(PostObject.Publisher), }); MAdapter.NotifyDataSetChanged(); CommentLayout.Visibility = ViewStates.Gone; } else { if (PostObject?.GetPostComments?.Count > 0) { var db = ClassMapper.Mapper?.Map <List <CommentObjectExtra> >(PostObject.GetPostComments); MAdapter.CommentList = new ObservableCollection <CommentObjectExtra>(db); } else { MAdapter.CommentList = new ObservableCollection <CommentObjectExtra>(); } Methods.SetColorEditText(TxtComment, AppSettings.SetTabDarkTheme ? Color.White : Color.Black); if (MAdapter.CommentList.Count > 0) { MAdapter?.NotifyDataSetChanged(); } StartApiService(); } } if (Type == "Normal_Gallery") { OpenDialogGallery(); //requestCode >> 500 => Image Gallery } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }