protected override void OnResume() { try { base.OnResume(); c.Log("LocationActivity resuming, ListActivity.initialized " + ListActivity.initialized); if (!ListActivity.initialized) { return; } RegisterReceiver(locationReceiver, new IntentFilter("balintfodor.locationconnection.LocationReceiver")); locationList = new List <LocationItem>(); if (File.Exists(c.locationLogFile)) { string[] fileLines = File.ReadAllLines(c.locationLogFile); for (int i = fileLines.Length - 1; i >= 0; i--) { string line = fileLines[i]; LocationItem item = new LocationItem(); int sep1Pos = line.IndexOf('|'); int sep2Pos = line.IndexOf('|', sep1Pos + 1); int sep3Pos = line.IndexOf('|', sep2Pos + 1); item.time = long.Parse(line.Substring(0, sep1Pos)); item.latitude = double.Parse(line.Substring(sep1Pos + 1, sep2Pos - sep1Pos - 1), CultureInfo.InvariantCulture); item.longitude = double.Parse(line.Substring(sep2Pos + 1, sep3Pos - sep2Pos - 1), CultureInfo.InvariantCulture); item.inApp = (line.Substring(sep3Pos + 1) == "0") ? false : true; item.isSelected = false; locationList.Add(item); } locationList[0].isSelected = true; selectedPos = 0; if (mapLoaded) { thisMap.Clear(); SetMap(); } } else { c.Snack(Resource.String.NoLocationRecords); } adapter = new LocationListAdapter(this, locationList); LocationHistoryList.Adapter = adapter; } catch (Exception ex) { c.ReportErrorSilent(ex.Message + System.Environment.NewLine + ex.StackTrace); } }
private void LoadList() { locationList = new List <LocationItem>(); if (lines != null) { LocationHistoryMap.RemoveOverlays(lines.ToArray()); } lines = new List <MKPolyline>(); //File.Delete(c.locationLogFile); if (File.Exists(c.locationLogFile)) { string[] fileLines = File.ReadAllLines(c.locationLogFile); for (int i = fileLines.Length - 1; i >= 0; i--) { string line = fileLines[i]; LocationItem item = new LocationItem(); int sep1Pos = line.IndexOf('|'); int sep2Pos = line.IndexOf('|', sep1Pos + 1); int sep3Pos = line.IndexOf('|', sep2Pos + 1); if (sep2Pos != -1) { item.time = long.Parse(line.Substring(0, sep1Pos)); item.latitude = double.Parse(line.Substring(sep1Pos + 1, sep2Pos - sep1Pos - 1), CultureInfo.InvariantCulture); item.longitude = double.Parse(line.Substring(sep2Pos + 1, sep3Pos - sep2Pos - 1), CultureInfo.InvariantCulture); string status = line.Substring(sep3Pos + 1); switch (status) { case "0": item.inApp = false; item.sent = false; break; case "1": item.inApp = true; item.sent = false; break; case "2": item.inApp = true; item.sent = true; break; } item.isSelected = false; locationList.Add(item); } } locationList[0].isSelected = true; selectedPos = 0; } else { c.Snack(LangEnglish.NoLocationRecords); } adapter = new LocationListAdapter(locationList); LocationHistoryList.Source = adapter; LocationHistoryList.ReloadData(); LocationHistoryList.Delegate = this; }