Esempio n. 1
0
        /// <summary>
        /// Show Reaction dialog when user long click on react button
        /// </summary>
        public void ClickDialog(CommentReplyClickEventArgs postData)
        {
            try
            {
                PostData = postData;

                //Show Dialog With 6 React
                Android.Support.V7.App.AlertDialog.Builder dialogBuilder = new Android.Support.V7.App.AlertDialog.Builder(MainContext);

                //Irrelevant code for customizing the buttons and title
                LayoutInflater inflater   = (LayoutInflater)MainContext.GetSystemService(Context.LayoutInflaterService);
                View           dialogView = inflater.Inflate(Resource.Layout.XReactDialogLayout, null);

                InitializingReactImages(dialogView);
                ClickImageButtons();

                dialogBuilder.SetView(dialogView);
                MReactAlertDialog = dialogBuilder.Create();
                MReactAlertDialog.Window.SetBackgroundDrawableResource(MReactDialogShape);

                Window window = MReactAlertDialog.Window;
                window.SetLayout(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);

                MReactAlertDialog.Show();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
 public void CommentReplyPostClick(CommentReplyClickEventArgs e)
 {
     try
     {
         if (TypeClass == "Reply")
         {
             var txtComment = ReplyCommentActivity.GetInstance().TxtComment;
             if (txtComment != null)
             {
                 txtComment.Text = "";
                 txtComment.Text = "@" + e.CommentObject.Publisher.Username + " ";
             }
         }
         else
         {
             var intent = new Intent(MainContext, typeof(ReplyCommentActivity));
             intent.PutExtra("CommentId", e.CommentObject.Id);
             intent.PutExtra("CommentObject", JsonConvert.SerializeObject(e.CommentObject));
             MainContext.StartActivity(intent);
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
        public void CommentReplyPostClick(CommentReplyClickEventArgs e)
        {
            try
            {
                switch (TypeClass)
                {
                case "Reply":
                {
                    var txtComment = ReplyCommentActivity.GetInstance().TxtComment;
                    if (txtComment != null)
                    {
                        txtComment.Text = "";
                        txtComment.Text = "@" + e.CommentObject.Publisher.Username + " ";
                    }

                    break;
                }

                default:
                {
                    var intent = new Intent(MainContext, typeof(ReplyCommentActivity));
                    intent.PutExtra("CommentId", e.CommentObject.Id);
                    intent.PutExtra("CommentObject", JsonConvert.SerializeObject(e.CommentObject));
                    MainContext.StartActivity(intent);
                    break;
                }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Esempio n. 4
0
 public void CommentReplyPostClick(CommentReplyClickEventArgs e)
 {
     try
     {
         var intent = new Intent(MainContext, typeof(ReplyCommentActivity));
         intent.PutExtra("CommentId", e.CommentObject.Id);
         intent.PutExtra("CommentObject", JsonConvert.SerializeObject(e.CommentObject));
         MainContext.StartActivity(intent);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Esempio n. 5
0
 public void CountLikeCommentReplyPostClick(CommentReplyClickEventArgs e)
 {
     try
     {
         var intent = new Intent(MainContext, typeof(ReactionCommentTabbedActivity));
         intent.PutExtra("TypeClass", TypeClass);
         intent.PutExtra("CommentObject", JsonConvert.SerializeObject(e.CommentObject));
         MainContext.StartActivity(intent);
     }
     catch (Exception exception)
     {
         Methods.DisplayReportResultTrack(exception);
     }
 }
        public void MoreCommentReplyPostClick(CommentReplyClickEventArgs e)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    TypeDialog    = "MoreComment";
                    CommentObject = e.CommentObject;

                    var arrayAdapter = new List <string>();
                    var dialogList   = new MaterialDialog.Builder(MainContext).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light);

                    arrayAdapter.Add(MainContext.GetString(Resource.String.Lbl_CopeText));
                    arrayAdapter.Add(MainContext.GetString(Resource.String.Lbl_Report));

                    if (CommentObject?.Owner != null && (bool)CommentObject?.Owner || CommentObject?.Publisher?.UserId == UserDetails.UserId)
                    {
                        arrayAdapter.Add(MainContext.GetString(Resource.String.Lbl_Edit));
                        arrayAdapter.Add(MainContext.GetString(Resource.String.Lbl_Delete));
                    }

                    dialogList.Title(MainContext.GetString(Resource.String.Lbl_More));
                    dialogList.Items(arrayAdapter);
                    dialogList.PositiveText(MainContext.GetText(Resource.String.Lbl_Close)).OnNegative(this);
                    dialogList.AlwaysCallSingleChoiceCallback();
                    dialogList.ItemsCallback(this).Build().Show();
                }
                else
                {
                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        public void DislikeCommentReplyPostClick(CommentReplyClickEventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    return;
                }

                e.CommentObject.IsCommentWondered = e.Holder.DislikeTextView.Tag.ToString() != "Disliked";

                if (TypeClass == "Reply")
                {
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.DislikeUnDislikeCommentAsync(e.CommentObject.Id, "reply_dislike")
                    });
                }
                else
                {
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.DislikeUnDislikeCommentAsync(e.CommentObject.Id, "comment_dislike")
                    });
                }

                switch (AppSettings.PostButton)
                {
                case PostButtonSystem.Wonder when e.CommentObject.IsCommentWondered:
                {
                    e.Holder.DislikeTextView.Text = MainContext.GetString(Resource.String.Lbl_wondered);
                    e.Holder.DislikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                    e.Holder.DislikeTextView.Tag = "Disliked";
                    break;
                }

                case PostButtonSystem.Wonder:
                {
                    e.Holder.DislikeTextView.Text = MainContext.GetString(Resource.String.Btn_Wonder);
                    e.Holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                    e.Holder.DislikeTextView.Tag = "Dislike";
                    break;
                }

                case PostButtonSystem.DisLike when e.CommentObject.IsCommentWondered:
                {
                    e.Holder.DislikeTextView.Text = MainContext.GetString(Resource.String.Lbl_disliked);
                    e.Holder.DislikeTextView.SetTextColor(Color.ParseColor("#f89823"));
                    e.Holder.DislikeTextView.Tag = "Disliked";
                    break;
                }

                case PostButtonSystem.DisLike:
                {
                    e.Holder.DislikeTextView.Text = MainContext.GetString(Resource.String.Btn_Dislike);
                    e.Holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                    e.Holder.DislikeTextView.Tag = "Dislike";
                    break;
                }
                }

                if (e.Holder.LikeTextView.Tag.ToString() == "Liked")
                {
                    e.CommentObject.IsCommentLiked = false;

                    e.Holder.LikeTextView.Text = MainContext.GetText(Resource.String.Btn_Like);
                    e.Holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                    e.Holder.LikeTextView.Tag = "Like";
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        public void LikeCommentReplyPostClick(CommentReplyClickEventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    return;
                }

                if (e.Holder.LikeTextView.Tag.ToString() == "Liked")
                {
                    e.CommentObject.IsCommentLiked = false;

                    e.Holder.LikeTextView.Text = MainContext.GetText(Resource.String.Btn_Like);
                    e.Holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                    e.Holder.LikeTextView.Tag = "Like";

                    if (TypeClass == "Reply")
                    {
                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                            () => RequestsAsync.Comment.LikeUnLikeCommentAsync(e.CommentObject.Id, "reply_like")
                        });
                    }
                    else
                    {
                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                            () => RequestsAsync.Comment.LikeUnLikeCommentAsync(e.CommentObject.Id, "comment_like")
                        });
                    }
                }
                else
                {
                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        new ReactionComment(MainContext, TypeClass).ClickDialog(e);
                    }
                    else
                    {
                        e.CommentObject.IsCommentLiked = true;

                        e.Holder.LikeTextView.Text = MainContext.GetText(Resource.String.Btn_Liked);
                        e.Holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        e.Holder.LikeTextView.Tag = "Liked";

                        if (TypeClass == "Reply")
                        {
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comment.LikeUnLikeCommentAsync(e.CommentObject.Id, "reply_like")
                            });
                        }
                        else
                        {
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comment.LikeUnLikeCommentAsync(e.CommentObject.Id, "comment_like")
                            });
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Esempio n. 9
0
        public void PlaySound(CommentReplyClickEventArgs args)
        {
            try
            {
                if (args.Holder.CommentAdapter.PositionSound != args.Position)
                {
                    var list = args.Holder.CommentAdapter.CommentList.Where(a => a.MediaPlayer != null).ToList();
                    if (list.Count > 0)
                    {
                        foreach (var item in list)
                        {
                            item.MediaIsPlaying = false;

                            if (item.MediaPlayer != null)
                            {
                                item.MediaPlayer.Stop();
                                item.MediaPlayer.Reset();
                            }
                            item.MediaPlayer = null !;
                            item.MediaTimer  = null !;

                            item.MediaPlayer?.Release();
                            item.MediaPlayer = null !;
                        }

                        args.Holder.CommentAdapter.NotifyItemChanged(args.Holder.CommentAdapter.PositionSound, "WithoutBlobAudio");
                    }
                }

                var fileName  = args.CommentObject.Record.Split('/').Last();
                var mediaFile = WoWonderTools.GetFile(args.CommentObject.PostId, Methods.Path.FolderDcimSound, fileName, args.CommentObject.Record);

                if (string.IsNullOrEmpty(args.CommentObject.MediaDuration) || args.CommentObject.MediaDuration == "00:00")
                {
                    var duration = WoWonderTools.GetDuration(mediaFile);
                    args.Holder.DurationVoice.Text = Methods.AudioRecorderAndPlayer.GetTimeString(duration);
                }
                else
                {
                    args.Holder.DurationVoice.Text = args.CommentObject.MediaDuration;
                }

                if (mediaFile.Contains("http"))
                {
                    mediaFile = WoWonderTools.GetFile(args.CommentObject.PostId, Methods.Path.FolderDcimSound, fileName, args.CommentObject.Record);
                }

                if (args.CommentObject.MediaPlayer == null)
                {
                    args.Holder.DurationVoice.Text           = "00:00";
                    args.Holder.CommentAdapter.PositionSound = args.Position;
                    args.CommentObject.MediaPlayer           = new MediaPlayer();
                    args.CommentObject.MediaPlayer.SetAudioAttributes(new AudioAttributes.Builder().SetUsage(AudioUsageKind.Media).SetContentType(AudioContentType.Music).Build());

                    args.CommentObject.MediaPlayer.Completion += (sender, e) =>
                    {
                        try
                        {
                            args.Holder.PlayButton.Tag = "Play";
                            args.Holder.PlayButton.SetImageResource(Resource.Drawable.ic_play_dark_arrow);

                            args.CommentObject.MediaIsPlaying = false;

                            args.CommentObject.MediaPlayer.Stop();
                            args.CommentObject.MediaPlayer.Reset();
                            args.CommentObject.MediaPlayer = null !;

                            args.CommentObject.MediaTimer.Enabled = false;
                            args.CommentObject.MediaTimer.Stop();
                            args.CommentObject.MediaTimer = null !;
                        }
                        catch (Exception exception)
                        {
                            Methods.DisplayReportResultTrack(exception);
                        }
                    };

                    args.CommentObject.MediaPlayer.Prepared += (s, ee) =>
                    {
                        try
                        {
                            args.CommentObject.MediaIsPlaying = true;
                            args.Holder.PlayButton.Tag        = "Pause";
                            args.Holder.PlayButton.SetImageResource(AppSettings.SetTabDarkTheme ? Resource.Drawable.ic_media_pause_light : Resource.Drawable.ic_media_pause_dark);

                            args.CommentObject.MediaTimer ??= new Timer {
                                Interval = 1000
                            };

                            args.CommentObject.MediaPlayer.Start();

                            //var durationOfSound = message.MediaPlayer.Duration;

                            args.CommentObject.MediaTimer.Elapsed += (sender, eventArgs) =>
                            {
                                args.Holder.CommentAdapter.ActivityContext.RunOnUiThread(() =>
                                {
                                    try
                                    {
                                        if (args.CommentObject.MediaTimer != null && args.CommentObject.MediaTimer.Enabled)
                                        {
                                            if (args.CommentObject.MediaPlayer.CurrentPosition <= args.CommentObject.MediaPlayer.Duration)
                                            {
                                                args.Holder.DurationVoice.Text = Methods.AudioRecorderAndPlayer.GetTimeString(args.CommentObject.MediaPlayer.CurrentPosition.ToString());
                                            }
                                            else
                                            {
                                                args.Holder.DurationVoice.Text = Methods.AudioRecorderAndPlayer.GetTimeString(args.CommentObject.MediaPlayer.Duration.ToString());

                                                args.Holder.PlayButton.Tag = "Play";
                                                args.Holder.PlayButton.SetImageResource(Resource.Drawable.ic_play_dark_arrow);
                                            }
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Methods.DisplayReportResultTrack(e);
                                        args.Holder.PlayButton.Tag = "Play";
                                    }
                                });
                            };
                            args.CommentObject.MediaTimer.Start();
                        }
                        catch (Exception e)
                        {
                            Methods.DisplayReportResultTrack(e);
                        }
                    };

                    if (mediaFile.Contains("http"))
                    {
                        args.CommentObject.MediaPlayer.SetDataSource(args.Holder.CommentAdapter.ActivityContext, Android.Net.Uri.Parse(mediaFile));
                        args.CommentObject.MediaPlayer.PrepareAsync();
                    }
                    else
                    {
                        Java.IO.File file2    = new Java.IO.File(mediaFile);
                        var          photoUri = FileProvider.GetUriForFile(args.Holder.CommentAdapter.ActivityContext, args.Holder.CommentAdapter.ActivityContext.PackageName + ".fileprovider", file2);

                        args.CommentObject.MediaPlayer.SetDataSource(args.Holder.CommentAdapter.ActivityContext, photoUri);
                        args.CommentObject.MediaPlayer.PrepareAsync();
                    }

                    //args.CommentObject.SoundViewHolder = soundViewHolder;
                }
                else
                {
                    if (args.Holder.PlayButton?.Tag?.ToString() == "Play")
                    {
                        args.Holder.PlayButton.Tag = "Pause";
                        args.Holder.PlayButton.SetImageResource(AppSettings.SetTabDarkTheme ? Resource.Drawable.ic_media_pause_light : Resource.Drawable.ic_media_pause_dark);

                        args.CommentObject.MediaIsPlaying = true;
                        args.CommentObject.MediaPlayer?.Start();

                        if (args.CommentObject.MediaTimer != null)
                        {
                            args.CommentObject.MediaTimer.Enabled = true;
                            args.CommentObject.MediaTimer.Start();
                        }
                    }
                    else if (args.Holder.PlayButton?.Tag?.ToString() == "Pause")
                    {
                        args.Holder.PlayButton.Tag = "Play";
                        args.Holder.PlayButton.SetImageResource(Resource.Drawable.ic_play_dark_arrow);

                        args.CommentObject.MediaIsPlaying = false;
                        args.CommentObject.MediaPlayer?.Pause();

                        if (args.CommentObject.MediaTimer != null)
                        {
                            args.CommentObject.MediaTimer.Enabled = false;
                            args.CommentObject.MediaTimer.Stop();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Esempio n. 10
0
        public void LikeCommentReplyPostClick(CommentReplyClickEventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                    return;
                }

                if (e.Holder.LikeTextView?.Tag?.ToString() == "Liked")
                {
                    e.Holder.LikeTextView.Text = MainContext.GetText(Resource.String.Btn_Like);
                    e.Holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                    e.Holder.LikeTextView.Tag = "Like";

                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        var x = e.CommentObject.Reaction.Count;
                        if (x > 0)
                        {
                            e.CommentObject.Reaction.Count--;
                        }
                        else
                        {
                            e.CommentObject.Reaction.Count = 0;
                        }

                        e.CommentObject.Reaction.IsReacted = false;
                        e.CommentObject.Reaction.Type      = "";

                        if (e.Holder.CountLike != null && e.CommentObject.Reaction.Count > 0)
                        {
                            e.Holder.CountLikeSection.Visibility = ViewStates.Visible;
                            e.Holder.CountLike.Text = Methods.FunString.FormatPriceValue(e.CommentObject.Reaction.Count);
                        }
                        else
                        {
                            e.Holder.CountLikeSection.Visibility = ViewStates.Gone;
                        }

                        PollyController.RunRetryPolicyFunction(TypeClass == "Reply" ? new List <Func <Task> > {
                            () => RequestsAsync.Comment.ReactionCommentAsync(e.CommentObject.Id, "", "reaction_reply")
                        } : new List <Func <Task> > {
                            () => RequestsAsync.Comment.ReactionCommentAsync(e.CommentObject.Id, "")
                        });
                    }
                    else
                    {
                        e.CommentObject.IsCommentLiked = false;

                        PollyController.RunRetryPolicyFunction(TypeClass == "Reply" ? new List <Func <Task> > {
                            () => RequestsAsync.Comment.LikeUnLikeCommentAsync(e.CommentObject.Id, "reply_like")
                        } : new List <Func <Task> > {
                            () => RequestsAsync.Comment.LikeUnLikeCommentAsync(e.CommentObject.Id, "comment_like")
                        });
                    }
                }
                else
                {
                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        new ReactionComment(MainContext, TypeClass)?.ClickDialog(e);
                    }
                    else
                    {
                        e.CommentObject.IsCommentLiked = true;

                        e.Holder.LikeTextView.Text = MainContext.GetText(Resource.String.Btn_Liked);
                        e.Holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        e.Holder.LikeTextView.Tag = "Liked";

                        PollyController.RunRetryPolicyFunction(TypeClass == "Reply" ? new List <Func <Task> > {
                            () => RequestsAsync.Comment.LikeUnLikeCommentAsync(e.CommentObject.Id, "reply_like")
                        } : new List <Func <Task> > {
                            () => RequestsAsync.Comment.LikeUnLikeCommentAsync(e.CommentObject.Id, "comment_like")
                        });
                    }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }