private void SaveTrack(StopTrackingDialog s, EventArgs ea) { FragmentTransaction ft = FragmentManager.BeginTransaction(); Fragment prev = FragmentManager.FindFragmentByTag("TrackNameDialog"); if (prev != null) { ft.Remove(prev); } ft.AddToBackStack(null); TrackNameDialog dialogBox = TrackNameDialog.NewInstance(null); dialogBox.Show(ft, "TrackNameDialog"); dialogBox.TrackNameDialogSave += (se, e) => { TrackModel tm = this.Tracker.GetOrInstantiateTrackModel(); tm.Name = e.TrackName; System.Console.WriteLine("____FAKETRACKGENERATIOSTRING____"); System.Console.WriteLine(tm.Track); Database.Database.GetInstance().InsertOrReplace(tm); this.Tracker.StopTracking(); this.UpdateStartStopPauseButton(); Toast.MakeText(this.Context, "Uw track is opgeslagen!", ToastLength.Short).Show(); se.Dismiss(); s.Dismiss(); }; }
private void StartStopTracking(object sender, EventArgs e) { if (!this.Tracker.IsTracking()) { this.StartNewTrack(); } else { FragmentTransaction ft = FragmentManager.BeginTransaction(); Fragment prev = FragmentManager.FindFragmentByTag("StopTrackingDialog"); if (prev != null) { ft.Remove(prev); } ft.AddToBackStack(null); // Create and show the dialog. StopTrackingDialog dialogBox = StopTrackingDialog.NewInstance(null); dialogBox.Show(ft, "StopTrackingDialog"); dialogBox.Cancelable = false; this.Tracker.PauseTracking(); dialogBox.OnSaveClick += this.SaveTrack; dialogBox.OnDeleteClick += (s, ea) => { this.Tracker.StopTracking(); this.UpdateStartStopPauseButton(); Toast.MakeText(this.Context, "De track is verwijderd.", ToastLength.Short).Show(); s.Dismiss(); }; // Make screenshot, store it and share it when the 'Share' button is pressed. dialogBox.OnShareClick += (s, ea) => { ShareImage(StoreScreenShot(TakeScreenShot(this.Map)), (Activity)this.Context, "RunningApp", "Ik heb " + this.Tracker.track.GetTotalRunningDistance().ToString() + " meter gelopen in een tijd van " + this.Tracker.track.GetTotalRunningTimeSpan().ToString() + " met een gemiddelde van " + this.Tracker.track.GetAvergageSpeed() + "km/h"); }; dialogBox.OnClose += (s, ea) => { this.Tracker.StartTracking(); this.UpdateStartStopPauseButton(); s.Dismiss(); }; } }