void PrepareWords() { if (m_Session.IsEnded) { Finish(); return; } m_NextButton.Text = GetTextForButton(); m_ListItemWords.Clear(); if (m_Session.ImmediateRepeatIsInProgress) { for (int i = m_Session.RepeatedWords - LIST_WORDS_COUNT; i < m_Session.RepeatedWords; i++) { RepeatSessionWord word = m_Session.Words[i]; if (word.IsForgotten) { m_ListItemWords.Add(new ListItemWord() { Russian = WordsManager.Instance.GetWord(word.English).Russian, English = word.English }); } } } else { List <RepeatSessionWord> words = m_Session.PostRepeatIsInProgress ? m_Session.PostRepeatWords : m_Session.Words; int repeatedCount = m_Session.PostRepeatIsInProgress ? m_Session.RepeatedWordsInPostRepeat : m_Session.RepeatedWords; for (int i = repeatedCount; i < Math.Min(repeatedCount + LIST_WORDS_COUNT, words.Count); i++) { RepeatSessionWord word = words[i]; m_ListItemWords.Add(new ListItemWord() { Russian = WordsManager.Instance.GetWord(word.English).Russian, English = word.English }); } } m_ListViewAdapter.NotifyDataSetChanged(); m_ListView.SetSelectionAfterHeaderView(); m_StartCurrentPageTime = DateTime.Now; m_SecondsInPause = 0; m_PauseTime = null; }
void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e) { var t = m_ListItemWords[e.Position]; t.ShowTranslate = !t.ShowTranslate; m_ListViewAdapter.NotifyDataSetChanged(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_learn_active_words); m_Session = WordsManager.Instance.GetActiveLearnSession(); if (m_Session == null) { Toast.MakeText(Application.Context, "Cant generate session", ToastLength.Long).Show(); Finish(); return; } m_ListView = FindViewById <ListView>(Resource.Id.lwMain); m_ListView.TextFilterEnabled = true; m_ListView.Adapter = m_ListViewAdapter = new ListItemWordAdapter(this, m_ListItemWords, false); m_ListView.ItemClick += OnListItemClick; FindViewById <Button>(Resource.Id.btnNewWordsShowAll).Click += (sender, e) => { foreach (var word in m_ListItemWords) { word.ShowTranslate = true; } m_ListViewAdapter.NotifyDataSetChanged(); }; FindViewById <Button>(Resource.Id.btnNewWordsClear).Click += (sender, e) => { foreach (var word in m_ListItemWords) { word.ShowTranslate = false; } m_ListViewAdapter.NotifyDataSetChanged(); }; foreach (RepeatSessionWord word in m_Session.Words) { m_ListItemWords.Add(new ListItemWord() { Russian = WordsManager.Instance.GetWord(word.English).Russian, English = word.English }); } m_ListViewAdapter.NotifyDataSetChanged(); }