Ejemplo n.º 1
0
        public void AsyncRequestData(CDVDataTarget requestor, CDVDocumentCell data)
        {
            //FetchCalendarDataSync(requestor, data);

            AsyncTask1 at = new AsyncTask1(FetchCalendarDataSync);

            at.BeginInvoke(requestor, data, null, null);
        }
        public static bool IsValid(string webDomain, string packageName, string fingerprint)
        {
            string canonicalDomain = GetCanonicalDomain(webDomain);

            if (CommonUtil.DEBUG)
            {
                Log.Debug(CommonUtil.TAG, "validating domain " + canonicalDomain + " (" + webDomain
                          + ") for pkg " + packageName + " and fingerprint " + fingerprint);
            }
            string fullDomain;

            if (!webDomain.StartsWith("http:") && !webDomain.StartsWith("https:"))
            {
                // Unfortunately AssistStructure.ViewNode does not tell what the domain is, so let's
                // assume it's https
                fullDomain = "https://" + canonicalDomain;
            }
            else
            {
                fullDomain = canonicalDomain;
            }

            // TODO: use the DAL Java API or a better REST alternative like Volley
            // and/or document it should not block until it returns (for example, the server could
            // start parsing the structure while it waits for the result.
            var task = new AsyncTask1()
            {
                fullDomain  = fullDomain,
                packageName = packageName,
                fingerprint = fingerprint
            };

            try
            {
                return((bool)task.Execute((string[])null).Get());
            }
            catch (InterruptedException ex)
            {
                Thread.CurrentThread().Interrupt();
                Log.Warn(CommonUtil.TAG, "Thread interrupted");
            }
            catch (Exception e)
            {
                Log.Warn(CommonUtil.TAG, "Async task failed", e);
            }

            return(false);
        }