示例#1
0
 public void AddToWatchLater(VideoObject video, int count = 0)
 {
     try
     {
         if (UserDetails.IsLogin)
         {
             var item = ActivityContext?.LibraryFragment?.MAdapter?.LibraryList?.FirstOrDefault(a => a.SectionId == "2");
             if (item == null)
             {
                 return;
             }
             item.VideoCount = count != 0 ? count : item.VideoCount + 1;
             if (video != null)
             {
                 item.BackgroundImage = video.Thumbnail;
             }
             else
             {
                 item.BackgroundImage = "blackdefault";
                 item.VideoCount      = 0;
             }
             ActivityContext?.LibraryFragment?.MAdapter?.NotifyItemChanged(1);
         }
         else
         {
             PopupDialogController dialog = new PopupDialogController(Activity, video, "Login");
             dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning), Activity.GetText(Resource.String.Lbl_Please_sign_in_WatchLater), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No));
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
示例#2
0
        //ReportSong
        private void OnMenuReportSongOnClick(MoreSongClickEventArgs song)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(GlobalContext, null, "Login");
                    dialog.ShowNormalDialog(GlobalContext.GetText(Resource.String.Lbl_Login), GlobalContext.GetText(Resource.String.Lbl_Message_Sorry_signin), GlobalContext.GetText(Resource.String.Lbl_Yes), GlobalContext.GetText(Resource.String.Lbl_No));
                    return;
                }

                if (Methods.CheckConnectivity())
                {
                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_YourReportSong), ToastLength.Short).Show();
                    //Sent Api >>
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Tracks.ReportUnReportTrackAsync(song.SongsClass.Id.ToString(), true)
                    });
                }
                else
                {
                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#3
0
        //Add Like Or Remove
        public void OnLikeSongsClick(LikeSongsClickEventArgs e, string name = "")
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(GlobalContext, null, "Login");
                    dialog.ShowNormalDialog(GlobalContext.GetText(Resource.String.Lbl_Login), GlobalContext.GetText(Resource.String.Lbl_Message_Sorry_signin), GlobalContext.GetText(Resource.String.Lbl_Yes), GlobalContext.GetText(Resource.String.Lbl_No));
                    return;
                }

                if (Methods.CheckConnectivity())
                {
                    var refs = SetLike(e.LikeButton);
                    e.SongsClass.IsLiked = refs;

                    //add to Liked
                    if (refs)
                    {
                        GlobalContext?.LibrarySynchronizer.AddToLiked(e.SongsClass);
                    }

                    if (name == "AlbumsFragment")
                    {
                        var list     = AlbumsFragment.MAdapter?.SoundsList;
                        var dataSong = list?.FirstOrDefault(a => a.Id == e.SongsClass.Id);
                        if (dataSong != null)
                        {
                            dataSong.IsLiked = refs;
                            int index = list.IndexOf(dataSong);
                            AlbumsFragment.MAdapter?.NotifyItemChanged(index);
                        }
                    }
                    else if (name == "PlaylistProfileFragment")
                    {
                        var list     = GlobalContext?.PlaylistFragment?.MyPlaylistFragment?.PlaylistProfileFragment?.MAdapter?.SoundsList;
                        var dataSong = list?.FirstOrDefault(a => a.Id == e.SongsClass.Id);
                        if (dataSong != null)
                        {
                            dataSong.IsLiked = refs;
                            int index = list.IndexOf(dataSong);
                            GlobalContext.PlaylistFragment.MyPlaylistFragment?.PlaylistProfileFragment?.MAdapter?.NotifyItemChanged(index);
                        }
                    }

                    //Sent Api
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Tracks.LikeUnLikeTrackAsync(e.SongsClass.AudioId)
                    });
                }
                else
                {
                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#4
0
 public void AddToPlaylist(VideoObject video)
 {
     try
     {
         if (Methods.CheckConnectivity())
         {
             if (UserDetails.IsLogin)
             {
                 PopupDialogController dialog = new PopupDialogController(ActivityContext, video, "PlayList");
                 dialog.ShowPlayListDialog();
             }
             else
             {
                 PopupDialogController dialog = new PopupDialogController(ActivityContext, video, "Login");
                 dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning), Activity.GetText(Resource.String.Lbl_Please_sign_in_playlist), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No));
             }
         }
         else
         {
             Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
        private void PurchaseButtonOnClick(object sender, EventArgs e)
        {
            try
            {
                if (UserDetails.IsLogin)
                {
                    var arrayAdapter = new List <string>();
                    var dialogList   = new MaterialDialog.Builder(Activity).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light);

                    if (AppSettings.ShowPaypal)
                    {
                        arrayAdapter.Add(Activity.GetString(Resource.String.Btn_Paypal));
                    }

                    if (AppSettings.ShowCreditCard)
                    {
                        arrayAdapter.Add(Activity.GetString(Resource.String.Lbl_CreditCard));
                    }

                    dialogList.Items(arrayAdapter);
                    dialogList.NegativeText(Activity.GetString(Resource.String.Lbl_Close)).OnNegative(this);
                    dialogList.AlwaysCallSingleChoiceCallback();
                    dialogList.ItemsCallback(this).Build().Show();
                }
                else
                {
                    PopupDialogController dialog = new PopupDialogController(Activity, VideoObject, "Login");
                    dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning), Activity.GetText(Resource.String.Lbl_Please_sign_in_Paid), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No));
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#6
0
        //DeleteSong
        private void OnMenuDeleteSongOnClick(MoreSongClickEventArgs song)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(GlobalContext, null, "Login");
                    dialog.ShowNormalDialog(GlobalContext.GetText(Resource.String.Lbl_Login), GlobalContext.GetText(Resource.String.Lbl_Message_Sorry_signin), GlobalContext.GetText(Resource.String.Lbl_Yes), GlobalContext.GetText(Resource.String.Lbl_No));
                    return;
                }


                if (Methods.CheckConnectivity())
                {
                    TypeDialog   = "DeleteSong";
                    MoreSongArgs = song;

                    var dialog = new MaterialDialog.Builder(MainContext).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light);
                    dialog.Title(MainContext.GetText(Resource.String.Lbl_DeleteSong));
                    dialog.Content(MainContext.GetText(Resource.String.Lbl_AreYouSureDeleteSong));
                    dialog.PositiveText(MainContext.GetText(Resource.String.Lbl_Yes)).OnPositive(this);
                    dialog.NegativeText(MainContext.GetText(Resource.String.Lbl_No)).OnNegative(this);
                    dialog.AlwaysCallSingleChoiceCallback();
                    dialog.ItemsCallback(this).Build().Show();
                }
                else
                {
                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        //Follow
        private void BtnAddUserOnClick(object sender, EventArgs e)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(Activity, null, "Login");
                    dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Login), Activity.GetText(Resource.String.Lbl_Message_Sorry_signin), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No));
                    return;
                }

                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    return;
                }

                switch (BtnFollow.Tag.ToString())
                {
                case "Add":     //Sent follow
                    BtnFollow.SetColor(Color.ParseColor(AppSettings.MainColor));
                    BtnFollow.SetImageResource(Resource.Drawable.ic_tick);
                    BtnFollow.Tag        = "friends";
                    DataUser.IsFollowing = true;

                    Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Sent_successfully_followed),
                                   ToastLength.Short).Show();
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.User.FollowUnFollowUserAsync(UserId, true)
                    });
                    break;

                case "friends":     //Sent un follow
                    BtnFollow.SetColor(Color.ParseColor("#444444"));
                    BtnFollow.SetImageResource(Resource.Drawable.ic_add);
                    BtnFollow.Tag        = "Add";
                    DataUser.IsFollowing = false;

                    Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Sent_successfully_Unfollowed),
                                   ToastLength.Short).Show();
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.User.FollowUnFollowUserAsync(UserId, false)
                    });
                    break;
                }

                var dataUser = GlobalContext?.MainFragment?.ArtistsAdapter?.ArtistsList?.FirstOrDefault(a => a.Id == DataUser.Id);
                if (dataUser != null)
                {
                    dataUser.IsFollowing = DataUser.IsFollowing;
                    GlobalContext.MainFragment.ArtistsAdapter.NotifyDataSetChanged();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#8
0
        //Report Copyright
        private void ReportCopyRightLayoutOnClick(object sender, EventArgs e)
        {
            try
            {
                if (UserDetails.IsLogin)
                {
                    if (Methods.CheckConnectivity())
                    {
                        MaterialDialog dialog = new MaterialDialog.Builder(Controller.ActivityContext).Theme(AppSettings.SetTabDarkTheme ? AFollestad.MaterialDialogs.Theme.Dark : AFollestad.MaterialDialogs.Theme.Light)
                                                .Title(Resource.String.Lbl_ReportCopyRight)
                                                .CustomView(Resource.Layout.ReportCopyRightLayout, true)
                                                .PositiveText(Resource.String.Lbl_Submit).OnPositive((materialDialog, action) =>
                        {
                            try
                            {
                                if (TxtMessage != null && (CheckBox2 != null && (CheckBox1 != null && (CheckBox1.Checked && CheckBox2.Checked && !string.IsNullOrEmpty(TxtMessage.Text) && !string.IsNullOrWhiteSpace(TxtMessage.Text)))))
                                {
                                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                        () => RequestsAsync.Video.ReportCopyRightVideos_Http(Controller.VideoData.Id, TxtMessage.Text)
                                    });
                                    Toast.MakeText(Controller.ActivityContext, Controller.ActivityContext.GetText(Resource.String.Lbl_received_your_report), ToastLength.Short).Show();
                                }
                                else
                                {
                                    Toast.MakeText(Controller.ActivityContext, Controller.ActivityContext.GetText(Resource.String.Lbl_Please_check_your_details), ToastLength.Short).Show();
                                }
                            }
                            catch (Exception exception)
                            {
                                Console.WriteLine(exception);
                            }
                        })
                                                .NegativeText(Resource.String.Lbl_Close).OnNegative(this)
                                                .Build();

                        TxtMessage = dialog.CustomView.FindViewById <EditText>(Resource.Id.MessageEditText);
                        CheckBox1  = dialog.CustomView.FindViewById <CheckBox>(Resource.Id.CheckBoxReportCopyRight1);
                        CheckBox2  = dialog.CustomView.FindViewById <CheckBox>(Resource.Id.CheckBoxReportCopyRight2);

                        dialog.Show();
                        Dismiss();
                    }
                    else
                    {
                        Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    }
                }
                else
                {
                    PopupDialogController dialog = new PopupDialogController(Activity, Controller.VideoData, "Login");
                    dialog.ShowNormalDialog(Context.GetText(Resource.String.Lbl_Warning), Context.GetText(Resource.String.Lbl_Please_sign_in_Report), Context.GetText(Resource.String.Lbl_Yes), Context.GetText(Resource.String.Lbl_No));
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
 //Support >> Logout , DeleteAccount , Report , Help
 //===================================================
 private void LogoutOnPreferenceClick(object sender, Preference.PreferenceClickEventArgs preferenceClickEventArgs)
 {
     try
     {
         PopupDialogController dialog = new PopupDialogController(ActivityContext, null, "Logout");
         dialog.ShowNormalDialog(ActivityContext.GetText(Resource.String.Lbl_Warning), ActivityContext.GetText(Resource.String.Lbl_Are_you_sure_you_went_to_logout), ActivityContext.GetText(Resource.String.Lbl_Ok), ActivityContext.GetText(Resource.String.Lbl_Cancel));
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
示例#10
0
 private void DeleteAccountOnPreferenceClick(object sender, Preference.PreferenceClickEventArgs preferenceClickEventArgs)
 {
     try
     {
         PopupDialogController dialog = new PopupDialogController(ActivityContext, null, "DeleteAcount");
         dialog.ShowNormalDialog(ActivityContext.GetText(Resource.String.Lbl_Warning), ActivityContext.GetText(Resource.String.Lbl_Are_you_sure_you_went_to_delete_account) + " " + AppSettings.ApplicationName, ActivityContext.GetText(Resource.String.Lbl_Ok), ActivityContext.GetText(Resource.String.Lbl_Cancel));
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
        private void OnFollowButtonClick(FollowFollowingClickEventArgs e)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(ActivityContext, null, "Login");
                    dialog.ShowNormalDialog(ActivityContext.GetText(Resource.String.Lbl_Login), ActivityContext.GetText(Resource.String.Lbl_Message_Sorry_signin), ActivityContext.GetText(Resource.String.Lbl_Yes), ActivityContext.GetText(Resource.String.Lbl_No));
                    return;
                }

                if (Methods.CheckConnectivity())
                {
                    if (e.UserClass != null)
                    {
                        if (e.ButtonFollow.Tag?.ToString() == "true")
                        {
                            e.UserClass.IsFollowing = false;
                            e.ButtonFollow.Tag      = "false";
                            e.ButtonFollow.Text     = ActivityContext.GetText(Resource.String.Lbl_Follow);
                            e.ButtonFollow.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                            e.ButtonFollow.SetTextColor(Color.ParseColor(AppSettings.MainColor));

                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.User.FollowUnFollowUserAsync(e.UserClass.Id.ToString(), false)
                            });
                        }
                        else
                        {
                            e.UserClass.IsFollowing = true;
                            e.ButtonFollow.Tag      = "true";
                            e.ButtonFollow.Text     = ActivityContext.GetText(Resource.String.Lbl_Following);
                            e.ButtonFollow.SetBackgroundResource(Resource.Xml.background_signup2);
                            e.ButtonFollow.SetTextColor(Color.White);

                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.User.FollowUnFollowUserAsync(e.UserClass.Id.ToString(), true)
                            });
                        }
                    }
                }
                else
                {
                    Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#12
0
        //Open Edit page profile
        private void BtnFollowOnClick(object sender, EventArgs e)
        {
            if (!UserDetails.IsLogin)
            {
                PopupDialogController dialog = new PopupDialogController(GlobalContext, null, "Login");
                dialog.ShowNormalDialog(GlobalContext.GetText(Resource.String.Lbl_Login), GlobalContext.GetText(Resource.String.Lbl_Message_Sorry_signin), GlobalContext.GetText(Resource.String.Lbl_Yes), GlobalContext.GetText(Resource.String.Lbl_No));
                return;
            }

            if (Methods.CheckConnectivity())
            {
                switch (BtnFollow.Tag.ToString())
                {
                case "Add":     //Sent follow

                    //BtnFollow.SetBackgroundResource(Resource.Drawable.SubcribeButton);
                    //BtnFollow.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor(AppSettings.MainColor));

                    //icon
                    var iconTick = Activity.GetDrawable(Resource.Drawable.ic_tick);
                    iconTick.Bounds = new Rect(10, 10, 10, 7);
                    BtnFollow.SetCompoundDrawablesWithIntrinsicBounds(iconTick, null, null, null);
                    BtnFollow.Tag = "friends";

                    Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Sent_successfully_followed), ToastLength.Short).Show();
                    RequestsAsync.User.FollowUnFollowUserAsync(UserId, true).ConfigureAwait(false);
                    break;

                case "friends":     //Sent un follow

                    //BtnFollow.SetBackgroundResource(Resource.Drawable.SubcribeButton);
                    //BtnFollow.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor("#444444"));

                    //icon
                    var iconAdd = Activity.GetDrawable(Resource.Drawable.ic_add);
                    iconAdd.Bounds = new Rect(10, 10, 10, 7);
                    BtnFollow.SetCompoundDrawablesWithIntrinsicBounds(iconAdd, null, null, null);
                    BtnFollow.Tag = "Add";

                    Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Sent_successfully_Unfollowed), ToastLength.Short).Show();
                    RequestsAsync.User.FollowUnFollowUserAsync(UserId, false).ConfigureAwait(false);
                    break;
                }
            }
            else
            {
                Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
            }
        }
示例#13
0
 //wael
 //Report Copyright Song
 private void OnMenuReportCopyrightSongOnClick(MoreSongClickEventArgs song)
 {
     try
     {
         if (!UserDetails.IsLogin)
         {
             PopupDialogController dialog = new PopupDialogController(GlobalContext, null, "Login");
             dialog.ShowNormalDialog(GlobalContext.GetText(Resource.String.Lbl_Login), GlobalContext.GetText(Resource.String.Lbl_Message_Sorry_signin), GlobalContext.GetText(Resource.String.Lbl_Yes), GlobalContext.GetText(Resource.String.Lbl_No));
             return;
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
示例#14
0
        public void AddToSubscriptions(VideoObject video, int count = 0)
        {
            try
            {
                if (UserDetails.IsLogin)
                {
                    var item = ActivityContext?.LibraryFragment?.MAdapter?.LibraryList?.FirstOrDefault(a => a.SectionId == "1");
                    if (item == null)
                    {
                        return;
                    }

                    if (count != 0)
                    {
                        item.VideoCount = count;
                    }
                    else
                    {
                        item.VideoCount = item.VideoCount + 1;
                    }

                    if (video != null)
                    {
                        item.BackgroundImage = video.Thumbnail;
                    }
                    else
                    {
                        item.BackgroundImage = "blackdefault";
                        item.VideoCount      = 0;
                    }
                    ActivityContext?.LibraryFragment?.MAdapter?.NotifyItemChanged(0);

                    var sqlEntity = new SqLiteDatabase();
                    sqlEntity.InsertLibraryItem(item);
                    sqlEntity.Dispose();
                }
                else
                {
                    PopupDialogController dialog = new PopupDialogController(Activity, video, "Login");
                    dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning), Activity.GetText(Resource.String.Lbl_Please_sign_in_Subcribed), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        // Create Playlist
        private void BtnAddOnClick(object sender, EventArgs e)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(GlobalContext, null, "Login");
                    dialog.ShowNormalDialog(GlobalContext.GetText(Resource.String.Lbl_Login), GlobalContext.GetText(Resource.String.Lbl_Message_Sorry_signin), GlobalContext.GetText(Resource.String.Lbl_Yes), GlobalContext.GetText(Resource.String.Lbl_No));
                    return;
                }

                StartActivity(new Intent(Activity, typeof(CreatePlaylistActivity)));
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        //Follow
        private void BtnFollowOnClick(object sender, EventArgs e)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(GlobalContext, null, "Login");
                    dialog.ShowNormalDialog(GlobalContext.GetText(Resource.String.Lbl_Login), GlobalContext.GetText(Resource.String.Lbl_Message_Sorry_signin), GlobalContext.GetText(Resource.String.Lbl_Yes), GlobalContext.GetText(Resource.String.Lbl_No));
                    return;
                }

                if (Methods.CheckConnectivity())
                {
                    switch (BtnFollow.Tag.ToString())
                    {
                    case "Add":     //Sent follow
                        BtnFollow.SetBackgroundColor(Color.ParseColor(AppSettings.MainColor));
                        BtnFollow.SetImageResource(Resource.Drawable.ic_tick);
                        BtnFollow.Tag = "friends";

                        Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Sent_successfully_followed), ToastLength.Short).Show();
                        RequestsAsync.User.FollowUnFollowUserAsync(UserId, true).ConfigureAwait(false);
                        break;

                    case "friends":     //Sent un follow
                        BtnFollow.SetBackgroundColor(Color.ParseColor("#444444"));
                        BtnFollow.SetImageResource(Resource.Drawable.ic_add);
                        BtnFollow.Tag = "Add";

                        Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Sent_successfully_Unfollowed), ToastLength.Short).Show();
                        RequestsAsync.User.FollowUnFollowUserAsync(UserId, false).ConfigureAwait(false);
                        break;
                    }
                }
                else
                {
                    Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#17
0
 public void AddReportVideo(VideoObject video)
 {
     try
     {
         if (UserDetails.IsLogin)
         {
             PopupDialogController dialog = new PopupDialogController(Activity, video, "Report");
             dialog.ShowEditTextDialog(Activity.GetText(Resource.String.Lbl_Report_This_Video), Activity.GetText(Resource.String.Lbl_Report_This_Video_Text), Activity.GetText(Resource.String.Lbl_Submit), Activity.GetText(Resource.String.Lbl_Cancel));
         }
         else
         {
             PopupDialogController dialog = new PopupDialogController(Activity, video, "Login");
             dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning), Activity.GetText(Resource.String.Lbl_Please_sign_in_Report), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No));
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
示例#18
0
        private void OnMenuEditPlaylistOnClick()
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(ActivityContext, null, "Login");
                    dialog.ShowNormalDialog(ActivityContext.GetText(Resource.String.Lbl_Login), ActivityContext.GetText(Resource.String.Lbl_Message_Sorry_signin), ActivityContext.GetText(Resource.String.Lbl_Yes), ActivityContext.GetText(Resource.String.Lbl_No));
                    return;
                }

                Intent intent = new Intent(ActivityContext, typeof(EditPlaylistActivity));
                intent.PutExtra("ItemData", JsonConvert.SerializeObject(MorePlaylistArgs.PlaylistClass));
                ActivityContext.StartActivity(intent);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#19
0
        //Edit Song
        private void OnMenuEditSongOnClick(MoreSongClickEventArgs song)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(GlobalContext, null, "Login");
                    dialog.ShowNormalDialog(GlobalContext.GetText(Resource.String.Lbl_Login), GlobalContext.GetText(Resource.String.Lbl_Message_Sorry_signin), GlobalContext.GetText(Resource.String.Lbl_Yes), GlobalContext.GetText(Resource.String.Lbl_No));
                    return;
                }


                Intent intent = new Intent(MainContext, typeof(EditSongActivity));
                intent.PutExtra("ItemDataSong", JsonConvert.SerializeObject(song.SongsClass));
                intent.PutExtra("NamePage", NamePage);
                MainContext.StartActivity(intent);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#20
0
        //Add Favorite Or Remove
        public void OnFavoriteSongsClick(FavSongsClickEventArgs e)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(GlobalContext, null, "Login");
                    dialog.ShowNormalDialog(GlobalContext.GetText(Resource.String.Lbl_Login), GlobalContext.GetText(Resource.String.Lbl_Message_Sorry_signin), GlobalContext.GetText(Resource.String.Lbl_Yes), GlobalContext.GetText(Resource.String.Lbl_No));
                    return;
                }


                if (Methods.CheckConnectivity())
                {
                    var refs = SetFav(e.FavButton);
                    e.SongsClass.IsFavoriated = refs;

                    //add to Favorites
                    if (refs)
                    {
                        GlobalContext?.LibrarySynchronizer.AddToFavorites(e.SongsClass);
                    }

                    //Sent Api
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Tracks.AddOrRemoveFavoriteTrackAsync(e.SongsClass.AudioId)
                    });
                }
                else
                {
                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#21
0
    public PopupDialogController CreatePopupDialog(string _textTitle, string _textMessage, string _errorCode, string _textSubmitButton, string _textCancleButton, System.Action _onSubmit, System.Action _onCanel)
    {
        if (myCanvas.worldCamera == null && CoreGameManager.instance.currentSceneManager != null)
        {
            myCanvas.worldCamera = CoreGameManager.instance.currentSceneManager.cameraForConsumableScreen.mainCamera;
        }
        else
        {
            myCanvas.worldCamera = Camera.main;
        }

        myCanvasGroup.alpha          = 1f;
        myCanvasGroup.blocksRaycasts = true;

        PopupDialogController _tmpPopup = LeanPool.Spawn(popupDialogPrefab.transform, Vector3.zero, Quaternion.identity, pool.transform).GetComponent <PopupDialogController>();

        _tmpPopup.Init(_textTitle, _textMessage, _errorCode, _textSubmitButton, _textCancleButton, _onSubmit, _onCanel, () => {
            RemovePopupActive(_tmpPopup);
        });
        MyAudioManager.instance.PlaySfx(PopupManager.Instance.myInfoAudio.sfx_Popup);
        AddPopupActive(_tmpPopup);

        return(_tmpPopup);
    }
示例#22
0
        private void SubscribeChannelButtonClick(object sender, EventArgs e)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    if (UserDetails.IsLogin)
                    {
                        if (!string.IsNullOrEmpty(UserData.SubscriberPrice) && UserData.SubscriberPrice != "0")
                        {
                            if (SubscribeChannelButton.Tag.ToString() == "PaidSubscribe")
                            {
                                DialogType = "PaidSubscribe";

                                //This channel is paid, You must pay to subscribe
                                var dialog = new MaterialDialog.Builder(Context).Theme(AppSettings.SetTabDarkTheme ? AFollestad.MaterialDialogs.Theme.Dark : AFollestad.MaterialDialogs.Theme.Light);

                                dialog.Title(Resource.String.Lbl_Warning);
                                dialog.Content(GetText(Resource.String.Lbl_ChannelIsPaid));
                                dialog.PositiveText(GetText(Resource.String.Lbl_Ok)).OnPositive(this);
                                dialog.NegativeText(GetText(Resource.String.Lbl_Cancel)).OnNegative(this);
                                dialog.AlwaysCallSingleChoiceCallback();
                                dialog.Build().Show();
                            }
                            else
                            {
                                SubscribeChannelButton.Tag  = "Subscribe";
                                SubscribeChannelButton.Text = GetText(Resource.String.Btn_Subscribe);
                                //Color
                                SubscribeChannelButton.SetTextColor(Color.ParseColor("#efefef"));
                                //icon
                                Drawable icon = Activity.GetDrawable(Resource.Drawable.SubcribeButton);
                                icon.Bounds = new Rect(10, 10, 10, 7);
                                SubscribeChannelButton.SetCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);

                                //Remove The Video to Subscribed Videos Database
                                var sqlEntity = new SqLiteDatabase();
                                sqlEntity.RemoveSubscriptionsChannel(IdChannel);
                                sqlEntity.Dispose();

                                //Send API Request here for UnSubscribed
                                PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                    () => RequestsAsync.Global.Add_Subscribe_To_Channel_Http(UserData.Id)
                                });

                                // Toast.MakeText(this, this.GetText(Resource.String.Lbl_Channel_Removed_successfully, ToastLength.Short).Show();
                            }
                        }
                        else
                        {
                            if (SubscribeChannelButton.Tag.ToString() == "Subscribe")
                            {
                                SubscribeChannelButton.Tag  = "Subscribed";
                                SubscribeChannelButton.Text = GetText(Resource.String.Btn_Subscribed);

                                //Color
                                SubscribeChannelButton.SetTextColor(Color.ParseColor("#efefef"));
                                //icon
                                Drawable icon = Activity.GetDrawable(Resource.Drawable.SubcribedButton);
                                icon.Bounds = new Rect(10, 10, 10, 7);
                                SubscribeChannelButton.SetCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);

                                //Add The Video to  Subcribed Videos Database
                                Events_Insert_SubscriptionsChannel();

                                //Send API Request here for Subcribe
                                PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                    () => RequestsAsync.Global.Add_Subscribe_To_Channel_Http(UserData.Id)
                                });

                                Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_Subscribed_successfully), ToastLength.Short).Show();
                            }
                            else
                            {
                                SubscribeChannelButton.Tag  = "Subscribe";
                                SubscribeChannelButton.Text = GetText(Resource.String.Btn_Subscribe);
                                //Color
                                SubscribeChannelButton.SetTextColor(Color.ParseColor("#efefef"));
                                //icon
                                Drawable icon = Activity.GetDrawable(Resource.Drawable.SubcribeButton);
                                icon.Bounds = new Rect(10, 10, 10, 7);
                                SubscribeChannelButton.SetCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);

                                //Remove The Video to Subcribed Videos Database
                                var sqlEntity = new SqLiteDatabase();
                                sqlEntity.RemoveSubscriptionsChannel(IdChannel);
                                sqlEntity.Dispose();

                                //Send API Request here for UnSubcribe
                                PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                    () => RequestsAsync.Global.Add_Subscribe_To_Channel_Http(UserData.Id)
                                });

                                // Toast.MakeText(this, this.GetText(Resource.String.Lbl_Channel_Removed_successfully, ToastLength.Short).Show();
                            }
                        }
                    }
                    else
                    {
                        PopupDialogController dialog = new PopupDialogController(Activity, null, "Login");
                        dialog.ShowNormalDialog(GetText(Resource.String.Lbl_Warning), GetText(Resource.String.Lbl_Please_sign_in_Subcribed), GetText(Resource.String.Lbl_Yes), GetText(Resource.String.Lbl_No));
                    }
                }
                else
                {
                    Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        private void OnLikeButtonClick(CommentAdapterViewHolder holder, CommentAdapterClickEventArgs e)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(ActivityContext, null, "Login");
                    dialog.ShowNormalDialog(ActivityContext.GetText(Resource.String.Lbl_Login), ActivityContext.GetText(Resource.String.Lbl_Message_Sorry_signin), ActivityContext.GetText(Resource.String.Lbl_Yes), ActivityContext.GetText(Resource.String.Lbl_No));
                    return;
                }

                if (Methods.CheckConnectivity())
                {
                    if (e.Class != null)
                    {
                        if (holder.LikeButton.Tag.ToString() == "1")
                        {
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.LikeiconView, IonIconsFonts.IosHeartOutline);
                            holder.LikeiconView.SetTextColor(Color.White);
                            holder.LikeButton.Tag  = "0";
                            e.Class.IsLikedComment = false;

                            if (!holder.LikeNumber.Text.Contains("K") && !holder.LikeNumber.Text.Contains("M"))
                            {
                                double x = Convert.ToDouble(holder.LikeNumber.Text);
                                if (x > 0)
                                {
                                    x--;
                                }
                                else
                                {
                                    x = 0;
                                }
                                holder.LikeNumber.Text = x.ToString(CultureInfo.InvariantCulture);
                                e.Class.CountLiked     = Convert.ToInt32(x);
                            }
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comments.LikeUnLikeCommentAsync(e.Class.Id.ToString(), false)
                            });
                        }
                        else
                        {
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.LikeiconView, IonIconsFonts.IosHeart);

                            holder.LikeiconView.SetTextColor(Color.ParseColor("#ed4856"));
                            holder.LikeButton.Tag  = "1";
                            e.Class.IsLikedComment = true;

                            if (!holder.LikeNumber.Text.Contains("K") && !holder.LikeNumber.Text.Contains("M"))
                            {
                                double x = Convert.ToDouble(holder.LikeNumber.Text);
                                x++;
                                holder.LikeNumber.Text = x.ToString(CultureInfo.InvariantCulture);
                                e.Class.CountLiked     = Convert.ToInt32(x);
                            }

                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comments.LikeUnLikeCommentAsync(e.Class.Id.ToString(), true)
                            });
                        }
                    }
                }
                else
                {
                    Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#24
0
        //Like
        private void LikeActLayoutOnClick(object sender, EventArgs e)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    if (UserDetails.IsLogin)
                    {
                        if (ItemActivity == null)
                        {
                            return;
                        }

                        ItemActivity.IsLiked = ItemActivity.IsLiked switch
                        {
                            "0" => "1",
                            "1" => "0",
                            _ => "1"
                        };

                        switch (ItemActivity.IsLiked)
                        {
                        case "0":
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconLikeAct, FontAwesomeIcon.ThumbsUp);
                            IconLikeAct.SetTextColor(Color.ParseColor("#444444"));
                            LikeActLayout.Tag = "Like";
                            break;

                        case "1":
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeSolid, IconLikeAct, FontAwesomeIcon.ThumbsUp);
                            IconLikeAct.SetTextColor(Color.ParseColor("#4caf50"));
                            LikeActLayout.Tag = "Liked";
                            break;

                        default:
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconLikeAct, FontAwesomeIcon.ThumbsUp);
                            IconLikeAct.SetTextColor(Color.ParseColor("#444444"));
                            LikeActLayout.Tag = "Like";
                            break;
                        }

                        switch (LikeActLayout.Tag.ToString())
                        {
                        case "Liked":
                        {
                            if (!ItemActivity.Likes.Contains("K") && !ItemActivity.Likes.Contains("M"))
                            {
                                var x = Convert.ToDouble(ItemActivity.Likes);
                                x++;
                                ItemActivity.Likes = x.ToString(CultureInfo.CurrentCulture);
                            }
                            break;
                        }

                        case "Like":
                        {
                            if (!ItemActivity.Likes.Contains("K") && !ItemActivity.Likes.Contains("M"))
                            {
                                var x = Convert.ToDouble(ItemActivity.Likes);
                                if (x > 0)
                                {
                                    x--;
                                }
                                else
                                {
                                    x = 0;
                                }

                                ItemActivity.Likes = x.ToString(CultureInfo.CurrentCulture);
                            }
                            break;
                        }
                        }

                        CountLikeAct.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(ItemActivity.Likes));

                        if (ItemActivity.IsDisliked == "1")
                        {
                            ItemActivity.IsDisliked = "0";
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconDislikeAct, FontAwesomeIcon.ThumbsDown);
                            IconDislikeAct.SetTextColor(Color.ParseColor("#444444"));
                            DislikeActLayout.Tag = "Dislike";

                            if (!ItemActivity.Dislikes.Contains("K") && !ItemActivity.Dislikes.Contains("M"))
                            {
                                var x = Convert.ToDouble(ItemActivity.Dislikes);
                                if (x > 0)
                                {
                                    x--;
                                }
                                else
                                {
                                    x = 0;
                                }

                                ItemActivity.Dislikes = x.ToString(CultureInfo.CurrentCulture);
                            }
                        }

                        CountDislikeAct.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(ItemActivity.Dislikes));

                        if (!Methods.CheckConnectivity())
                        {
                            Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                        }
                        else
                        {
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Activities.LikeActivity_Http(ItemActivity.Id)
                            });
                        }
                    }
                    else
                    {
                        PopupDialogController dialog = new PopupDialogController(Activity, null, "Login");
                        dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning), Activity.GetText(Resource.String.Lbl_Please_sign_in_Dislike), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No));
                    }
                }
                else
                {
                    Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#25
0
        private void SendButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(EmojiconEditTextView.Text))
                {
                    if (UserDetails.IsLogin)
                    {
                        if (Methods.CheckConnectivity())
                        {
                            //Comment Code
                            string time = Methods.Time.TimeAgo(DateTime.Now, false);
                            EmojiconEditTextView.ClearFocus();

                            int    unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                            string time2         = unixTimestamp.ToString();
                            string message       = EmojiconEditTextView.Text;

                            ReplyObject comment = new ReplyObject
                            {
                                Text          = message,
                                TextTime      = time,
                                UserId        = Convert.ToInt32(UserDetails.UserId),
                                Id            = Convert.ToInt32(time2),
                                IsReplyOwner  = true,
                                PostId        = Convert.ToInt32(Comment.PostId),
                                ReplyUserData = new UserDataObject
                                {
                                    Avatar   = UserDetails.Avatar,
                                    Username = UserDetails.Username,
                                    Name     = UserDetails.FullName,
                                }
                            };

                            EmptyStateLayout.Visibility  = ViewStates.Gone;
                            ReplyRecyclerView.Visibility = ViewStates.Visible;
                            ReplyAdapter.ReplyList.Add(comment);
                            ReplyAdapter.NotifyItemInserted(ReplyAdapter.ReplyList.Count - 1);
                            ReplyRecyclerView.ScrollToPosition(ReplyAdapter.ReplyList.Count - 1);
                            var x = Convert.ToInt32(Comment.RepliesCount);
                            RepliesCount.Text = Methods.FunString.FormatPriceValue(++x);

                            if (Type == "video")
                            {
                                var dataComments = ActivityContext?.CommentsFragment?.MAdapter?.CommentList?.FirstOrDefault(a => a.Id == Comment.Id);
                                if (dataComments != null)
                                {
                                    dataComments.RepliesCount++;

                                    if (dataComments.CommentReplies?.Count > 0)
                                    {
                                        dataComments.CommentReplies.Add(comment);
                                    }
                                    else
                                    {
                                        dataComments.CommentReplies = new List <ReplyObject> {
                                            comment
                                        };
                                    }

                                    int index = ActivityContext.CommentsFragment.MAdapter.CommentList.IndexOf(dataComments);
                                    ActivityContext?.CommentsFragment?.MAdapter.NotifyItemChanged(index);
                                }

                                //Api request
                                //Task.Run(async () =>
                                //{
                                //    var (respondCode, respond) = await RequestsAsync.Comments.Reply_Video_comments_Http(Comment.VideoId.ToString(), Comment.Id.ToString(), message);
                                //    if (respondCode.Equals(200))
                                //    {
                                //        if (respond is AddReplyObject result)
                                //        {
                                //            var dataComment = ReplyAdapter.ReplyList.FirstOrDefault(a => a.Id == int.Parse(time2));
                                //            if (dataComment != null)
                                //                dataComment.Id = result.ReplyId;
                                //        }
                                //    }
                                //    else Methods.DisplayReportResult(Activity, respond);
                                //});
                                Task.Run(async() =>
                                {
                                    using (var client = new System.Net.Http.HttpClient())
                                    {
                                        var formContent = new System.Net.Http.FormUrlEncodedContent(new[]
                                        {
                                            new KeyValuePair <string, string>("server_key", "0913cbbd8c729a5db4db40e4aa267a17"),
                                            new KeyValuePair <string, string>("type", "reply"),
                                            new KeyValuePair <string, string>("video_id", Comment.VideoId.ToString()),
                                            new KeyValuePair <string, string>("comment_id", Comment.Id.ToString()),
                                            new KeyValuePair <string, string>("text", message),
                                            new KeyValuePair <string, string>("user_id", UserDetails.UserId),
                                            new KeyValuePair <string, string>("s", UserDetails.AccessToken)
                                        });

                                        //  send a Post request
                                        var uri    = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=response_comments";
                                        var result = await client.PostAsync(uri, formContent);
                                        if (result.IsSuccessStatusCode)
                                        {
                                            // handling the answer
                                            var resultString  = await result.Content.ReadAsStringAsync();
                                            var jConfigObject = Newtonsoft.Json.Linq.JObject.Parse(resultString);
                                            if (jConfigObject["api_status"].ToString() == "200")
                                            {
                                                var dataComment = ReplyAdapter.ReplyList.FirstOrDefault(a => a.Id == int.Parse(time2));
                                                if (dataComment != null)
                                                {
                                                    dataComment.Id = Int32.Parse(jConfigObject["reply_id"].ToString());
                                                }
                                            }
                                            else
                                            {
                                                Methods.DisplayReportResult(Activity, "An unknown error occurred. Please try again later");
                                            }
                                        }
                                    }
                                });
                            }
                            else if (Type == "Article")
                            {
                                var dataComments = ShowArticleActivity.MAdapter?.CommentList?.FirstOrDefault(a => a.Id == Comment.Id);
                                if (dataComments != null)
                                {
                                    dataComments.RepliesCount++;

                                    if (dataComments.CommentReplies?.Count > 0)
                                    {
                                        dataComments.CommentReplies.Add(comment);
                                    }
                                    else
                                    {
                                        dataComments.CommentReplies = new List <ReplyObject> {
                                            comment
                                        };
                                    }

                                    int index = ShowArticleActivity.MAdapter.CommentList.IndexOf(dataComments);
                                    ShowArticleActivity.MAdapter.NotifyItemChanged(index);
                                }

                                //Api request
                                Task.Run(async() =>
                                {
                                    var(respondCode, respond) = await RequestsAsync.Articles.reply_Articles_comments_Http(Comment.PostId.ToString(), Comment.Id.ToString(), message);
                                    if (respondCode.Equals(200))
                                    {
                                        if (respond is AddReplyObject result)
                                        {
                                            var dataComment = ReplyAdapter.ReplyList.FirstOrDefault(a => a.Id == int.Parse(time2));
                                            if (dataComment != null)
                                            {
                                                dataComment.Id = result.ReplyId;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Methods.DisplayReportResult(Activity, respond);
                                    }
                                });
                            }

                            //Hide keyboard
                            EmojiconEditTextView.Text = "";
                            EmojiconEditTextView.ClearFocus();
                        }
                        else
                        {
                            Toast.MakeText(Activity, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                        }
                    }
                    else
                    {
                        PopupDialogController dialog = new PopupDialogController(Activity, null, "Login");
                        dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning),
                                                Activity.GetText(Resource.String.Lbl_Please_sign_in_comment),
                                                Activity.GetText(Resource.String.Lbl_Yes),
                                                Activity.GetText(Resource.String.Lbl_No));
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#26
0
        private async void OnLikeButtonClick(object sender, EventArgs e)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    if (UserDetails.IsLogin)
                    {
                        dynamic dataComments = Type == "video" ? ActivityContext?.CommentsFragment?.MAdapter?.CommentList?.FirstOrDefault(a => a.Id == Comment.Id) : ShowArticleActivity.MAdapter?.CommentList?.FirstOrDefault(a => a.Id == Comment.Id);

                        if (dataComments != null)
                        {
                            if (LikeButton.Tag.ToString() == "1")
                            {
                                LikeiconView.SetColorFilter(Color.ParseColor("#777777"));

                                LikeButton.Tag = "0";
                                dataComments.IsLikedComment = 0;

                                if (!LikeNumber.Text.Contains("K") && !LikeNumber.Text.Contains("M"))
                                {
                                    double x = Convert.ToDouble(LikeNumber.Text);
                                    if (x > 0)
                                    {
                                        x--;
                                    }
                                    else
                                    {
                                        x = 0;
                                    }
                                    LikeNumber.Text    = x.ToString(CultureInfo.InvariantCulture);
                                    dataComments.Likes = Convert.ToInt32(x);
                                }
                            }
                            else
                            {
                                LikeiconView.SetColorFilter(Color.ParseColor(AppSettings.MainColor));
                                LikeButton.Tag = "1";
                                dataComments.IsLikedComment = 1;

                                if (!LikeNumber.Text.Contains("K") && !LikeNumber.Text.Contains("M"))
                                {
                                    double x = Convert.ToDouble(LikeNumber.Text);
                                    x++;
                                    LikeNumber.Text    = x.ToString(CultureInfo.InvariantCulture);
                                    dataComments.Likes = Convert.ToInt32(x);
                                }
                            }

                            if (UnLikeButton.Tag.ToString() == "1")
                            {
                                UnLikeiconView.SetColorFilter(Color.ParseColor("#777777"));

                                UnLikeButton.Tag = "0";
                                dataComments.IsDislikedComment = 0;

                                if (!UnLikeNumber.Text.Contains("K") && !UnLikeNumber.Text.Contains("M"))
                                {
                                    double x = Convert.ToDouble(UnLikeNumber.Text);
                                    if (x > 0)
                                    {
                                        x--;
                                    }
                                    else
                                    {
                                        x = 0;
                                    }
                                    UnLikeNumber.Text     = x.ToString(CultureInfo.InvariantCulture);
                                    dataComments.DisLikes = Convert.ToInt32(x);
                                }
                            }
                            //PollyController.RunRetryPolicyFunction(new List<Func<Task>> { () => RequestsAsync.Comments.Add_likeOrDislike_Comment_Http(dataComments.Id.ToString(), true) });
                            using (var client = new System.Net.Http.HttpClient())
                            {
                                var formContent = new System.Net.Http.FormUrlEncodedContent(new[]
                                {
                                    new KeyValuePair <string, string>("server_key", "0913cbbd8c729a5db4db40e4aa267a17"),
                                    new KeyValuePair <string, string>("type", "like"),
                                    new KeyValuePair <string, string>("reply_id", dataComments.Id.ToString()),
                                    new KeyValuePair <string, string>("user_id", UserDetails.UserId),
                                    new KeyValuePair <string, string>("s", UserDetails.AccessToken)
                                });

                                //  send a Post request
                                var uri    = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=response_comments";
                                var result = await client.PostAsync(uri, formContent);

                                if (result.IsSuccessStatusCode)
                                {
                                    // handling the answer
                                    var resultString = await result.Content.ReadAsStringAsync();

                                    var jConfigObject = Newtonsoft.Json.Linq.JObject.Parse(resultString);
                                    if (jConfigObject["api_status"].ToString() != "200")
                                    {
                                        Methods.DisplayReportResult(ActivityContext, "An unknown error occurred. Please try again later");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        PopupDialogController dialog = new PopupDialogController(ActivityContext, null, "Login");
                        dialog.ShowNormalDialog(ActivityContext.GetText(Resource.String.Lbl_Warning), ActivityContext.GetText(Resource.String.Lbl_Please_sign_in_Like), ActivityContext.GetText(Resource.String.Lbl_Yes),
                                                ActivityContext.GetText(Resource.String.Lbl_No));
                    }
                }
                else
                {
                    Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        private async void SendButtonOnClick(object sender, EventArgs e)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(ActivityContext, null, "Login");
                    dialog.ShowNormalDialog(ActivityContext.GetText(Resource.String.Lbl_Login), ActivityContext.GetText(Resource.String.Lbl_Message_Sorry_signin), ActivityContext.GetText(Resource.String.Lbl_Yes), ActivityContext.GetText(Resource.String.Lbl_No));
                    return;
                }

                if (string.IsNullOrEmpty(EmojisIconEditTextView.Text))
                {
                    return;
                }

                if (Methods.CheckConnectivity())
                {
                    EmptyStateLayout.Visibility = ViewStates.Gone;

                    //Comment Code
                    string time = Methods.Time.TimeAgo(DateTime.Now);

                    UnixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;

                    CommentsDataObject comment = new CommentsDataObject
                    {
                        Id              = UnixTimestamp,
                        TrackId         = DataObject.Id,
                        UserId          = UserDetails.UserId,
                        Value           = EmojisIconEditTextView.Text,
                        Songseconds     = 0,
                        Songpercentage  = 0,
                        Time            = UnixTimestamp,
                        Posted          = time,
                        SecondsFormated = TimeComment,
                        Owner           = true,
                        UserData        = ListUtils.MyUserInfoList.FirstOrDefault(),
                        IsLikedComment  = false,
                        CountLiked      = 0,
                    };

                    MAdapter.CommentList.Add(comment);

                    var index = MAdapter.CommentList.IndexOf(comment);
                    if (index > -1)
                    {
                        MAdapter.NotifyItemInserted(index);
                    }

                    MRecycler.Visibility        = ViewStates.Visible;
                    EmptyStateLayout.Visibility = ViewStates.Gone;

                    (int apiStatus, var respond) = await RequestsAsync.Comments.CreateCommentAsync(DataObject.AudioId, TimeComment, EmojisIconEditTextView.Text).ConfigureAwait(false);

                    if (apiStatus == 200)
                    {
                        if (respond is CreateCommentObject result)
                        {
                            var date = MAdapter.CommentList.FirstOrDefault(a => a.Id == UnixTimestamp);
                            if (date != null)
                            {
                                date.Id = result.Data.CommentId;

                                index = MAdapter.CommentList.IndexOf(comment);
                                if (index > -1)
                                {
                                    ActivityContext.RunOnUiThread(() =>
                                    {
                                        try
                                        {
                                            MAdapter.NotifyItemChanged(index);
                                            MRecycler.ScrollToPosition(index);
                                        }
                                        catch (Exception exception)
                                        {
                                            Console.WriteLine(exception);
                                        }
                                    });
                                }
                            }

                            Console.WriteLine(date);
                        }
                    }
                    else
                    {
                        Methods.DisplayReportResult(ActivityContext, respond);
                    }

                    //Hide keyboard
                    EmojisIconEditTextView.Text = "";
                    EmojisIconEditTextView.ClearFocus();
                }
                else
                {
                    Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#28
0
        //Add Comment
        private async void ImgSentOnClick(object sender, EventArgs e)
        {
            try
            {
                if (UserDetails.IsLogin)
                {
                    if (!string.IsNullOrEmpty(TxtComment.Text))
                    {
                        if (Methods.CheckConnectivity())
                        {
                            if (MAdapter.CommentList.Count == 0)
                            {
                                EmptyStateLayout.Visibility = ViewStates.Gone;
                                MRecycler.Visibility        = ViewStates.Visible;
                            }

                            //Comment Code
                            string time          = Methods.Time.TimeAgo(DateTime.Now, false);
                            int    unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                            string time2         = unixTimestamp.ToString();
                            string message       = TxtComment.Text;
                            var    postId        = MAdapter.CommentList.FirstOrDefault(a => a.ActivityId == Convert.ToInt32(ActivityId))?.PostId ?? 0;

                            var comment = new CommentObject
                            {
                                Text            = message,
                                TextTime        = time,
                                UserId          = Convert.ToInt32(UserDetails.UserId),
                                Id              = Convert.ToInt32(time2),
                                IsCommentOwner  = true,
                                ActivityId      = Convert.ToInt32(ActivityId),
                                CommentUserData = new UserDataObject
                                {
                                    Avatar   = UserDetails.Avatar,
                                    Username = UserDetails.Username,
                                    Name     = UserDetails.FullName,
                                    Cover    = UserDetails.Cover
                                },
                                CommentReplies    = new List <ReplyObject>(),
                                DisLikes          = 0,
                                IsDislikedComment = 0,
                                IsLikedComment    = 0,
                                Likes             = 0,
                                Pinned            = "",
                                PostId            = postId,
                                RepliesCount      = 0,
                                Time = unixTimestamp
                            };

                            MAdapter.CommentList.Add(comment);
                            int index = MAdapter.CommentList.IndexOf(comment);
                            MAdapter.NotifyItemInserted(index);
                            MRecycler.ScrollToPosition(MAdapter.CommentList.IndexOf(MAdapter.CommentList.Last()));

                            //Api request
                            var(respondCode, respond) = await RequestsAsync.Activities.AddCommentActivity_Http(ActivityId, message);

                            if (respondCode.Equals(200))
                            {
                                if (respond is MessageIdObject messageId)
                                {
                                    var dataComment = MAdapter.CommentList.FirstOrDefault(a => a.Id == int.Parse(time2));
                                    if (dataComment != null)
                                    {
                                        dataComment.Id = messageId.Id;
                                    }
                                }
                            }
                            else
                            {
                                Methods.DisplayReportResult(Activity, respond);
                            }

                            //Hide keyboard
                            TxtComment.Text = "";
                            TxtComment.ClearFocus();
                        }
                        else
                        {
                            Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                        }
                    }
                }
                else
                {
                    PopupDialogController dialog = new PopupDialogController(Activity, null, "Login");
                    dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning), Activity.GetText(Resource.String.Lbl_Please_sign_in_comment), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No));
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#29
0
        //Add New Comment
        private void SendButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (UserDetails.IsLogin)
                {
                    if (!string.IsNullOrEmpty(EmojiconEditTextView.Text))
                    {
                        if (Methods.CheckConnectivity())
                        {
                            if (MAdapter.CommentList.Count == 0)
                            {
                                EmptyStateLayout.Visibility = ViewStates.Gone;
                                MRecycler.Visibility        = ViewStates.Visible;
                            }

                            //Comment Code
                            string time          = Methods.Time.TimeAgo(DateTime.Now, false);
                            int    unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                            string time2         = unixTimestamp.ToString();
                            string message       = EmojiconEditTextView.Text;
                            var    postId        = MAdapter.CommentList.FirstOrDefault(a => a.VideoId == Convert.ToInt32(VideoId))?.PostId ?? 0;

                            CommentObject comment = new CommentObject
                            {
                                Text            = message,
                                TextTime        = time,
                                UserId          = Convert.ToInt32(UserDetails.UserId),
                                Id              = Convert.ToInt32(time2),
                                IsCommentOwner  = true,
                                VideoId         = Convert.ToInt32(VideoId),
                                CommentUserData = new UserDataObject
                                {
                                    Avatar   = UserDetails.Avatar,
                                    Username = UserDetails.Username,
                                    Name     = UserDetails.FullName,
                                    Cover    = UserDetails.Cover
                                },
                                CommentReplies    = new List <ReplyObject>(),
                                DisLikes          = 0,
                                IsDislikedComment = 0,
                                IsLikedComment    = 0,
                                Likes             = 0,
                                Pinned            = "",
                                PostId            = postId,
                                RepliesCount      = 0,
                                Time = unixTimestamp
                            };

                            MAdapter.CommentList.Add(comment);
                            int index = MAdapter.CommentList.IndexOf(comment);
                            MAdapter.NotifyItemInserted(index);
                            MRecycler.ScrollToPosition(MAdapter.CommentList.IndexOf(MAdapter.CommentList.Last()));

                            var y = MAdapter.CommentList.Count;
                            MainContext.txtCommentNumber.Text = y.ToString(System.Globalization.CultureInfo.InvariantCulture);
                            int index2 = MainContext.mediaList.FindIndex(x => x.Id == MainContext.selectedMedia.Id);
                            MainContext.mediaList[index2].Comments = y.ToString();
                            //Api request
                            Task.Run(async() =>
                            {
                                using (var client = new System.Net.Http.HttpClient())
                                {
                                    var formContent = new System.Net.Http.FormUrlEncodedContent(new[]
                                    {
                                        new KeyValuePair <string, string>("server_key", "0913cbbd8c729a5db4db40e4aa267a17"),
                                        new KeyValuePair <string, string>("video_id", VideoId),
                                        new KeyValuePair <string, string>("user_id", UserDetails.UserId),
                                        new KeyValuePair <string, string>("text", message),
                                        new KeyValuePair <string, string>("s", UserDetails.AccessToken)
                                    });

                                    //  send a Post request
                                    var uri    = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=add_response_comment";
                                    var result = await client.PostAsync(uri, formContent);
                                    if (result.IsSuccessStatusCode)
                                    {
                                        // handling the answer
                                        var resultString  = await result.Content.ReadAsStringAsync();
                                        var jConfigObject = Newtonsoft.Json.Linq.JObject.Parse(resultString);
                                        if (jConfigObject["api_status"].ToString() == "200")
                                        {
                                            var dataComment = MAdapter.CommentList.FirstOrDefault(a => a.Id == int.Parse(time2));
                                            if (dataComment != null)
                                            {
                                                dataComment.Id = Int32.Parse(jConfigObject["id"].ToString());
                                            }
                                        }
                                        else
                                        {
                                            Methods.DisplayReportResult(Activity, "An unknown error occurred. Please try again later");
                                        }
                                    }
                                }
                                //var (respondCode, respond) = await RequestsAsync.Comments.Add_Comment_Http(VideoId, message);
                                //if (respondCode.Equals(200))
                                //{
                                //    if (respond is MessageIdObject Object)
                                //    {
                                //        var dataComment = MAdapter.CommentList.FirstOrDefault(a => a.Id == int.Parse(time2));
                                //        if (dataComment != null)
                                //            dataComment.Id = Object.Id;
                                //    }
                                //}
                                //else Methods.DisplayReportResult(Activity, respond);
                            });

                            //Hide keyboard
                            EmojiconEditTextView.Text = "";
                            EmojiconEditTextView.ClearFocus();
                        }
                        else
                        {
                            Toast.MakeText(Activity, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                        }
                    }
                }
                else
                {
                    PopupDialogController dialog = new PopupDialogController(Activity, null, "Login");
                    dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning),
                                            Activity.GetText(Resource.String.Lbl_Please_sign_in_comment),
                                            Activity.GetText(Resource.String.Lbl_Yes),
                                            Activity.GetText(Resource.String.Lbl_No));
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#30
0
        private async void BtnNextOnClick(object sender, EventArgs e)
        {
            try
            {
                if (!UserDetails.IsLogin)
                {
                    PopupDialogController dialog = new PopupDialogController(this, null, "Login");
                    dialog.ShowNormalDialog(GetText(Resource.String.Lbl_Login), GetText(Resource.String.Lbl_Message_Sorry_signin), GetText(Resource.String.Lbl_Yes), GetText(Resource.String.Lbl_No));
                    return;
                }

                string totalIdChecked = "";
                var    list           = GenresAdapter.GenresList.Where(genres => genres.Checked).ToList();
                if (list.Count > 0)
                {
                    //Show a progress
                    AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading));

                    //Get all id
                    totalIdChecked = list.Aggregate(totalIdChecked, (current, item) => current + (item.Id + ","));

                    //Sent Api
                    if (!string.IsNullOrEmpty(totalIdChecked))
                    {
                        (int apiStatus, var respond) = await RequestsAsync.Common.UpdateInterestAsync(UserDetails.UserId.ToString(), totalIdChecked.Remove(totalIdChecked.Length - 1, 1)).ConfigureAwait(false);

                        if (apiStatus == 200)
                        {
                            if (respond is MessageObject result)
                            {
                                Console.WriteLine(result.Message);
                                RunOnUiThread(() =>
                                {
                                    try
                                    {
                                        //AndHUD.Shared.Dismiss(this);
                                        // Toast.MakeText(this, "Subscription has been updated in" + " " + list?.Count + " " + "interests", ToastLength.Long).Show();

                                        switch (TypeBtn)
                                        {
                                        case "Save":
                                            Finish();
                                            break;

                                        case "Continue":
                                            StartActivity(new Intent(this, typeof(BoardingActivity)));
                                            Finish();
                                            break;
                                        }
                                    }
                                    catch (Exception exception)
                                    {
                                        Console.WriteLine(exception);
                                    }
                                });
                            }
                        }
                        else
                        {
                            Methods.DisplayReportResult(this, respond);
                        }
                    }
                }
                else
                {
                    AndHUD.Shared.ShowError(this, GetText(Resource.String.Lbl_PleaseSelectInterest), MaskType.Clear, TimeSpan.FromSeconds(2));
                }

                AndHUD.Shared.Dismiss(this);
            }
            catch (Exception exception)
            {
                AndHUD.Shared.Dismiss(this);
                Console.WriteLine(exception);
            }
        }