Skip to content

Commit

Permalink
Improve Avatar Image Loading
Browse files Browse the repository at this point in the history
Implement `ImageService.Instance.LoadString().PreloadAsync()` to precache the Avatar Images
  • Loading branch information
TheCodeTraveler committed Aug 16, 2020
1 parent 9b3b3cc commit 21c45f2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions GitTrends/ViewModels/RepositoryViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
Expand All @@ -9,6 +10,7 @@
using AsyncAwaitBestPractices;
using AsyncAwaitBestPractices.MVVM;
using Autofac;
using FFImageLoading;
using GitTrends.Mobile.Common;
using GitTrends.Mobile.Common.Constants;
using GitTrends.Shared;
Expand Down Expand Up @@ -292,6 +294,11 @@ void UpdateVisibleRepositoryList(in string searchBarText, in SortingOption sorti
var filteredRepositoryList = GetRepositoriesFilteredBySearchBar(_repositoryList, searchBarText);

VisibleRepositoryList = MobileSortingService.SortRepositories(filteredRepositoryList, sortingOption, isReversed).ToList();

foreach (var url in VisibleRepositoryList.Select(x => x.OwnerAvatarUrl).Distinct().Where(isValidUri))
ImageService.Instance.LoadString(url).PreloadAsync().SafeFireAndForget(ex => AnalyticsService.Report(ex));

static bool isValidUri(string url) => Uri.TryCreate(url, UriKind.Absolute, out _);
}

void UpdateListForLoggedOutUser()
Expand Down

0 comments on commit 21c45f2

Please sign in to comment.