private void StartTest() { buttonStartTest.Enabled = false; testLogic = wordsAdapter.GetTestLogic(); if (testLogic.GetCountSelectWords() == 0) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Предупреждение"); alert.SetMessage("Тест должен состоять минимум из одного слова!"); alert.SetPositiveButton("Ок", (senderAlert, args) => { buttonStartTest.Enabled = true; }); Dialog zeroWordsDialog = alert.Create(); zeroWordsDialog.Show(); zeroWordsDialog.SetCanceledOnTouchOutside(false); } else { testLogic.CreateWordsForTest(); Intent intent = new Intent(this, typeof(SolutionTestActivity)); intent.PutStringArrayListExtra("WordsForTest", testLogic.GetWordsForTest()); StartActivity(intent); Finish(); } }
private void StartGenerationTest() { buttonStartTest.Enabled = false; if (typeOfGeneration == 1 || typeOfGeneration == 3 || typeOfGeneration == 5) { int countWords = GetNumberInEditText(); if (countWords <= 0) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Предупреждение"); alert.SetMessage("Тест должен состоять минимум из одного слова!"); alert.SetPositiveButton("Ок", (senderAlert, args) => { buttonStartTest.Enabled = true; }); Dialog zeroWordsDialog = alert.Create(); zeroWordsDialog.Show(); zeroWordsDialog.SetCanceledOnTouchOutside(false); } else { textViewWaiting.Visibility = Android.Views.ViewStates.Visible; Task.Run(() => testLogic.GenerateTestByTypeOfGeneration(typeOfGeneration, countWords)).Wait(); Intent intent = new Intent(this, typeof(SolutionTestActivity)); intent.PutStringArrayListExtra("WordsForTest", testLogic.GetWordsForTest()); StartActivity(intent); Finish(); } } else { textViewWaiting.Visibility = Android.Views.ViewStates.Visible; Task.Run(() => testLogic.GenerateTestByTypeOfGeneration(typeOfGeneration)).Wait(); Intent intent = new Intent(this, typeof(SolutionTestActivity)); intent.PutStringArrayListExtra("WordsForTest", testLogic.GetWordsForTest()); StartActivity(intent); Finish(); } }