예제 #1
0
        protected override bool DrawChild(Canvas canvas, View child, long drawingTime)
        {
            bool ret = base.DrawChild(canvas, child, drawingTime);

            canvas.Save();
            Paint paint = new Paint();

            paint.Color     = Color.Red;
            paint.TextSize  = (24.0f);
            paint.AntiAlias = (true);
            if (X5WebViewExtension != null)
            {
                canvas.DrawText(this.Context.PackageName + "-pid:"
                                + Android.OS.Process.MyPid(), 10, 50, paint);
                canvas.DrawText(
                    "X5  Core:" + QbSdk.GetTbsVersion(this.Context), 10,
                    100, paint);
            }
            else
            {
                canvas.DrawText(this.Context.PackageName + "-pid:"
                                + Android.OS.Process.MyPid(), 10, 50, paint);
                canvas.DrawText("Sys Core", 10, 100, paint);
            }
            canvas.DrawText(Build.Manufacturer, 10, 150, paint);
            canvas.DrawText(Build.Model, 10, 200, paint);
            canvas.Restore();
            return(ret);
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

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

            // 在调用TBS初始化、创建WebView之前进行如下配置
            var dic = new System.Collections.Generic.Dictionary <string, Java.Lang.Object>
            {
                { TbsCoreSettings.TbsSettingsUseSpeedyClassloader, true },
                { TbsCoreSettings.TbsSettingsUseDexloaderService, true },
            };

            QbSdk.InitTbsSettings(dic);

            preInitCallback = new PreInitCallback();
            tbsListener     = new TbsListener();
            MessagingCenter.Subscribe <object>(this, WebPage.InitX5, o =>
            {
                //QbSdk.DownloadWithoutWifi = true;
                QbSdk.SetTbsListener(tbsListener);
                QbSdk.InitX5Environment(this, preInitCallback);
            });
            MessagingCenter.Subscribe <object>(this, WebPage.PlayVideo, o =>
            {
                TbsVideo.OpenVideo(this, "http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4");
            });
            MessagingCenter.Subscribe <object>(this, WebPage.OpenFile, async o =>
            {
                var backingFile = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "excel.xlsx");
                if (System.IO.File.Exists(backingFile) == false)
                {
                    using (var stream = Assets.Open("excel.xlsx"))
                    {
                        using (var newStream = System.IO.File.Create(backingFile))
                        {
                            await stream.CopyToAsync(newStream);
                        }
                    }
                }
                var dic = new System.Collections.Generic.Dictionary <string, string>
                {
                    { "local", "true" }
                };
                var openResult = QbSdk.OpenFileReader(this, backingFile, dic, new ValueCallback());
            });
        }
예제 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.LoadMainVw);

            QbSdk.InitX5Environment(this.ApplicationContext, this);
            QbSdk.SetTbsListener(this);

            var intent = new Intent(this, typeof(MainActivity));

            StartActivity(intent);
            AnalyticAgreement.PageParam  = new Dictionary <string, PageParam>();
            X5WebViewHelper.PageActivity = new Dictionary <string, Activity>();


            //异步初始化操作
            var th = new Thread((() => { HybridCommonMain.Init(new AgreementProvider()); }));

            th.Start();
        }
예제 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());
            preInitCallback = new PreInitCallback();
            tbsListener     = new TbsListener();
            MessagingCenter.Subscribe <object>(this, WebPage.InitX5, o =>
            {
                //QbSdk.DownloadWithoutWifi = true;
                QbSdk.SetTbsListener(tbsListener);
                QbSdk.InitX5Environment(this, preInitCallback);
            });
            MessagingCenter.Subscribe <object>(this, WebPage.PlayVideo, o =>
            {
                TbsVideo.OpenVideo(this, "http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4");
            });
            MessagingCenter.Subscribe <object>(this, WebPage.OpenFile, async o =>
            {
                var backingFile = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "excel.xlsx");
                if (System.IO.File.Exists(backingFile) == false)
                {
                    using (var stream = Assets.Open("excel.xlsx"))
                    {
                        using (var newStream = System.IO.File.Create(backingFile))
                        {
                            await stream.CopyToAsync(newStream);
                        }
                    }
                }
                var openResult = QbSdk.OpenFileReader(this, backingFile, null, new ValueCallback());
            });
        }