Example #1
0
        public void OnBookingComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;

                bookings.Clear();
                foreach (var doc in documents.Documents)
                {
                    Booking booking = new Booking
                    {
                        Name       = doc.Get("name").ToString(),
                        TotalDays  = (int)doc.Get("totalDays"),
                        ExtraBed   = (bool)doc.Get("extraBed"),
                        RoomNumber = (int)doc.Get("roomNumber"),
                        TotalPrice = (float)doc.Get("totalPrice"),
                        Id         = doc.Id,
                        BookDate   = NativeDateToDateTime(doc.Get("bookDate") as Date)
                    };
                    bookings.Add(booking);
                }
            }
            else
            {
                bookings.Clear();
            }
            hasReadBookings = true;
        }
Example #2
0
        public void OnComplete(Android.Gms.Tasks.Task task)  //qui otteniani il risultato della query
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;
                appelliList.Clear();
                foreach (var doc in documents.Documents)
                {
                    string date;
                    if (doc.Get("date") == null)
                    {
                        date = "";
                    }
                    else
                    {
                        date = doc.Get("date").ToString();
                    }
                    Appello appello = new Appello
                    {
                        Name = doc.Get("name").ToString(),
                        Date = date,
                        Id   = doc.Id
                    };

                    appelliList.Add(appello);
                }
            }
            else
            {
                appelliList.Clear();
            }
            hasReadAppelli = true;
        }
Example #3
0
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;

                inboxItems.Clear();
                foreach (var doc in documents.Documents)
                {
                    InboxItem inboxItem = new InboxItem
                    {
                        IsActive  = (bool)doc.Get("isActive"),
                        Name      = doc.Get("name").ToString(),
                        Notes     = doc.Get("notes").ToString(),
                        UserId    = doc.Get("author").ToString(),
                        StartDate = NativeDateToDateTime(doc.Get("startDate") as Date),
                        Id        = doc.Id
                    };

                    inboxItems.Add(inboxItem);
                }
            }
            else
            {
                inboxItems.Clear();
            }
            hasReadInboxItems = true;
        }
Example #4
0
 public void OnComplete(Android.Gms.Tasks.Task task)
 {
     if (task.IsSuccessful)
     {
         userList.Clear();
         var documents = (QuerySnapshot)task.Result;
         foreach (var doc in documents.Documents)
         {
             if (!doc.Id.Equals(Application.Current.Properties["MyUID"]) && !doc.Get("admin").Equals("Admin"))
             {
                 string name     = doc.Get("name").ToString();
                 string surname  = doc.Get("surname").ToString();
                 string uri      = doc.Get("uri").ToString();
                 string username = doc.Get("username").ToString();
                 string email    = doc.Get("email").ToString();
                 User   user     = new User(name, surname, uri, username, email);
                 user.Id = doc.Id.ToString();
                 userList.Add(user);
             }
         }
         value = 1;
     }
     else
     {
         value = 2;
     }
 }
Example #5
0
        /*public static DateTime NativeToDatetime(Date date)
         * {
         *  DateTime reference = System.TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0));
         *  return reference.AddMilliseconds(date.Time);
         * }*/

        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var document = (QuerySnapshot)task.Result;

                subsriptions.Clear();
                foreach (var doc in document.Documents)
                {
                    var subscription = new Subscription
                    {
                        IsActive  = (bool)doc.Get("Visited"),
                        Name      = doc.Get("Title").ToString(),
                        UserId    = doc.Get("author").ToString(),
                        VenueName = doc.Get("Place").ToString(),
                        //Address = doc.Get("Address").ToString(),
                        Distance     = (int)doc.Get("Distance from current location (meters)"),
                        CategoryId   = doc.Get("Category Id").ToString(),
                        CategoryName = doc.Get("Category Name").ToString(),
                        Lat          = (double)doc.Get("Latitude"),
                        Lng          = (double)doc.Get("Longitude"),
                        //SubscribedDate = NativeToDatetime(doc.Get("subscribeddate") as Date)
                        Id = doc.Id
                    };
                    subsriptions.Add(subscription);
                }
                hasreadvalue = true;
            }
            else
            {
                App.Current.MainPage.DisplayAlert("Error", "Something went wrong, please try again", "Okay");
            }
        }
Example #6
0
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var docs = (QuerySnapshot)task.Result;
                //List<Subscription> subscriptions = new List<Subscription>();
                subscriptions.Clear();
                foreach (var doc in docs.Documents)
                {
                    Subscription sb = new Subscription {
                        Id             = doc.Id,
                        IsActive       = (bool)doc.Get("isActive"),
                        Name           = doc.Get("name").ToString(),
                        UserId         = doc.Get("author").ToString(),
                        SubscribedDate = DateToNatDateTime(doc.Get("subscribedDate") as Date),
                    };

                    subscriptions.Add(sb);
                }
            }
            else
            {
                subscriptions.Clear();
            }

            hasReadSubs = true;
        }
Example #7
0
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;

                posts.Clear();
                foreach (var doc in documents.Documents)
                {
                    Post newPost = new Post()
                    {
                        Experience   = doc.Get("experience").ToString(),
                        VenueName    = doc.Get("venuename").ToString(),
                        CategoryId   = doc.Get("categoryId").ToString(),
                        CategoryName = doc.Get("categoryName").ToString(),
                        Address      = doc.Get("address").ToString(),
                        Latitude     = (double)doc.Get("latitude"),
                        Longitude    = (double)doc.Get("longitude"),
                        Distance     = (int)doc.Get("distance"),
                        UserId       = doc.Get("userId").ToString(),
                        Id           = doc.Id
                    };

                    posts.Add(newPost);
                }
            }
            else
            {
                posts.Clear();
            }

            hasReadPosts = true;
        }
Example #8
0
 public void OnComplete(Android.Gms.Tasks.Task task)
 {
     if (task.IsComplete)
     {
         storageReference.GetDownloadUrl().AddOnCompleteListener(downloadListener);
     }
 }
 public void OnComplete(Task task)
 {
     try
     {
         RunOnUiThread(() =>
         {
             bool result = task.IsSuccessful;
             if (result)
             {
                 //Toast.MakeText(this, "Ready", ToastLength.Long).Show();
                 BtnApply.Enabled = true;
             }
             else
             {
                 Toast.MakeText(this, GetText(Resource.String.Lbl_ErrorConnectionSystemStripe), ToastLength.Long)
                 .Show();
                 //hide Google as payment option
                 BtnApply.Enabled = false;
             }
         });
     }
     catch (ApiException exception)
     {
         Toast.MakeText(this, "Exception" + exception.Message, ToastLength.Long).Show();
     }
 }
Example #10
0
 public void OnComplete(Android.Gms.Tasks.Task task)
 {
     if (task.IsSuccessful)
     {
         var documents = (QuerySnapshot)task.Result;
         foreach (var doc in documents.Documents)
         {
             DaysInWeek d = new DaysInWeek();
             d.n    = doc.Id;
             d.week = currentWeek;
             if (doc.Get("ifSet" + currentType) != null && doc.Get("ifSet" + currentType).Equals("True"))
             {
                 d.ifSet = true;
             }
             else
             {
                 d.ifSet = false;
             }
             whichDayAdd(d, GetWhichWeek(currentWeek));
         }
         value = 1;
     }
     else
     {
         value = 2;
     }
 }
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;


                foreach (var doc in documents.Documents)
                {
                    Locations loc = new Locations();
                    loc.Centers = new List <string>();

                    loc.Location = (string)doc.Get("Location");
                    var centersDoc  = doc.Get("Centers");
                    var centersList = new Android.Runtime.JavaList((System.Collections.IEnumerable)centersDoc);

                    var list = centersList.ToArray();

                    for (int i = 0; i < list.Length; i++)
                    {
                        var o = (Java.Lang.Object)list[i].ToString();

                        loc.Centers.Add((string)o);
                    }

                    AllLocations.Add(loc);
                }
                HasLocations = true;
            }
            else
            {
                AllLocations.Clear();
            }
        }
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var docObj = task.Result;
                if (docObj is DocumentSnapshot doc)
                {
                    _tcs.TrySetResult(doc.Convert <T>());
                    return;

                    /*
                     * var item = new Item
                     * {
                     *  Id = doc.Id,
                     *  Name = doc.GetString(DatabaseKey.FirebaseFirestore.WatchField.Name),
                     *  Style = doc.GetString(DatabaseKey.FirebaseFirestore.WatchField.Style),
                     *  CaseColor = doc.GetString(DatabaseKey.FirebaseFirestore.WatchField.CaseColor),
                     *  CaseMaterial = doc.GetString(DatabaseKey.FirebaseFirestore.WatchField.CaseMaterial),
                     *  Description = doc.GetString(DatabaseKey.FirebaseFirestore.WatchField.Description),
                     *  AvatarUrl = doc.GetString(DatabaseKey.FirebaseFirestore.WatchField.AvatarUrl),
                     *  Latitude = (double)doc.GetDouble(DatabaseKey.FirebaseFirestore.WatchField.Latitude),
                     *  Longitude = (double)doc.GetDouble(DatabaseKey.FirebaseFirestore.WatchField.Longitude),
                     *  Text = "Some random text"
                     * };
                     * _tcs.TrySetResult(item);
                     * return;
                     */
                }
            }
            else
            {
                _tcs.TrySetResult(default(T));
            }
        }
Example #13
0
 //method will be executed after completing the document retrieving. Like an event.
 public void OnComplete(Android.Gms.Tasks.Task task)
 {
     if (task.IsSuccessful)
     {
         var document = (QuerySnapshot)task.Result;
         subscriptions.Clear();
         foreach (var doc in document.Documents)
         {
             Subscription subscription = new Subscription
             {
                 IsActive         = (bool)doc.Get("isActive"),
                 Name             = doc.Get("name").ToString(),
                 UserId           = doc.Get("auther").ToString(),
                 SubscriptionDate = nativeDateToDateTime(doc.Get("subscriptionDate") as Date),
                 Id = doc.Id
             };
             subscriptions.Add(subscription);
         }
     }
     else
     {
         subscriptions.Clear();
     }
     //Make this true to know that OnComplete methid has completed reading the subscriptions.
     hasSubscriptionsRead = true;
 }
Example #14
0
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;

                profiles.Clear();
                foreach (var doc in documents.Documents)
                {
                    Profile profile = new Profile
                    {
                        IsActive       = (bool)doc.Get("isActive"),
                        Name           = doc.Get("name").ToString(),
                        UserId         = doc.Get("author").ToString(),
                        SubscribedDate = NativeDateToDateTime(doc.Get("subscribedDate") as Date),
                        Id             = doc.Id
                    };

                    profiles.Add(profile);
                }
            }
            else
            {
                profiles.Clear();
            }
            hasReadProfiles = true;
        }
Example #15
0
 public void OnComplete(Android.Gms.Tasks.Task task)
 {
     if (task.IsSuccessful)
     {
         SavePlayer(golgioc, teams, segno);
     }
 }
Example #16
0
        // Method used to notify the app that the response from the server was received and how to handle the response
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;
                MyStocks.Clear();
                foreach (var doc in documents.Documents)
                {
                    MyStock stock = new MyStock()
                    {
                        MyStockId = doc.Id,
                        ShortName = (string)doc.Get("shortname"),
                        LongName  = (string)doc.Get("longname"),
                        BuyPrice  = (double)doc.Get("buyprice"),
                        Quantity  = (int)doc.Get("quantity"),
                        RonRate   = (double)doc.Get("ronrate"),
                        ImageUri  = ImageSource.FromUri(new Uri((string)doc.Get("imageuri")))
                    };

                    // Convert the BuyPrice to the rate at which the stock was bought
                    if (CrossMultilingual.Current.CurrentCultureInfo.TwoLetterISOLanguageName.Equals("ro"))
                    {
                        stock.BuyPrice = stock.BuyPrice * stock.RonRate;
                    }
                    MyStocks.Add(stock);
                }
            }
            else
            {
                MyStocks.Clear();
            }
            hasReadStocks = true;
        }
Example #17
0
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;

                subscriptions.Clear();
                foreach (var doc in documents.Documents)
                {
                    Subscription subscription = new Subscription
                    {
                        IsActive       = (bool)doc.Get("IsActive"),
                        Name           = doc.Get("name").ToString(),
                        UserId         = doc.Get("author").ToString(),
                        SubscribedDate = NativeDateToDateTime(doc.Get("subscribedDate") as Date)
                    };

                    subscriptions.Add(subscription);
                }
            }
            else
            {
                subscriptions.Clear();
            }
            hasReadSubscriptions = true;
        }
Example #18
0
        /*
         * Method used to notify the app that the response from the server was received and how to handle the response
         * @mystock
         *  The stock to be deleted
         */
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;
                Stocks.Clear();
                foreach (var doc in documents.Documents)
                {
                    Stock stock = new Stock()
                    {
                        ShortName          = (string)doc.Get("shortname"),
                        LongName           = (string)doc.Get("longname"),
                        NowPrice           = (double)doc.Get("nowprice"),
                        OldPrice           = (double)doc.Get("oldprice"),
                        ImageUri           = ImageSource.FromUri(new Uri((string)doc.Get("imageuri"))),
                        CompanyDescription = (string)doc.Get("companydescription")
                    };

                    // Change the price based on the current rate
                    if (CrossMultilingual.Current.CurrentCultureInfo.TwoLetterISOLanguageName.Equals("ro"))
                    {
                        stock.NowPrice = stock.NowPrice * (double)App.Current.Properties["rate"];
                        stock.OldPrice = stock.OldPrice * (double)App.Current.Properties["rate"];
                    }
                    stock.Statistic = Math.Round(stock.NowPrice - stock.OldPrice, 2);
                    Stocks.Add(stock);
                }
            }
            else
            {
                Stocks.Clear();
            }
            hasReadStocks = true;
        }
Example #19
0
        public void OnComplete(Android.Gms.Tasks.Task task)  //qui otteniani il risultato della query
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;
                appuntiList.Clear();
                foreach (var doc in documents.Documents)
                {
                    string description;
                    if (doc.Get("description") == null)
                    {
                        description = "";
                    }
                    else
                    {
                        description = doc.Get("description").ToString();
                    }
                    Appunto appunto = new Appunto
                    {
                        Name        = doc.Get("name").ToString(),
                        Description = description,
                        IdCorso     = doc.Get("idCorso").ToString(),
                        Id          = doc.Id
                    };

                    appuntiList.Add(appunto);
                }
            }
            else
            {
                appuntiList.Clear();
            }
            hasReadAppunti = true;
        }
Example #20
0
 public void OnComplete(Android.Gms.Tasks.Task task)
 {
     if (task.IsSuccessful)
     {
         cardList.Clear();
         var documents = (QuerySnapshot)task.Result;
         foreach (var doc in documents.Documents)
         {
             if (doc.Get("type").Equals(currentType))
             {
                 Card card = new Card();
                 card.Name = doc.Get("name").ToString();
                 card.Type = doc.Get("type").ToString();
                 card.Path = doc.Id.ToString();
                 card.Ref  = UserId;
                 cardList.Add(card);
             }
         }
         value = 1;
     }
     else
     {
         value = 2;
     }
 }
 void IOnCompleteListener.OnComplete(GmsTask task)
 {
     if (imageProxy != null)
     {
         imageProxy.Close();
         imageProxy = null;
     }
 }
Example #22
0
 public void OnComplete(Android.Gms.Tasks.Task task)
 {
     try
     {
         string token = task.Result.JavaCast <IInstanceIdResult>().Token;
         _tokenTcs?.TrySetResult(token);
     }
     catch { }
 }
        public static Task <Java.Lang.Object> ToAwaitableTask(this Android.Gms.Tasks.Task task)
        {
            var taskCompletionSource = new TaskCompletionSource <Java.Lang.Object>();
            var taskCompleteListener = new TaskCompleteListener(taskCompletionSource);

            task.AddOnCompleteListener(taskCompleteListener);

            return(taskCompletionSource.Task);
        }
Example #24
0
        public async void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var imageUrl = await _storageReference.GetDownloadUrlAsync();

                string imageUrlString = imageUrl.ToString();
                _tcs.TrySetResult(imageUrl.ToString());
            }
        }
Example #25
0
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;


                attivitaList.Clear();
                foreach (var doc in documents.Documents)
                {
                    string desc, source, dat;
                    if (doc.Get("description") == null)
                    {
                        desc = "";
                    }
                    else
                    {
                        desc = doc.Get("description").ToString();
                    }
                    if (doc.Get("source") == null)
                    {
                        source = "";
                    }
                    else
                    {
                        source = doc.Get("source").ToString();
                    }
                    if (doc.Get("data") == null)
                    {
                        dat = "";
                    }
                    else
                    {
                        dat = doc.Get("data").ToString();
                    }


                    Attivita attivita = new Attivita
                    {
                        Name        = doc.Get("name").ToString(),
                        Description = desc,
                        Source      = source,
                        Scadenza    = dat,
                        Id          = doc.Id
                    };

                    attivitaList.Add(attivita);
                }
            }
            else
            {
                attivitaList.Clear();
            }
            hasReadAttivita = true;
        }
 public void OnComplete(Task task)
 {
     if (task.IsSuccessful)
     {
         if (task.Result is DocumentReference doc)
         {
             _tcs.TrySetResult(doc.Id);
             return;
         }
     }
     _tcs.TrySetResult(default);
Example #27
0
 public void OnComplete(Android.Gms.Tasks.Task task)
 {
     if (task.IsSuccessful)
     {
         var docsObj = task.Result;
         if (docsObj is QuerySnapshot docs)
         {
             _tcs.TrySetResult(docs.Convert <T>());
         }
     }
 }
Example #28
0
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            //if (task.IsSuccessful)
            //{
            //	bool isFetched = FirebaseRemoteConfig.Instance.ActivateFetched();
            //}
            //else
            //{

            //}
        }
 public void OnComplete(Task task)
 {
     if (task.IsSuccessful && task.Result != null)
     {
         Service.Location = (Location)task.Result;
     }
     else
     {
         Log.Warn(Service.Tag, "Failed to get location.");
     }
 }
Example #30
0
 public void OnComplete(Android.Gms.Tasks.Task task)
 {
     if (task.IsSuccessful)
     {
         FirebaseUser user = mAuth.CurrentUser;
     }
     else
     {
         Toast.MakeText(this, "Authentication failed.", ToastLength.Short).Show();
     }
 }