Пример #1
0
        private async void _adapter_OnRestart(Edit obj)
        {
            AndHUD.Shared.Show(Activity, Resources.GetString(Resource.String.connecting), -1, MaskType.Black);
            try
            {
                cancel = new CancellationTokenSource();
                await LoginFuncs.TryLogin(Activity, cancel.Token);

                await Bootlegger.BootleggerClient.RestartEdit(obj);

                _adapter.UpdateData(Bootlegger.BootleggerClient.MyEdits, true);
                _adapter.NotifyDataSetChanged();
            }
            catch (TaskCanceledException)
            {
                //do nothing
            }
            catch (Exception e)
            {
                LoginFuncs.ShowError(Context, e);
            }
            finally
            {
                AndHUD.Shared.Dismiss();
            }
        }
Пример #2
0
        private async void Refresh(bool manually)
        {
            cancel = new CancellationTokenSource();

            try
            {
                if (manually)
                {
                    if (!Bootlegger.BootleggerClient.Connected && (Context.ApplicationContext as BootleggerApp).IsReallyConnected)
                    {
                        //AndHUD.Shared.Show(Activity, Resources.GetString(Resource.String.connecting), -1, MaskType.Black);
                        try
                        {
                            await LoginFuncs.TryLogin(Activity, cancel.Token);
                        }
                        catch (TaskCanceledException)
                        {
                            //do nothing
                        }
                        catch (Exception)
                        {
                            //LoginFuncs.ShowError(Context, Resource.String.cantconnect);
                            throw new Exception();
                            //return;
                        }
                    }

                    if ((Context.ApplicationContext as BootleggerApp).IsReallyConnected)
                    {
                        await Bootlegger.BootleggerClient.GetMyEdits(cancel.Token, false);

                        //if we are in the review screen
                        if (Bootlegger.BootleggerClient.CurrentEvent != null)
                        {
                            try
                            {
                                Bootlegger.BootleggerClient.RegisterForEditUpdates();
                            }
                            catch
                            {
                                //not online, so dont register for updates
                            }
                        }
                    }
                }

                _adapter.UpdateData(Bootlegger.BootleggerClient.MyEdits, true);

                theview.FindViewById <View>(Resource.Id.emptytext).Visibility = ViewStates.Gone;
                if (_adapter.ItemCount == 1)
                {
                    theview.FindViewById <View>(Resource.Id.emptytext).Visibility = ViewStates.Visible;
                }

                //if (Bootlegger.BootleggerClient.CurrentEvent != null && _adapter.ItemCount == 0)
                //{
                //    theview.FindViewById<View>(Resource.Id.emptytext).Visibility = ViewStates.Visible;
                //}
            }
            catch (TaskCanceledException)
            {
                //user cancelled
            }
            catch (Exception e)
            {
                if (Activity != null)
                {
                    LoginFuncs.ShowError(Activity, e);
                }
            }
            finally
            {
                theview.Post(() => { theview.FindViewById <ProgressBar>(Resource.Id.progressBar).Visibility = ViewStates.Gone; });
                AndHUD.Shared.Dismiss();
            }
            //}
            //else
            //{
            //    theview.Post(() => { theview.FindViewById<ProgressBar>(Resource.Id.progressBar).Visibility = ViewStates.Gone; });
            //}
        }
Пример #3
0
        private async void Myedits_OnOpenEdit(Edit obj)
        {
            cancel = new CancellationTokenSource();
            AndHUD.Shared.Show(this, Resources.GetString(Resource.String.connecting), -1, MaskType.Black, null, null, true, () => {
                cancel.Cancel();
            });

            if ((Application as BootleggerApp).IsReallyConnected && !CrossConnectivity.Current.ConnectionTypes.Contains(Plugin.Connectivity.Abstractions.ConnectionType.WiFi))
            {
                var diag = new Android.Support.V7.App.AlertDialog.Builder(this)
                           .SetTitle(Resource.String.datausagetitle)
                           .SetMessage(Resource.String.datacharge)
                           .SetPositiveButton(Resource.String.continuebtn, async(o, e) => {
                    try
                    {
                        await LoginFuncs.TryLogin(this, cancel.Token);
                        await Bootlegger.BootleggerClient.Connect(Bootlegger.BootleggerClient.SessionCookie, new System.Threading.CancellationTokenSource().Token);
                        await Bootlegger.BootleggerClient.ConnectForReview(WhiteLabelConfig.REDUCE_BANDWIDTH, new Shoot()
                        {
                            id = obj.media[0].event_id
                        }, cancel.Token);
                        Intent i = new Intent(this, typeof(Editor));
                        i.PutExtra(Review.EDIT, obj.id);
                        StartActivityForResult(i, Review.EDIT_RESPONSE);
                        Bootlegger.BootleggerClient.CanUpload = false;
                    }
                    catch (TaskCanceledException)
                    {
                        //nothing, it was cancelled
                    }
                    catch
                    {
                        LoginFuncs.ShowError(this, new Exception(Resources.GetString(Resource.String.noconnectionshort)));
                    }
                    finally
                    {
                        AndHUD.Shared.Dismiss();
                    }
                })
                           .SetCancelable(false)
                           .SetNegativeButton(Android.Resource.String.Cancel, (o, e) => {
                    AndHUD.Shared.Dismiss();
                })
                           .Show();
            }
            else
            {
                try
                {
                    await LoginFuncs.TryLogin(this, cancel.Token);

                    await Bootlegger.BootleggerClient.Connect(Bootlegger.BootleggerClient.SessionCookie, new System.Threading.CancellationTokenSource().Token);

                    await Bootlegger.BootleggerClient.ConnectForReview(WhiteLabelConfig.REDUCE_BANDWIDTH, new Shoot()
                    {
                        id = obj.media[0].event_id
                    }, cancel.Token);

                    Intent i = new Intent(this, typeof(Editor));
                    i.PutExtra(Review.EDIT, obj.id);
                    StartActivityForResult(i, Review.EDIT_RESPONSE);
                    Bootlegger.BootleggerClient.CanUpload = false;
                }
                catch (TaskCanceledException)
                {
                    //nothing, it was cancelled
                }
                catch (Exception e)
                {
                    LoginFuncs.ShowError(this, e);
                }
                finally
                {
                    AndHUD.Shared.Dismiss();
                }
            }
        }
Пример #4
0
        void CheckUpload()
        {
            try
            {
                if ((Application as BootleggerApp).IsReallyConnected)
                {
                    if (CrossConnectivity.Current.ConnectionTypes.Contains(Plugin.Connectivity.Abstractions.ConnectionType.WiFi))
                    {
                        // Do whatever
                        new Android.Support.V7.App.AlertDialog.Builder(this).SetMessage(Resource.String.deleteclipwarning)
                        .SetNegativeButton(Android.Resource.String.Cancel, new EventHandler <DialogClickEventArgs>((oe, eo) =>
                        {
                            //do nothing...
                        }))
                        .SetPositiveButton(Resource.String.continueanyway, new EventHandler <DialogClickEventArgs>(async(oe, eo) =>
                        {
                            try
                            {
                                await LoginFuncs.TryLogin(this, cancel.Token);
                                //await Bootlegger.BootleggerClient.OfflineConnect(Bootlegger.BootleggerClient.CurrentEvent.id);
                                Bootlegger.BootleggerClient.CanUpload = true;
                                oktocontinueon3g = false;
                                //myclips.Redraw();
                                FindViewById <Button>(Resource.Id.uploadbtn).Text = Resources.GetString(Resource.String.pause);
                                receiver.LostWifi += Receiver_LostWifi;
                                receiver.GotWifi  += Receiver_GotWifi;
                            }
                            catch (Exception e)
                            {
                                LoginFuncs.ShowError(this, e);
                            }
                        }))
                        .SetTitle(Resource.String.continuetitle)
                        .SetCancelable(false)
                        .Show();
                    }
                    else
                    {
                        new Android.Support.V7.App.AlertDialog.Builder(this).SetMessage(Resource.String.datachargewithwarning)
                        .SetNegativeButton(Resource.String.notnow, new EventHandler <DialogClickEventArgs>((oe, eo) =>
                        {
                            //do nothing...
                        }))
                        .SetPositiveButton(Resource.String.continueanyway, new EventHandler <DialogClickEventArgs>(async(oe, eo) =>
                        {
                            try
                            {
                                oktocontinueon3g = true;
                                //await connection:
                                await LoginFuncs.TryLogin(this, cancel.Token);
                                //await Bootlegger.BootleggerClient.OfflineConnect(Bootlegger.BootleggerClient.CurrentEvent.id);

                                Bootlegger.BootleggerClient.CanUpload = true;
                                //myclips.Redraw();
                                FindViewById <Button>(Resource.Id.uploadbtn).Text = Resources.GetString(Resource.String.pause);
                                receiver.LostWifi += Receiver_LostWifi;
                                receiver.GotWifi  += Receiver_GotWifi;
                            }
                            catch (Exception e)
                            {
                                LoginFuncs.ShowError(this, e);
                            }
                        }))
                        .SetTitle(Resource.String.continuetitle)
                        .SetCancelable(false)
                        .Show();
                    }
                }
                else
                {
                    LoginFuncs.ShowError(this, new NoNetworkException());
                }
            }
            catch (Exception e)
            {
                LoginFuncs.ShowError(this, e);
            }
        }