Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            documentInfo = InstantDocumentInfo.FromJson(Intent.GetStringExtra(DocumentDescriptor));
            if (documentInfo is null)
            {
                throw new InvalidOperationException("InstantExampleActivity was not initialized with proper arguments: Missing document descriptor extra!");
            }
            var a = Theme.ObtainStyledAttributes(null, Resource.Styleable.pspdf__ActionBarIcons, Resource.Attribute.pspdf__actionBarIconsStyle, Resource.Style.PSPDFKit_ActionBarIcons);

            mainToolbarIconsColor = a.GetColor(Resource.Styleable.pspdf__ActionBarIcons_pspdf__iconsColor, ContextCompat.GetColor(this, Resource.Color.pspdf__color_white));
            a.Recycle();

            InitCollaborateMenu();
        }
Example #2
0
        public async Task <InstantDocumentInfo> ResolveDocument(string code)
        {
            try {
                var response = await httpClient.GetAsync($"{instantCodeEndpointUrl}/instant/{WebUtility.UrlEncode (code)}");

                response.EnsureSuccessStatusCode();

                // Do not allocate a string for the json reponse, read directly from the stream
                using (var stream = await response.Content.ReadAsStreamAsync())
                    using (var reader = new StreamReader(stream))
                        using (var json = new JsonTextReader(reader)) {
                            return(InstantDocumentInfo.FromJson(json));
                        }
            } catch (HttpRequestException ex) {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
Example #3
0
        public async Task <InstantDocumentInfo> CreateNewDocument()
        {
            try {
                var response = await httpClient.PostAsync($"{instantCodeEndpointUrl}/instant-landing-page", null);

                response.EnsureSuccessStatusCode();

                // Do not allocate a string for the json reponse, read directly from the stream
                using (var stream = await response.Content.ReadAsStreamAsync())
                    using (var reader = new StreamReader(stream))
                        using (var json = new JsonTextReader(reader)) {
                            return(InstantDocumentInfo.FromJson(json));
                        }
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
Example #4
0
        public async Task <InstantDocumentInfo> ResolveDocument(Uri uri)
        {
            try {
                var msg = new HttpRequestMessage();
                msg.Headers.Add("Accept", "application/vnd.instant-example+json");
                msg.RequestUri = uri;

                var response = await httpClient.SendAsync(msg);

                response.EnsureSuccessStatusCode();

                // Do not allocate a string for the json reponse, read directly from the stream
                using (var stream = await response.Content.ReadAsStreamAsync())
                    using (var reader = new StreamReader(stream))
                        using (var json = new JsonTextReader(reader)) {
                            return(InstantDocumentInfo.FromJson(json));
                        }
            } catch (HttpRequestException ex) {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }