private void InitAdapter() { recyclerView = FindViewById <RecyclerView>(Resource.Id.statsList); var layoutManager = new LinearLayoutManager(this); recyclerView.SetLayoutManager(layoutManager); HistoryStatsAdapter adapter; var ids = new List <string>(); switch (extraReason) { case 0: ids.Add(RegisterViewModel.GetIdByUsername(SignInViewModel.currentUser.Username)); adapter = new HistoryStatsAdapter(historyViewModel.FetchItemList(ids, DateTime.Now)); break; case 1: ids = GroupActivityModel.GetGroupUserIds(extraName); adapter = new HistoryStatsAdapter(historyViewModel.FetchItemList(ids, DateTime.Now)); break; case 2: ids.Add(RegisterViewModel.GetIdByUsername(extraName)); adapter = new HistoryStatsAdapter(historyViewModel.FetchItemList(ids, DateTime.Now)); break; default: ids.Add(RegisterViewModel.GetIdByUsername(SignInViewModel.currentUser.Username)); adapter = new HistoryStatsAdapter(historyViewModel.FetchItemList(ids, DateTime.Now)); break; } recyclerView.SetAdapter(adapter); }
private async void InitAdapterAsync() { RecyclerView = FindViewById <RecyclerView>(Resource.Id.statsList); var layoutManager = new LinearLayoutManager(this); RecyclerView.SetLayoutManager(layoutManager); HistoryStatsAdapter adapter; var ids = new List <string>(); switch (extraReason) { case 0: var itemList = await historyViewModel.FetchItemList(ids, DateTime.UtcNow); ids.Add(SignInViewModel.currentUser.Id); adapter = new HistoryStatsAdapter(itemList); break; case 1: ids = await GroupActivityModel.GetGroupUserIdsAsync(extraName); itemList = await historyViewModel.FetchItemList(ids, DateTime.UtcNow); adapter = new HistoryStatsAdapter(itemList); break; case 2: var user = await API.UserEndpoint.GetUserByUsername(extraName); ids.Add(user.Id); itemList = await historyViewModel.FetchItemList(ids, DateTime.UtcNow); adapter = new HistoryStatsAdapter(itemList); break; default: itemList = await historyViewModel.FetchItemList(ids, DateTime.UtcNow); ids.Add(SignInViewModel.currentUser.Id); adapter = new HistoryStatsAdapter(itemList); break; } RecyclerView.SetAdapter(adapter); }
private void InitView() { var dateInput = FindViewById <EditText>(Resource.Id.datePicker); dateInput.Click += (sender, e) => { DatePickerFragment frag = DatePickerFragment.NewInstance(async delegate(DateTime time) { dateInput.Text = time.ToLongDateString(); var ids = new List <string>(); switch (extraReason) { case 0: ids.Add(SignInViewModel.currentUser.Id); var itemList = await historyViewModel.FetchItemList(ids, time); (RecyclerView.GetAdapter() as HistoryStatsAdapter).UpdateList(itemList); break; case 1: ids = await GroupActivityModel.GetGroupUserIdsAsync(extraName); itemList = await historyViewModel.FetchItemList(ids, time); (RecyclerView.GetAdapter() as HistoryStatsAdapter).UpdateList(itemList); break; case 2: var user = await API.UserEndpoint.GetUserByUsername(extraName); ids.Add(user.Id); itemList = await historyViewModel.FetchItemList(ids, time); (RecyclerView.GetAdapter() as HistoryStatsAdapter).UpdateList(itemList); break; default: ids.Add(SignInViewModel.currentUser.Id); itemList = await historyViewModel.FetchItemList(ids, time); (RecyclerView.GetAdapter() as HistoryStatsAdapter).UpdateList(itemList); break; } }); frag.Show(SupportFragmentManager, DatePickerFragment.TAG); }; }