Ejemplo n.º 1
0
        public async Task Load(object repo)
        {
            if (!GlobalHelper.IsInternet())
            {
                //Sending NoInternet message to all viewModels
                Messenger.Default.Send(new GlobalHelper.NoInternetMessageType());
            }
            else
            {
                //Sending Internet available message to all viewModels
                Messenger.Default.Send(new GlobalHelper.HasInternetMessageType());

                isLoading = true;
                if (repo.GetType() == typeof(string))
                {
                    //Splitting repository name and owner name
                    var names = (repo as string).Split('/');
                    Repository = await RepositoryUtility.GetRepository(names[0], names[1]);
                }
                else
                {
                    Repository = repo as Repository;
                }
                IsStar = await RepositoryUtility.CheckStarred(Repository);

                isLoading = false;
            }
        }
Ejemplo n.º 2
0
        public async Task Load(object repo)
        {
            if (!GlobalHelper.IsInternet())
            {
                //Sending NoInternet message to all viewModels
                Messenger.Default.Send(new GlobalHelper.LocalNotificationMessageType {
                    Message = "No Internet", Glyph = "\uE704"
                });
            }
            else
            {
                isLoading = true;

                string s = repo as string;
                if (s != null)
                {
                    //Splitting repository name and owner name
                    var names = s.Split('/');
                    Repository = await RepositoryUtility.GetRepository(names[0], names[1]);
                }
                else
                {
                    Repository = repo as Repository;
                }

                IsStar = await RepositoryUtility.CheckStarred(Repository);

                IsWatching = await RepositoryUtility.CheckWatched(Repository);

                isLoading = false;
            }
        }
Ejemplo n.º 3
0
        public async Task Load(object repo)
        {
            if (!GlobalHelper.IsInternet())
            {
                //Sending NoInternet message to all viewModels
                Messenger.Default.Send(new GlobalHelper.LocalNotificationMessageType {
                    Message = "No Internet", Glyph = "\uE704"
                });
            }
            else
            {
                isLoading = true;

                if (repo is string s)
                {
                    //Splitting repository name and owner name
                    var names = s.Split('/');
                    Repository = await RepositoryUtility.GetRepository(names[0], names[1]);
                }
                else
                {
                    if ((repo as Repository).FullName == null)
                    {
                        Repository = await RepositoryUtility.GetRepository((repo as Repository).Id);
                    }
                    else
                    {
                        Repository = repo as Repository;
                    }
                }
                if (Repository != null)
                {
                    WatchersCount = Repository.SubscribersCount;
                    IsStar        = await RepositoryUtility.CheckStarred(Repository);

                    IsWatching = await RepositoryUtility.CheckWatched(Repository);

                    if (Repository.SubscribersCount == 0)
                    {
                        WatchersCount = (await RepositoryUtility.GetRepository(Repository.Id)).SubscribersCount;
                    }
                }
                isLoading = false;
            }
        }
Ejemplo n.º 4
0
        public async Task Load(Repository repo)
        {
            Repository = repo;
            if (!GlobalHelper.IsInternet())
            {
                //Sending NoInternet message to all viewModels
                Messenger.Default.Send(new GlobalHelper.NoInternetMessageType());
            }
            else
            {
                //Sending Internet available message to all viewModels
                Messenger.Default.Send(new GlobalHelper.HasInternetMessageType());

                isLoading = true;
                if (Repository?.Owner != null)
                {
                    // Get the image buffer manually to avoid making the HTTP call twice
                    CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
                    IBuffer buffer = await HTTPHelper.GetBufferFromUrlAsync(Repository.Owner.AvatarUrl, cts.Token);

                    if (buffer != null)
                    {
                        // Load the user image
                        Tuple <ImageSource, ImageSource> images = await ImageHelper.GetImageAndBlurredCopyFromPixelDataAsync(buffer, 256);

                        UserAvatar        = images?.Item1;
                        UserBlurredAvatar = images?.Item2;

                        // Calculate the brightness
                        byte brightness = await ImageHelper.CalculateAverageBrightnessAsync(buffer);

                        Messenger.Default.Send(new GlobalHelper.SetBlurredAvatarUIBrightnessMessageType {
                            Brightness = brightness
                        });
                    }
                }
                IsStar = await RepositoryUtility.CheckStarred(Repository);

                isLoading = false;
            }
        }
Ejemplo n.º 5
0
        public async Task Load(object repo)
        {
            if (GlobalHelper.IsInternet())
            {
                isLoading = true;

                if (repo is string s)
                {
                    //Splitting repository name and owner name
                    var names = s.Split('/');
                    Repository = await RepositoryUtility.GetRepository(names[0], names[1]);
                }
                else
                {
                    if ((repo as Repository).FullName == null)
                    {
                        Repository = await RepositoryUtility.GetRepository((repo as Repository).Id);
                    }
                    else
                    {
                        Repository = repo as Repository;
                    }
                }
                if (Repository != null)
                {
                    WatchersCount = Repository.SubscribersCount;
                    IsStar        = await RepositoryUtility.CheckStarred(Repository);

                    IsWatching = await RepositoryUtility.CheckWatched(Repository);

                    if (Repository.SubscribersCount == 0)
                    {
                        WatchersCount = (await RepositoryUtility.GetRepository(Repository.Id)).SubscribersCount;
                    }
                }
                isLoading = false;
            }
        }