Ejemplo n.º 1
0
        public static async Task<RootObject> Get()
        {
            var serializer = new SimplyMobile.Text.ServiceStack.JsonSerializer ();

            var webClient = new JsonClient (serializer);

            var response = await webClient.GetAsync<RootObject>("http://www.reddit.com/r/all.json", Format.Json);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return response.Value;
            } 
            else
            {
                System.Diagnostics.Debug.WriteLine (response.Content);
            }

            var serializer2 = new SimplyMobile.Text.JsonNet.JsonSerializer ();

            webClient = new JsonClient(serializer2);

            response = await webClient.GetAsync<RootObject>("http://www.reddit.com/r/all.json", Format.Json);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return response.Value;
            } 
            else
            {
                System.Diagnostics.Debug.WriteLine (response.Content);
            }
            return null;
        }
Ejemplo n.º 2
0
        public static async Task <RootObject> Get()
        {
            var serializer = new SimplyMobile.Text.ServiceStack.JsonSerializer();

            var webClient = new JsonClient(serializer);

            var response = await webClient.GetAsync <RootObject>("http://www.reddit.com/r/all.json", Format.Json);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(response.Value);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(response.Content);
            }

            var serializer2 = new SimplyMobile.Text.JsonNet.JsonSerializer();

            webClient = new JsonClient(serializer2);

            response = await webClient.GetAsync <RootObject>("http://www.reddit.com/r/all.json", Format.Json);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(response.Value);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(response.Content);
            }
            return(null);
        }
Ejemplo n.º 3
0
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            button = FindViewById<Button> (Resource.Id.myButton);

            var serializer = new SimplyMobile.Text.ServiceStack.JsonSerializer();



            var webView = FindViewById<WebView> (Resource.Id.webView1);

            this.webHybrid = new WebHybrid (webView, serializer);

            this.webHybrid.RegisterCallback ("dataCallback", Console.WriteLine);

            webView.LoadUrl("file:///android_asset/Content/home.html");

            button.Click += delegate
            {
                var data = new Data()
                {
                    Name = "Sami",
                    Count = 99
                };

                this.webHybrid.InjectJavaScript(string.Format("Native(\"test\", {0})", serializer.Serialize(data)));

                this.webHybrid.CallJsFunction("Native", "test", data);

                this.webHybrid.CallJsFunction("alert", "test");
            };
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            button = FindViewById <Button> (Resource.Id.myButton);

            var serializer = new SimplyMobile.Text.ServiceStack.JsonSerializer();



            var webView = FindViewById <WebView> (Resource.Id.webView1);

            this.webHybrid = new WebHybrid(webView, serializer);

            this.webHybrid.RegisterCallback("dataCallback", Console.WriteLine);

            webView.LoadUrl("file:///android_asset/Content/home.html");

            button.Click += delegate
            {
                var data = new Data()
                {
                    Name  = "Sami",
                    Count = 99
                };

                this.webHybrid.InjectJavaScript(string.Format("Native(\"test\", {0})", serializer.Serialize(data)));

                this.webHybrid.CallJsFunction("Native", "test", data);

                this.webHybrid.CallJsFunction("alert", "test");
            };
        }