public static StationCardFragment WithStation (Station station, GeoPoint currentLocation, BikeActionStatus status)
		{
			var r = new StationCardFragment ();
			r.station = station;
			r.currentLocation = currentLocation;
			r.status = status;
			return r;
		}
		async Task SetMapStationPins (Station[] stations, float alpha = 1)
		{
			var stationsToUpdate = stations.Where (station => {
				Marker marker;
				var stats = station.BikeCount + "|" + station.EmptySlotCount;
				if (existingMarkers.TryGetValue (station.Id, out marker)) {
					if (marker.Snippet == stats && !showedStale)
						return false;
					marker.Remove ();
				}
				return true;
			}).ToArray ();

			var pins = await Task.Run (() => stationsToUpdate.ToDictionary (station => station.Id, station => {
				var w = 24.ToPixels ();
				var h = 40.ToPixels ();
				if (station.Locked)
					return pinFactory.GetClosedPin (w, h);
				var ratio = (float)TruncateDigit (station.BikeCount / ((float)station.Capacity), 2);
				return pinFactory.GetPin (ratio,
				                          station.BikeCount,
				                          w, h,
				                          alpha: alpha);
			}));

			foreach (var station in stationsToUpdate) {
				var pin = pins [station.Id];

				var markerOptions = new MarkerOptions ()
					.SetTitle (station.Id + "|" + station.Name)
					.SetSnippet (station.Locked ? string.Empty : station.BikeCount + "|" + station.EmptySlotCount)
					.SetPosition (new Android.Gms.Maps.Model.LatLng (station.Location.Lat, station.Location.Lon))
					.InvokeIcon (BitmapDescriptorFactory.FromBitmap (pin));
				existingMarkers [station.Id] = mapFragment.Map.AddMarker (markerOptions);
			}
		}
Exemple #3
0
 public bool Equals(Station other)
 {
     return other.Id == Id;
 }
Exemple #4
0
        public static IList<Station> ParseStations(Stream stream)
        {
            using (var reader = new BinaryReader (stream, System.Text.Encoding.UTF8, true)) {
                var count = reader.ReadInt32 ();
                var stations = new Station[count];
                for (int i = 0; i < count; i++) {
                    stations [i] = new Station {
                        Id = reader.ReadInt32 (),
                        Name = reader.ReadString (),
                        Location = new GeoPoint { Lat = reader.ReadDouble (), Lon = reader.ReadDouble () },
                        Installed = reader.ReadBoolean (),
                        Locked = reader.ReadBoolean (),
                        Temporary = reader.ReadBoolean (),
                        Public = reader.ReadBoolean (),
                        BikeCount = reader.ReadInt32 (),
                        EmptySlotCount = reader.ReadInt32 ()
                    };
                }

                return stations;
            }
        }
Exemple #5
0
		async Task<Asset> CreateWearAssetFrom (Station station)
		{
			var cacheDir = CacheDir.AbsolutePath;
			var file = Path.Combine (cacheDir, "StationBackgrounds", station.Id.ToString ());
			byte[] content = null;
			var url = GoogleApis.MakeStreetViewUrl (station.Location, 640, 400);

			try {
				if (!File.Exists (file)) {
					if (client == null)
						client = new HttpClient ();
					content = await client.GetByteArrayAsync (url);
					Directory.CreateDirectory (Path.GetDirectoryName (file));
					File.WriteAllBytes (file, content);
				} else {
					content = File.ReadAllBytes (file);
				}
			} catch (Exception e) {
				e.Data ["URL"] = url;
				Android.Util.Log.Error ("StreetViewBackground", e.ToString ());
				AnalyticsHelper.LogException ("StreetViewBackground", e);
			}

			return content == null ? null : Asset.CreateFromBytes (content);
		}
Exemple #6
0
 public bool Equals(Station other)
 {
     return(other.Id == Id);
 }