public VideoDownloadAsyncController(string url, string filename, Activity contextActivity, string fromActivity)
        {
            try
            {
                if (fromActivity == "Main")
                {
                    ActivityContext = TabbedMainActivity.GetInstance();
                }
                else if (fromActivity == "GlobalPlayer")
                {
                    ActivityContext = GlobalPlayerActivity.GetInstance();
                }
                else
                {
                    ActivityContext = contextActivity;
                }

                if (!Directory.Exists(FilePath))
                {
                    Directory.CreateDirectory(FilePath);
                }

                if (!filename.Contains(".mp4") || !filename.Contains(".Mp4") || !filename.Contains(".MP4"))
                {
                    Filename = filename + ".mp4";
                }

                Downloadmanager = (DownloadManager)ActivityContext.GetSystemService(Context.DownloadService);
                Request         = new DownloadManager.Request(Android.Net.Uri.Parse(url));
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
예제 #2
0
 public UserResponsePostDescription(Intent data, Context context, int type)
 {
     intentData  = data;
     mainContext = context;
     if (type == 1)
     {
         tabbed = (TabbedMainActivity)context;
     }
     else if (type == 2)
     {
         global = (GlobalPlayerActivity)context;
     }
 }
예제 #3
0
        public void OnInput(MaterialDialog p0, ICharSequence p1)
        {
            try
            {
                if (p1.Length() > 0)
                {
                    var strName = p1.ToString();

                    if (!Methods.CheckConnectivity())
                    {
                        Toast.MakeText(MainContext, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    }
                    else
                    {
                        if (TypeClass == "Comment")
                        {
                            //TypeClass
                            var adapterGlobal = MainContext?.CommentsFragment?.MAdapter;
                            var dataGlobal    = adapterGlobal?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id);
                            if (dataGlobal != null)
                            {
                                dataGlobal.Text = strName;
                                var index = adapterGlobal.CommentList.IndexOf(dataGlobal);
                                if (index > -1)
                                {
                                    adapterGlobal.NotifyItemChanged(index);
                                }
                            }

                            var adapterGlobal1 = GlobalPlayerActivity.GetInstance()?.CommentsFragment?.MAdapter;
                            var dataGlobal1    = adapterGlobal1?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id);
                            if (dataGlobal1 != null)
                            {
                                dataGlobal1.Text = strName;
                                var index = adapterGlobal1.CommentList.IndexOf(dataGlobal1);
                                if (index > -1)
                                {
                                    adapterGlobal1.NotifyItemChanged(index);
                                }
                            }
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comments.Edit_Comment_Http(CommentObject.Id.ToString(), strName)
                            });
                        }
                        else if (TypeClass == "Reply")
                        {
                            //TypeClass
                            var adapterGlobal = ReplyCommentBottomSheet.GetInstance()?.ReplyAdapter;
                            var dataGlobal    = adapterGlobal?.ReplyList?.FirstOrDefault(a => a.Id == ReplyObject?.Id);
                            if (dataGlobal != null)
                            {
                                dataGlobal.Text = strName;
                                var index = adapterGlobal.ReplyList.IndexOf(dataGlobal);
                                if (index > -1)
                                {
                                    adapterGlobal.NotifyItemChanged(index);
                                }
                            }

                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comments.Edit_Comment_Reply_Http(ReplyObject.Id.ToString(), strName)
                            });
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
예제 #4
0
        public void OnClick(MaterialDialog p0, DialogAction p1)
        {
            try
            {
                if (p1 == DialogAction.Positive)
                {
                    if (TypeDialog == "DeleteComment")
                    {
                        MainContext.RunOnUiThread(() =>
                        {
                            try
                            {
                                if (TypeClass == "Comment")
                                {
                                    //TypeClass
                                    var adapterGlobal = MainContext?.CommentsFragment?.MAdapter;
                                    var dataGlobal    = adapterGlobal?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id);
                                    if (dataGlobal != null)
                                    {
                                        var index = adapterGlobal.CommentList.IndexOf(dataGlobal);
                                        if (index > -1)
                                        {
                                            adapterGlobal.CommentList.RemoveAt(index);
                                            adapterGlobal.NotifyItemRemoved(index);
                                        }
                                    }

                                    var adapterGlobal1 = GlobalPlayerActivity.GetInstance()?.CommentsFragment?.MAdapter;
                                    var dataGlobal1    = adapterGlobal1?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id);
                                    if (dataGlobal1 != null)
                                    {
                                        var index = adapterGlobal1.CommentList.IndexOf(dataGlobal1);
                                        if (index > -1)
                                        {
                                            adapterGlobal1.CommentList.RemoveAt(index);
                                            adapterGlobal1.NotifyItemRemoved(index);
                                        }
                                    }

                                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                        () => RequestsAsync.Comments.Delete_Comment_Http(CommentObject.Id.ToString())
                                    });
                                }
                                else if (TypeClass == "Reply")
                                {
                                    //TypeClass
                                    var adapterGlobal = ReplyCommentBottomSheet.GetInstance()?.ReplyAdapter;
                                    var dataGlobal    = adapterGlobal?.ReplyList?.FirstOrDefault(a => a.Id == ReplyObject?.Id);
                                    if (dataGlobal != null)
                                    {
                                        var index = adapterGlobal.ReplyList.IndexOf(dataGlobal);
                                        if (index > -1)
                                        {
                                            adapterGlobal.ReplyList.RemoveAt(index);
                                            adapterGlobal.NotifyItemRemoved(index);
                                        }
                                    }

                                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                        () => RequestsAsync.Comments.Delete_Reply_Http(ReplyObject.Id.ToString())
                                    });
                                }

                                Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CommentSuccessfullyDeleted), ToastLength.Short).Show();
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        });
                    }
                    else
                    {
                        if (p1 == DialogAction.Positive)
                        {
                        }
                        else if (p1 == DialogAction.Negative)
                        {
                            p0.Dismiss();
                        }
                    }
                }
                else if (p1 == DialogAction.Negative)
                {
                    p0.Dismiss();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
예제 #5
0
        //Click Save data
        private async void BtnSaveOnClick(object sender, EventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
                else
                {
                    if (string.IsNullOrEmpty(TitleEditText.Text))
                    {
                        Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_PleaseEnterTitleVideo), ToastLength.Short).Show();
                        return;
                    }

                    if (string.IsNullOrEmpty(DescriptionEditText.Text))
                    {
                        Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_PleaseEnterDescriptionVideo), ToastLength.Short).Show();
                        return;
                    }

                    if (string.IsNullOrEmpty(TagsEditText.Text))
                    {
                        Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_PleaseEnterTags), ToastLength.Short).Show();
                        return;
                    }

                    if (string.IsNullOrEmpty(CategoryEditText.Text))
                    {
                        Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_PleaseChooseCategory), ToastLength.Short).Show();
                        return;
                    }

                    if (string.IsNullOrEmpty(PrivacyEditText.Text))
                    {
                        Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_PleaseChoosePrivacy), ToastLength.Short).Show();
                        return;
                    }

                    if (string.IsNullOrEmpty(AgeRestrictionEditText.Text))
                    {
                        Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_PleaseChooseAgeRestriction), ToastLength.Short).Show();
                        return;
                    }

                    if (string.IsNullOrEmpty(PathImage))
                    {
                        Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_Please_select_Image), ToastLength.Short).Show();
                        return;
                    }

                    //Show a progress
                    AndHUD.Shared.Show(Activity, Activity.GetString(Resource.String.Lbl_Loading));

                    var dictionary = new Dictionary <string, string>
                    {
                        { "title", TitleEditText.Text },
                        { "description", DescriptionEditText.Text },
                        { "tags", TagsEditText.Text },
                        { "category_id", IdCategory },
                        { "privacy", Privacy },
                        { "age_restriction", IdAgeRestriction },
                        //{"sub_category_id", ""},
                    };

                    (int apiStatus, var respond) = await RequestsAsync.Video.EditVideoAsync(VideoClass.Id, dictionary, PathImage); //Sent api

                    if (apiStatus.Equals(200))
                    {
                        if (respond is MessageObject result)
                        {
                            Console.WriteLine(result.Message);

                            var data = TabbedMainActivity.GetInstance()?.MyChannelFragment?.VideosFragment?.MAdapter?.VideoList?.FirstOrDefault(a => a.Id == VideoClass.Id);
                            if (data != null)
                            {
                                data.Title          = TitleEditText.Text;
                                data.Description    = DescriptionEditText.Text;
                                data.Tags           = TagsEditText.Text;
                                data.CategoryName   = CategoryEditText.Text;
                                data.CategoryId     = IdCategory;
                                data.Privacy        = Privacy;
                                data.AgeRestriction = IdAgeRestriction;
                                data.Thumbnail      = PathImage;

                                TabbedMainActivity.GetInstance()?.MyChannelFragment?.VideosFragment?.MAdapter?.NotifyDataSetChanged();
                            }

                            GlobalPlayerActivity.GetInstance()?.SetNewDataVideo(data);
                            TabbedMainActivity.GetInstance()?.VideoDataWithEventsLoader?.SetNewDataVideo(data);

                            Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_YourVideoSuccessfullyEdited), ToastLength.Short).Show();
                            AndHUD.Shared.Dismiss(Activity);

                            GlobalContext.FragmentNavigatorBack();
                        }
                    }
                    else
                    {
                        if (respond is ErrorObject error)
                        {
                            var errorText = error.errors.ErrorText;
                            AndHUD.Shared.ShowError(Activity, errorText, MaskType.Clear, TimeSpan.FromSeconds(2));
                        }
                        else if (respond is MessageObject errorRespond)
                        {
                            AndHUD.Shared.ShowError(Activity, errorRespond.Message, MaskType.Clear, TimeSpan.FromSeconds(2));
                        }
                        Methods.DisplayReportResult(Activity, respond);
                    }

                    AndHUD.Shared.Dismiss(Activity);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                AndHUD.Shared.Dismiss(Activity);
            }
        }
        public async void OnSuccess(Token token)
        {
            try
            {
                // Send token to your own web service
                //var stripeBankAccount = token.BankAccount;
                //var stripeCard = token.Card;
                //var stripeCreated = token.Created;
                //var stripeId = token.Id;
                //var stripeLiveMode = token.Livemode;
                //var stripeType = token.Type;
                //var stripeUsed = token.Used;

                //send api
                //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();
                    }
                }

                AndHUD.Shared.Dismiss(this);

                Finish();

                //ShowFragmentStripe();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                AndHUD.Shared.Dismiss(this);
            }
        }
        //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);
            }
        }
            public override void OnReceive(Context context, Intent intent)
            {
                try
                {
                    if (intent.Action == DownloadManager.ActionDownloadComplete)
                    {
                        if (ActivityContext == null)
                        {
                            return;
                        }

                        DownloadManager       downloadManagerExcuter = (DownloadManager)ActivityContext.GetSystemService(Context.DownloadService);
                        long                  downloadId             = intent.GetLongExtra(DownloadManager.ExtraDownloadId, -1);
                        DownloadManager.Query query = new DownloadManager.Query();
                        query.SetFilterById(downloadId);
                        ICursor c         = downloadManagerExcuter.InvokeQuery(query);
                        var     sqlEntity = new SqLiteDatabase();

                        if (c.MoveToFirst())
                        {
                            int columnIndex = c.GetColumnIndex(DownloadManager.ColumnStatus);
                            if (c.GetInt(columnIndex) == (int)DownloadStatus.Successful)
                            {
                                string downloadedPath = c.GetString(c.GetColumnIndex(DownloadManager.ColumnLocalUri));

                                ActivityManager.RunningAppProcessInfo appProcessInfo = new ActivityManager.RunningAppProcessInfo();
                                ActivityManager.GetMyMemoryState(appProcessInfo);
                                if (appProcessInfo.Importance == Importance.Foreground || appProcessInfo.Importance == Importance.Background)
                                {
                                    sqlEntity.Update_WatchOfflineVideos(Video.VideoId, downloadedPath);
                                    if (TypeActivity == "Main")
                                    {
                                        TabbedMainActivity.GetInstance()?.VideoActionsController.DownloadIcon.SetImageResource(Resource.Drawable.ic_checked_red);
                                        TabbedMainActivity.GetInstance().VideoActionsController.DownloadIcon.Tag = "Downloaded";
                                        TabbedMainActivity.GetInstance()?.LibrarySynchronizer.AddToWatchOffline(Video);
                                    }
                                    else if (TypeActivity == "GlobalPlayer")
                                    {
                                        GlobalPlayerActivity.GetInstance()?.VideoActionsController.DownloadIcon.SetImageResource(Resource.Drawable.ic_checked_red);
                                        GlobalPlayerActivity.GetInstance().VideoActionsController.DownloadIcon.Tag = "Downloaded";
                                        GlobalPlayerActivity.GetInstance()?.LibrarySynchronizer.AddToWatchOffline(Video);
                                    }
                                    else
                                    {
                                        if (ActivityContext is FullScreenVideoActivity fullScreen)
                                        {
                                            fullScreen.VideoActionsController.DownloadIcon.SetImageResource(Resource.Drawable.ic_checked_red);
                                            fullScreen.VideoActionsController.DownloadIcon.Tag = "Downloaded";
                                            //fullScreen tabbedMain.LibrarySynchronizer.OfflineVideoList.Add(Video);
                                        }
                                    }
                                }
                                else
                                {
                                    sqlEntity.Connect();
                                    sqlEntity.Update_WatchOfflineVideos(Video.VideoId, downloadedPath);
                                    sqlEntity.Close();
                                }
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }