예제 #1
0
 private void MAdapterOnItemClick(object sender, NotificationAdapterClickEventArgs e)
 {
     try
     {
         if (e.Position >= 0)
         {
             var item = MAdapter.GetItem(e.Position);
             if (item != null)
             {
                 if (item.Title.Contains("added") || item.Title.Contains("disliked") || item.Title.Contains("liked") || item.Title.Contains("commented"))
                 {
                     MainContext.StartPlayVideo(item.Video);
                 }
                 else if (item.Title.Contains("unsubscribed") || item.Title.Contains("subscribed"))
                 {
                     MainContext.ShowUserChannelFragment(item.Userdata, item.Userdata.Id);
                 }
                 else
                 {
                     MainContext.ShowUserChannelFragment(item.Userdata, item.Userdata.Id);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
예제 #2
0
        //Open Video from Fav
        private void FavVideosAdapterOnItemClick(object sender, VideoAdapterClickEventArgs e)
        {
            try
            {
                if (e.Position <= -1)
                {
                    return;
                }

                var item = FavVideosAdapter.GetItem(e.Position);
                if (item == null)
                {
                    return;
                }

                GlobalContext.StartPlayVideo(item);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
예제 #3
0
        //Open Video from Other
        private void OnVideoItemClick(object sender, VideoAdapterClickEventArgs args)
        {
            try
            {
                if (args.Position <= -1)
                {
                    return;
                }

                var item = MAdapter.GetItem(args.Position);
                if (item.VideoData == null)
                {
                    return;
                }

                GlobalContext.StartPlayVideo(item.VideoData);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        //Result
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);

                if (requestCode == LoadPaymentDataRequestCode)
                {
                    switch (resultCode)
                    {
                    case Result.Ok:
                        PaymentData paymentData = PaymentData.GetFromIntent(data);
                        // You can get some data on the user's card, such as the brand and last 4 digits
                        CardInfo info = paymentData.CardInfo;
                        // You can also pull the user address from the PaymentData object.
                        UserAddress address = paymentData.ShippingAddress;
                        // This is the raw string version of your Stripe token.
                        string rawToken = paymentData.PaymentMethodToken.Token;

                        // Now that you have a Stripe token object, charge that by using the id
                        Token stripeToken = Token.FromString(rawToken);
                        if (stripeToken != null)
                        {
                            // This chargeToken function is a call to your own server, which should then connect
                            // to Stripe's API to finish the charge.
                            // chargeToken(stripeToken.getId());
                            //var stripeBankAccount = stripeToken.BankAccount;
                            //var stripeCard = stripeToken.Card;
                            //var stripeCreated = stripeToken.Created;
                            //var stripeId = stripeToken.Id;
                            //var stripeLiveMode = stripeToken.Livemode;
                            //var stripeType = stripeToken.Type;
                            //var stripeUsed = stripeToken.Used;

                            //send api
                            if (PayType == "purchaseVideo")
                            {
                                if (Methods.CheckConnectivity())
                                {
                                    (int apiStatus, var respond) = await RequestsAsync.Global.BuyVideoAsync(Id);

                                    if (apiStatus == 200)
                                    {
                                        if (respond is MessageObject result)
                                        {
                                            FragmentTransaction ft = SupportFragmentManager.BeginTransaction();

                                            if (GlobalContext.RestrictedVideoPlayerFragment != null && GlobalContext.RestrictedVideoPlayerFragment.IsAdded)
                                            {
                                                ft.Hide(GlobalContext.RestrictedVideoPlayerFragment);
                                            }

                                            if (GlobalContext.YouTubeFragment != null)
                                            {
                                                if (GlobalContext.YouTubeFragment.IsAdded)
                                                {
                                                    if (GlobalContext.YoutubePlayer != null && GlobalContext.YoutubePlayer.IsPlaying)
                                                    {
                                                        GlobalContext.YoutubePlayer?.Pause();
                                                    }

                                                    ft.Hide(GlobalContext.YouTubeFragment).AddToBackStack(null).Commit();
                                                    GlobalContext.YouTubeFragment.View.Visibility = ViewStates.Gone;

                                                    if (GlobalContext.VideoActionsController.SimpleExoPlayerView.Visibility == ViewStates.Gone)
                                                    {
                                                        GlobalContext.VideoActionsController.SimpleExoPlayerView.Visibility = ViewStates.Visible;
                                                    }
                                                }
                                            }

                                            GlobalContext.PaymentVideoObject.IsPurchased = "1";
                                            GlobalContext.StartPlayVideo(GlobalContext.PaymentVideoObject);

                                            Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long).Show();
                                            StopService(new Intent(this, typeof(PayPalService)));
                                        }
                                    }
                                    else
                                    {
                                        Methods.DisplayReportResult(this, respond);
                                    }
                                }
                                else
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                                }
                            }
                            else if (PayType == "Subscriber")
                            {
                                if (Methods.CheckConnectivity())
                                {
                                    TabbedMainActivity.GetInstance()?.UserChannelFragment?.SetSubscribeChannelWithPaid();
                                }
                                else
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                                }
                            }
                            else if (PayType == "SubscriberVideo")
                            {
                                if (Methods.CheckConnectivity())
                                {
                                    if (GlobalPlayerActivity.OnOpenPage)
                                    {
                                        GlobalPlayerActivity.GetInstance()?.SetSubscribeChannelWithPaid();
                                    }
                                    else
                                    {
                                        TabbedMainActivity.GetInstance()?.VideoDataWithEventsLoader.SetSubscribeChannelWithPaid();
                                    }
                                }
                                else
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                                }
                            }
                            else if (PayType == "RentVideo")
                            {
                                if (Methods.CheckConnectivity())
                                {
                                    (int apiStatus, var respond) = await RequestsAsync.Video.RentVideo_Http(Id).ConfigureAwait(false);

                                    if (apiStatus == 200)
                                    {
                                        RunOnUiThread(() =>
                                        {
                                            Toast.MakeText(this, GetText(Resource.String.Lbl_VideoSuccessfullyPaid), ToastLength.Long).Show();
                                        });
                                    }
                                    else
                                    {
                                        Methods.DisplayReportResult(this, respond);
                                    }
                                }
                                else
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                                }
                            }
                            else if (PayType == "DonateVideo")
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_DonatedSuccessfully), ToastLength.Long).Show();
                            }
                            else if (PayType == "GoPro")
                            {
                                if (Methods.CheckConnectivity())
                                {
                                    (int apiStatus, var respond) = await RequestsAsync.Global.UpgradeAsync();

                                    if (apiStatus == 200)
                                    {
                                        var dataUser = ListUtils.MyChannelList.FirstOrDefault();
                                        if (dataUser != null)
                                        {
                                            dataUser.IsPro = "1";

                                            var sqlEntity = new SqLiteDatabase();
                                            sqlEntity.InsertOrUpdate_DataMyChannel(dataUser);
                                            sqlEntity.Dispose();
                                        }

                                        Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long).Show();
                                        Finish();
                                    }
                                    else
                                    {
                                        Methods.DisplayReportResult(this, respond);
                                    }
                                }
                                else
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                                }
                            }
                        }

                        break;

                    case Result.Canceled:
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Canceled), ToastLength.Long).Show();
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }