private void SetNewFragment() { Type thisType = tasks[taskIndex].GetType(); if (thisType == typeof (QuickFireTask)) { currentFragment = QuickFireFragment.NewInstance(tasks[taskIndex], helpers[tasks[taskIndex].TaskType]); } else if (thisType == typeof (ImageDescTask)) { currentFragment = ImageDescFragment.NewInstance(tasks[taskIndex], helpers[tasks[taskIndex].TaskType]); } else { currentFragment = null; return; } if (!GetPrefs().GetBoolean(thisType.ToString(), false)) { currentFragment.runOnceCreated.Push(delegate { ShowInfo(); }); ISharedPreferencesEditor editor = GetPrefs().Edit(); editor.PutBoolean(thisType.ToString(), true); editor.Apply(); } }
private void recButton_Click(object sender, EventArgs e) { if (currentStage == AssessmentStage.Preparing) return; if (currentStage == AssessmentStage.Preamble) { StartAssessment(); return; } if (recording) { TimeSpan recTime = DateTime.Now - timeRecStarted; if (recTime.TotalMilliseconds < MinimumMillis) return; // Stop recording and move onto next task/finish StopRecording(); if (!currentFragment.IsFinished()) { currentFragment.NextAction(); } else { taskIndex++; if (taskIndex < tasks.Length) { loadingContainer.Visibility = ViewStates.Visible; fragmentContainer.Visibility = ViewStates.Gone; currentFragment = null; SetNewFragment(); if (currentFragment != null) { FragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, currentFragment, "ASSESSMENT_TASK") .Commit(); currentFragment.runOnceCreated.Push( delegate { RunOnUiThread(() => { assessmentType.Text = currentFragment.GetTitle(); }); }); } loadingContainer.Visibility = ViewStates.Gone; fragmentContainer.Visibility = ViewStates.Visible; } else { FinishAssessment(); } } } else { StartRecording(); } }
private void StartAssessment(int startPosition = -1) { preambleContainer.Visibility = (Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape) ? ViewStates.Invisible : ViewStates.Gone; recButton.Visibility = ViewStates.Visible; helpButton.Visibility = ViewStates.Visible; currentStage = AssessmentStage.Running; if (startPosition >= 0) { currentFragment = FragmentManager.FindFragmentByTag<AssessmentFragment>("ASSESSMENT_TASK"); currentFragment.GoToStage(startPosition); } else { SetNewFragment(); FragmentManager.BeginTransaction() .Add(Resource.Id.fragment_container, currentFragment, "ASSESSMENT_TASK") .Commit(); } fragmentContainer.Visibility = ViewStates.Visible; // If the device was rotated, the fragment might already exist and the data will be ready if (currentFragment.finishedCreating) { assessmentType.Text = currentFragment.GetTitle(); } // Otherwise, the fragment's data is currently waiting to be unbundled and so actions should be queued else { currentFragment.runOnceCreated.Push( delegate { RunOnUiThread(() => { assessmentType.Text = currentFragment.GetTitle(); }); }); } recButton.Text = "Record"; }