Ejemplo n.º 1
0
        /// <summary>
        /// Simple Method to set default settings for ReactButton Constructors
        /// - Default Text Is Like
        /// - set onClick And onLongClick
        /// - set Default image is Dark Like
        /// </summary>
        private void ReactButtonDefaultSetting()
        {
            MReactButton.Text = MDefaultReaction.GetReactText();
            //MReactButton.SetOnClickListener(this);
            //MReactButton.SetOnLongClickListener(this);

            Drawable icon;

            if (MReactButton.Text == ReactConstants.Like)
            {
                icon = AppCompatResources.GetDrawable(Context, MDefaultReaction.GetReactType() == ReactConstants.Default ? Resource.Drawable.icon_post_like_vector  : Resource.Drawable.like); //ic_action_like
                if (MDefaultReaction.GetReactType() == ReactConstants.Default)
                {
                    icon.SetTint(Color.ParseColor(AppSettings.SetTabDarkTheme ? "#ffffff" : "#888888"));
                }
            }
            else if (MReactButton.Text == ReactConstants.Love)
            {
                icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.love);
            }
            else if (MReactButton.Text == ReactConstants.HaHa)
            {
                icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.haha);
            }
            else if (MReactButton.Text == ReactConstants.Wow)
            {
                icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.wow);
            }
            else if (MReactButton.Text == ReactConstants.Sad)
            {
                icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.sad);
            }
            else if (MReactButton.Text == ReactConstants.Angry)
            {
                icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.angry);
            }
            else
            {
                icon = AppCompatResources.GetDrawable(Context, MDefaultReaction.GetReactIconId());
            }

            // Drawable icon = Build.VERSION.SdkInt < BuildVersionCodes.Lollipop ? VectorDrawableCompat.Create(Context.Resources, MDefaultReaction.GetReactIconId(), Context.Theme) : AppCompatResources.GetDrawable(Context, MDefaultReaction.GetReactIconId());

            //MReactButton.CompoundDrawablePadding = 20;

            //if (AppSettings.FlowDirectionRightToLeft)
            //    MReactButton.SetCompoundDrawablesWithIntrinsicBounds(null, null, icon, null);
            //else
            //    MReactButton.SetCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);

            SetImageReaction(icon);
        }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            try
            {
                switch (obj)
                {
                //Assert that obj type is Reaction
                case Reaction reaction:
                {
                    //Cast Object to Reaction
                    Reaction react = reaction;
                    //if react type equal current Reaction type
                    return(react.GetReactType().Equals(ReactType));
                }

                default:
                    return(false);
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(false);
            }
        }
        public override bool Equals(object obj)
        {
            try
            {
                //Assert that obj type is Reaction
                if (obj is Reaction reaction)
                {
                    //Cast Object to Reaction
                    Reaction react = reaction;
                    //if react type equal current Reaction type
                    return(react.GetReactType().Equals(ReactType));
                }

                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="react">Reaction to update UI by take attribute from it</param>
        private void UpdateReactButtonByReaction(Reaction react)
        {
            try
            {
                MCurrentReaction  = react;
                MReactButton.Text = react.GetReactText();
                MReactButton.SetTextColor(Color.ParseColor(react.GetReactTextColor()));

                //Drawable icon = Build.VERSION.SdkInt < BuildVersionCodes.Lollipop ? VectorDrawableCompat.Create(Context.Resources, react.GetReactIconId(), Context.Theme) : AppCompatResources.GetDrawable(Context,react.GetReactIconId());

                Drawable icon = AppCompatResources.GetDrawable(Context, react.GetReactIconId());
                if (MReactButton.Text == ReactConstants.Like)
                {
                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault)
                    {
                        icon = AppCompatResources.GetDrawable(Context, react.GetReactType() == ReactConstants.Default ? Resource.Drawable.icon_post_like_vector : Resource.Drawable.emoji_like);  //ic_action_like
                    }
                    else if (AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        icon = AppCompatResources.GetDrawable(Context, react.GetReactType() == ReactConstants.Default ? Resource.Drawable.icon_post_like_vector : Resource.Drawable.like);  //ic_action_like
                    }

                    if (react.GetReactType() == ReactConstants.Default)
                    {
                        icon?.SetTint(Color.ParseColor(AppSettings.SetTabDarkTheme ? "#ffffff" : "#888888"));
                    }

                    if (NamePage == "ImagePostViewerActivity" || NamePage == "MultiImagesPostViewerActivity")
                    {
                        var imgLike = PostData.View?.FindViewById <ImageView>(Resource.Id.image_like1);
                        imgLike?.SetImageResource(Resource.Drawable.emoji_like);
                    }
                }
                else if (MReactButton.Text == ReactConstants.Love)
                {
                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault)
                    {
                        icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.emoji_love);
                    }
                    else if (AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.love);
                    }

                    if (NamePage == "ImagePostViewerActivity" || NamePage == "MultiImagesPostViewerActivity")
                    {
                        var imgLike = PostData.View?.FindViewById <ImageView>(Resource.Id.image_like1);
                        imgLike?.SetImageResource(Resource.Drawable.emoji_love);
                    }
                }
                else if (MReactButton.Text == ReactConstants.HaHa)
                {
                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault)
                    {
                        icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.emoji_haha);
                    }
                    else if (AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.haha);
                    }

                    if (NamePage == "ImagePostViewerActivity" || NamePage == "MultiImagesPostViewerActivity")
                    {
                        var imgLike = PostData.View?.FindViewById <ImageView>(Resource.Id.image_like1);
                        imgLike?.SetImageResource(Resource.Drawable.emoji_haha);
                    }
                }
                else if (MReactButton.Text == ReactConstants.Wow)
                {
                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault)
                    {
                        icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.emoji_wow);
                    }
                    else if (AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.wow);
                    }

                    if (NamePage == "ImagePostViewerActivity" || NamePage == "MultiImagesPostViewerActivity")
                    {
                        var imgLike = PostData.View?.FindViewById <ImageView>(Resource.Id.image_like1);
                        imgLike?.SetImageResource(Resource.Drawable.emoji_wow);
                    }
                }
                else if (MReactButton.Text == ReactConstants.Sad)
                {
                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault)
                    {
                        icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.emoji_sad);
                    }
                    else if (AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.sad);
                    }

                    if (NamePage == "ImagePostViewerActivity" || NamePage == "MultiImagesPostViewerActivity")
                    {
                        var imgLike = PostData.View?.FindViewById <ImageView>(Resource.Id.image_like1);
                        imgLike?.SetImageResource(Resource.Drawable.emoji_sad);
                    }
                }
                else if (MReactButton.Text == ReactConstants.Angry)
                {
                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault)
                    {
                        icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.emoji_angry);
                    }
                    else if (AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.angry);
                    }

                    if (NamePage == "ImagePostViewerActivity" || NamePage == "MultiImagesPostViewerActivity")
                    {
                        var imgLike = PostData.View?.FindViewById <ImageView>(Resource.Id.image_like1);
                        imgLike?.SetImageResource(Resource.Drawable.emoji_angry);
                    }
                }
                else
                {
                    icon = AppCompatResources.GetDrawable(Context, react.GetReactIconId());

                    if (NamePage == "ImagePostViewerActivity" || NamePage == "MultiImagesPostViewerActivity")
                    {
                        var imgLike = PostData.View?.FindViewById <ImageView>(Resource.Id.image_like1);
                        imgLike?.SetImageResource(Resource.Drawable.icon_post_like_vector);
                    }
                }

                MReactButton.CompoundDrawablePadding = 20;

                if (AppSettings.FlowDirectionRightToLeft)
                {
                    MReactButton.SetCompoundDrawablesWithIntrinsicBounds(null, null, icon, null);
                }

                else
                {
                    MReactButton.SetCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
                }

                //SetImageReaction(icon);


                MCurrentReactState = !react.GetReactType().Equals(MDefaultReaction.GetReactType());
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="react">Reaction to update UI by take attribute from it</param>
        private void UpdateReactButtonByReaction(Reaction react)
        {
            try
            {
                MCurrentReaction  = react;
                MReactButton.Text = react.GetReactText();
                MReactButton.SetTextColor(Color.ParseColor(react.GetReactTextColor()));

                //Drawable icon = Build.VERSION.SdkInt < BuildVersionCodes.Lollipop ? VectorDrawableCompat.Create(Context.Resources, react.GetReactIconId(), Context.Theme) : AppCompatResources.GetDrawable(Context,react.GetReactIconId());

                Drawable icon;
                if (MReactButton.Text == ReactConstants.Like)
                {
                    icon = AppCompatResources.GetDrawable(Context, react.GetReactType() == ReactConstants.Default ? Resource.Drawable.icon_post_like_vector  : Resource.Drawable.like);  //ic_action_like

                    if (react.GetReactType() == ReactConstants.Default)
                    {
                        icon.SetTint(Color.ParseColor(AppSettings.SetTabDarkTheme ? "#ffffff" : "#888888"));
                    }
                }
                else if (MReactButton.Text == ReactConstants.Love)
                {
                    icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.love);
                }
                else if (MReactButton.Text == ReactConstants.HaHa)
                {
                    icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.haha);
                }
                else if (MReactButton.Text == ReactConstants.Wow)
                {
                    icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.wow);
                }
                else if (MReactButton.Text == ReactConstants.Sad)
                {
                    icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.sad);
                }
                else if (MReactButton.Text == ReactConstants.Angry)
                {
                    icon = AppCompatResources.GetDrawable(Context, Resource.Drawable.angry);
                }
                else
                {
                    icon = AppCompatResources.GetDrawable(Context, react.GetReactIconId());
                }

                //if (AppSettings.FlowDirectionRightToLeft)
                //    MReactButton.SetCompoundDrawablesWithIntrinsicBounds(null, null, icon, null);

                //else
                //    MReactButton.SetCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);

                SetImageReaction(icon);

                //MReactButton.CompoundDrawablePadding = 10;

                MCurrentReactState = !react.GetReactType().Equals(MDefaultReaction.GetReactType());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }