Exemplo n.º 1
0
 public override void OnBackPressed()
 {
     base.OnBackPressed();
     StartActivity(new Intent(this, typeof(MainActivity)));
     NotificationHandler.CancelNotification(this);
 }
Exemplo n.º 2
0
        protected override void OnStart()
        {
            base.OnStart();
            NotificationHandler.CancelNotification(this);
            YouTubeHook.VerboseCallback = (o) => Console.WriteLine(o);
            Settings.LoadInfos();

            var code = string.Empty;

            try
            {
                var urlparams = Uptred.Core.QueryParametersFromUrl(Intent.Data.ToString());
                code = urlparams["code"];
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Settings.YouTubeHook = null;
            }
            if (code != string.Empty)
            {
                try
                {
                    Settings.YouTubeHook = YouTubeHook.Authorize(
                        authCode: code,
                        clientId: ApiKeys.YouTubeClientId,
                        secret: ApiKeys.YouTubeClientSecret,
                        redirect: ApiKeys.YouTubeRedirectURL);
                    Console.WriteLine("Logged in as " + Settings.YouTubeHook.DisplayName);
                    Settings.YouTubeRefreshToken = Settings.YouTubeHook.RefreshToken;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Settings.YouTubeHook = null;
                }
            }
            else
            {
                try
                {
                    Settings.YouTubeHook = YouTubeHook.ReAuthorize(
                        refreshToken: Settings.YouTubeRefreshToken,
                        clientId: ApiKeys.YouTubeClientId,
                        secret: ApiKeys.YouTubeClientSecret,
                        redirect: ApiKeys.YouTubeRedirectURL);
                    Console.WriteLine("Logged in as " + Settings.YouTubeHook.DisplayName);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Settings.YouTubeHook = null;
                }
            }

            if (Settings.YouTubeHook == null)
            {
                StartActivity(new Intent(Intent.ActionView, Uri.Parse(
                                             YouTubeHook.GetLoginURL(clientId: ApiKeys.YouTubeClientId, redirect: ApiKeys.YouTubeRedirectURL))));
            }
            else
            {
                FindViewById <TextView>(Resource.Id.lblVerifier).Text = Settings.YouTubeHook.DisplayName;
            }
        }
Exemplo n.º 3
0
 protected override void OnStart()
 {
     base.OnStart();
     NotificationHandler.CancelNotification(this);
 }