Пример #1
0
 public PIPBroadcastReceiver(MainActivity self)
 {
     this.self = self;
 }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            LogFile($"============================== ON CREATE AT {UnixTime} ==============================");
            print("ON CREATED:::::!!!!!!!!!");
            CreateMediaSession();

            try {
                SetTheme(Resource.Style.MainTheme_NonSplash);
                LogFile("SetTheme Done");

                PublicNot = Resource.Drawable.bicon512;

                TabLayoutResource = Resource.Layout.Tabbar;
                ToolbarResource   = Resource.Layout.Toolbar;

                LogFile("Setup Done 1/2");
                base.OnCreate(savedInstanceState);
                LogFile("Setup Done 2/2");
#if DEBUG
                System.AppDomain.CurrentDomain.UnhandledException += MainPage.UnhandledExceptionTrapper;
#endif
                string data = Intent?.Data?.EncodedAuthority;

                try {
                    MainPage.intentData = data;
                }
                catch (Exception) { }

                // ======================================= INIT =======================================

                LogFile("Starting Init");

                FFImageLoading.Forms.Platform.CachedImageRenderer.Init(enableFastRenderer: true);
                Rg.Plugins.Popup.Popup.Init(this);
                LibVLCSharpFormsRenderer.Init();
                XamEffects.Droid.Effects.Init();

                Xamarin.Essentials.Platform.Init(this, savedInstanceState);
                global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

                LogFile("Completed Init");

                //LocalNotificationsImplementation.NotificationIconId = PublicNot;
                MainDroid.NotificationIconId = PublicNot;

                LogFile("Start Application");
                LoadApplication(new App());
                LogFile("Completed Startup");

                App.OnVideoStatusChanged += (o, e) => {
                    UpdatePipVideostatus();
                };
                LogFile("Completed PIP");
            }
            catch (Exception _ex) {
                LogFile("ERROR LOADING APP: " + _ex);
                error(_ex);
            }

            if (Settings.IS_TEST_BUILD)
            {
                return;
            }
            try {
                LogFile("Creating activity");

                activity = this;

                mainDroid = new MainDroid();
                LogFile("Creating Maindroid");

                mainDroid.Awake();
                LogFile("Completed Awake");

                //Typeface.CreateFromAsset(Application.Context.Assets, "Times-New-Roman.ttf");

                var datastring = Intent.DataString;
                var clip       = Intent.ClipData;

                if (datastring != null)
                {
                    print("GOT NON NULL DATA");
                    if (datastring != "")
                    {
                        print("INTENTDATA::::" + datastring);
                        if (datastring.Contains("www.imdb.com"))
                        {
                            string id = FindHTML(datastring + "/", "title/", "/");
                            //  var _thread = mainCore.CreateThread(2);
                            mainCore.StartThread("IMDb Thread", () => {
                                string json = mainCore.DownloadString($"https://v2.sg.media-imdb.com/suggestion/t/{id}.json");
                                //  await Task.Delay(1000);
                                Device.BeginInvokeOnMainThread(() => {
                                    if (json != "")
                                    {
                                        MainPage.PushPageFromUrlAndName(id, FindHTML(json, "\"l\":\"", "\""));;
                                    }
                                    else
                                    {
                                        App.ShowToast("Error loading imdb");
                                    }
                                });
                            });
                        }
                        else if (IsFromYoutube(datastring))
                        {
                            HandleYoutubeUrl(datastring);
                        }
                        else
                        {
                            MainPage.PushPageFromUrlAndName(datastring);
                        }
                    }
                }

                LogFile("Calling RequestPermission");

                RequestPermission(this);
                LogFile("Permissions Loaded");
                //GetLatency(); // https://developer.amazon.com/docs/fire-tv/audio-video-synchronization.html#section1-2

                MainChrome.OnDisconnected += (o, e) => {
                    MainDroid.CancelChromecast();
                };

                MainChrome.OnNotificationChanged += (o, e) => {
                    try {
                        print("CHROMECAST CHANGED::: ");
                        print("ID=====================" + e.isCasting + "|" + e.isPlaying + "|" + e.isPaused);
                        if (!e.isCasting)                          // || !e.isPlaying) {
                        {
                            MainDroid.CancelChromecast();
                        }
                        else
                        {
                            MainDroid.UpdateChromecastNotification(e.title, e.body, e.isPaused, e.posterUrl, e.time, e.duration);
                        }
                    }
                    catch (Exception _ex) {
                        print("EX NOT CHANGED::: " + _ex);
                    }
                };
                LogFile("OnLoad Completed");


                //ResumeIntentData();
                LogFile("Resume intents completed");

                StartService(new Intent(BaseContext, typeof(OnKilledService)));
                LogFile("OnKilled completed");

                Window.SetSoftInputMode(Android.Views.SoftInput.AdjustNothing);
                LogFile("OnSetsoft completed");
            }
            catch (Exception _ex) {
                LogFile("FATAL ERROR : " + _ex);
                error(_ex);
            }
            LogFile($"============================== STARTUP DONE AT {UnixTime} ==============================");
            // TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
            //  Android.Renderscripts.ta
            // var bar = new Xamarin.Forms.Platform.Android.TabbedRenderer();//.Platform.Android.

            //ShowBlackToast("Yeet", 3);
            // DownloadHandle.ResumeIntents();
            //   ShowLocalNot(new LocalNot() { mediaStyle = false, title = "yeet", data = "", progress = -1, showWhen = false, autoCancel = true, onGoing = false, id = 1234, smallIcon = Resource.Drawable.bicon, body = "Download ddddd" }, Application.Context);

            // ShowLocalNot(new LocalNot() { mediaStyle = false, title = "yeet", autoCancel = true, onGoing = false, id = 123545, smallIcon = Resource.Drawable.bicon, body = "Download Failed!",showWhen=false }); // ((e.Cancelled || e.Error != null) ? "Download Failed!"
        }