public async void SetSubscribeChannelWithPaid() { try { if (Methods.CheckConnectivity()) { 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 Subscribe Videos Database Events_Insert_SubscriptionsChannel(); //Send API Request here for Subscribe (int apiStatus, var respond) = await RequestsAsync.Global.Add_Subscribe_To_Channel_Http(IdChannel, "paid"); if (apiStatus == 200) { if (respond is MessageObject result) { Console.WriteLine(result.Message); Activity.RunOnUiThread(() => { Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_Subscribed_successfully), ToastLength.Short).Show(); PlayListFragment.ShowEmptyPage(); VideosFragment.ShowEmptyPage(); }); } } else { Methods.DisplayReportResult(Activity, respond); } } } catch (Exception e) { Console.WriteLine(e); } }
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); } }