public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { _favoritesService.FavoritesChanged += FavoritesChanged; //todo: change this from nuking/rebuilding every time to add/remove what's changed GroupedFavoritePlaces.Clear(); MappableFavoritePlaces.Clear(); GroupedFavoriteRoutes.Clear(); MappableFavoriteRoutes.Clear(); var favorites = await _favoritesService.GetFavoritesAsync(); foreach (IPlace place in favorites.OfType <IPlace>()) { AddFavoritePlace((IFavorite)place); } foreach (FavoriteRoute route in favorites.OfType <FavoriteRoute>()) { AddFavoriteRoute(route); } await Task.CompletedTask; }
private async void DigiTransitSearchBox_Loaded(object sender, RoutedEventArgs e) { this.IsEnabled = true; _favoritesService.FavoritesChanged += FavoritesChanged; Views.Busy.BusyChanged += BusyView_BusyChanged; if (!_favoritesInserted) { _favoritesInserted = true; _allFavorites = (await _favoritesService.GetFavoritesAsync()) .OfType <FavoritePlace>() .ToList(); int insertIndex = IsUserCurrentLocationListed ? 1 : 0; SuggestedPlaces.Insert(insertIndex, _favoritePlacesList); } }
public async void Init() { foreach (var favorite in await _favoritesService.GetFavoritesAsync()) { Favorites.Add(favorite); } if (Favorites.Count == 0) { VisualState = "LonelyHere"; } }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Favorites); // toolbar setup var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); favoritesListView = FindViewById <RecyclerView>(Resource.Id.FavoritesList); // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView favoritesListView.HasFixedSize = true; // use a linear layout manager var layoutManager = new LinearLayoutManager(this); layoutManager.Orientation = (int)Orientation.Vertical; favoritesListView.SetLayoutManager(layoutManager); _favoritesService = SimpleIoc.Default.GetInstance <IFavoritesService>(); _favorites = await _favoritesService.GetFavoritesAsync(); // specify an adapter (see also next example) mAdapter = new FavoriteListAdapter(this, _favorites, this); favoritesListView.SetAdapter(mAdapter); favoritesListView.ChildViewRemoved += FavoritesListView_ChildViewRemoved; var callback = new SimpleItemTouchHelperCallback((IItemTouchHelperAdapter)mAdapter); _itemTouchHelper = new ItemTouchHelper(callback); _itemTouchHelper.AttachToRecyclerView(favoritesListView); _placeHolder = FindViewById <TextView>(Resource.Id.placeHolder); _placeHolderAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.placeholder); if (_favorites.Count == 0) { await Task.Delay(200); _placeHolder.StartAnimation(_placeHolderAnimation); _placeHolder.Visibility = ViewStates.Visible; } }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Favorites); // toolbar setup var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); favoritesListView = FindViewById<RecyclerView>(Resource.Id.FavoritesList); // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView favoritesListView.HasFixedSize = true; // use a linear layout manager var layoutManager = new LinearLayoutManager(this); layoutManager.Orientation = (int)Orientation.Vertical; favoritesListView.SetLayoutManager(layoutManager); _favoritesService = SimpleIoc.Default.GetInstance<IFavoritesService>(); _favorites = await _favoritesService.GetFavoritesAsync(); // specify an adapter (see also next example) mAdapter = new FavoriteListAdapter(this, _favorites, this); favoritesListView.SetAdapter(mAdapter); favoritesListView.ChildViewRemoved += FavoritesListView_ChildViewRemoved; var callback = new SimpleItemTouchHelperCallback((IItemTouchHelperAdapter)mAdapter); _itemTouchHelper = new ItemTouchHelper(callback); _itemTouchHelper.AttachToRecyclerView(favoritesListView); _placeHolder = FindViewById<TextView>(Resource.Id.placeHolder); _placeHolderAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.placeholder); if (_favorites.Count == 0) { await Task.Delay(200); _placeHolder.StartAnimation(_placeHolderAnimation); _placeHolder.Visibility = ViewStates.Visible; } }