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();
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_repeat_word);

            RepeatSessionType type = (RepeatSessionType)Intent.Extras.GetInt("Type", 0);

            m_ListView = FindViewById <ListView>(Resource.Id.lwMain);

            m_Session = WordsManager.Instance.GetOrGenerateCurrentSession(type);

            if (m_Session == null)
            {
                Toast.MakeText(Application.Context, "Cant generate session", ToastLength.Long).Show();
                Finish();
                return;
            }

            if (m_Session.Words.Count == 0)
            {
                Toast.MakeText(Application.Context, "No words for that sesion", ToastLength.Long).Show();
                Finish();
                return;
            }

            m_ListView.TextFilterEnabled = true;
            m_ListView.Adapter           = m_ListViewAdapter = new ListItemWordAdapter(this, m_ListItemWords, type.NeedReverse());
            m_ListView.ItemClick        += OnListItemClick;

            m_NextButton        = FindViewById <Button>(Resource.Id.btnGoNext);
            m_NextButton.Click += (sender, e) =>
            {
                NextButtonClicked();
            };

            PrepareWords();
        }