public void UpdateInfo (ParkingLotInfo parkingLotInfo) { info = parkingLotInfo; nameLabel.Text = parkingLotInfo.Name; freeSlotsLabel.Text = "Free slots: " + parkingLotInfo.Spots; LayoutSubviews (); }
public static List<ParkingLotInfo> DecodeParkingLotsRequest (JsonValue json) { List<ParkingLotInfo> parkingLotInfoList = new List<ParkingLotInfo> (); var jsonarray = json as JsonArray; if (jsonarray != null) { foreach (var jsonObject in jsonarray) { if (jsonObject is JsonPrimitive) { continue; } try { ParkingLotInfo parkingLotInfo = new ParkingLotInfo (); if (jsonObject.ContainsKey (ParkingLotInfo.RATE)) { parkingLotInfo.BaseRatePerMinute = jsonObject [ParkingLotInfo.RATE]; } if (jsonObject.ContainsKey (ParkingLotInfo.LOCATION)) { parkingLotInfo.Location = jsonObject [ParkingLotInfo.LOCATION]; } else { continue; } if (jsonObject.ContainsKey (ParkingLotInfo.NAME)) { parkingLotInfo.Name = jsonObject [ParkingLotInfo.NAME]; } else { continue; } if (jsonObject.ContainsKey (ParkingLotInfo.OCCUPIED)) { parkingLotInfo.Occupied = jsonObject [ParkingLotInfo.OCCUPIED]; } if (jsonObject.ContainsKey (ParkingLotInfo.PROVIDER)) { parkingLotInfo.Provider = jsonObject [ParkingLotInfo.PROVIDER]; } if (jsonObject.ContainsKey (ParkingLotInfo.PUBLICID)) { parkingLotInfo.PublicId = jsonObject [ParkingLotInfo.PUBLICID]; } if (jsonObject.ContainsKey (ParkingLotInfo.SPOTS)) { parkingLotInfo.Spots = jsonObject [ParkingLotInfo.SPOTS]; } parkingLotInfoList.Add (parkingLotInfo); } catch { Console.WriteLine ("# Failed to parse"); } } } return parkingLotInfoList; }
public ParkingLotView (Activity activity, ParkingLotInfo info) : base (activity) { this.activity = activity; parkingLotInfo = info; backgroundImage = new UIImageView (activity); backgroundImage.ImageResource = Resource.Drawable.app_parking_background; backgroundImage.SetScaleType (Android.Widget.ImageView.ScaleType.CenterCrop); backgroundImage.LayoutParameters = LayoutUtils.GetRelativeMatchParent (); infoContainer = new UIView (activity); infoContainer.SetRoundBordersWithColor ( CustomColors.LightColor, Sizes.LoginInputHeight / 3, Sizes.LoginSeparatorSize ); nameLabel = new ParkingLotLabel (activity); nameLabel.Text = parkingLotInfo.Name; nameLabel.TextSize = Sizes.GetRealSize (10); // locationLabel = new ParkingLotLabel (activity); // locationLabel.Text = parkingLotInfo.Location; // locationLabel.TextSize = Sizes.GetRealSize (8); freeSpotsLabel = new ParkingLotLabel (activity); freeSpotsLabel.TextSize = Sizes.GetRealSize (8); UpdateFreeSpots (); startParkingButton = new ParkingLotLabel (activity); startParkingButton.TextSize = Sizes.GetRealSize (9); startParkingButton.TextColor = CustomColors.DarkColor; if (LoginState.ActiveUser != null && LoginState.ActiveUser.ParkingLotInUse == info) { startParkingButton.Text = Strings.EndParking; } else { if (LoginState.ActiveUser.ParkingLotInUse == null) { startParkingButton.Text = Strings.StartParking; } else { startParkingButton.Text = "Parking at: " + LoginState.ActiveUser.ParkingLotInUse.Name; } } int radius = (int)(Sizes.ParkingViewLabelHeight * 0.6f); startParkingButton.SetCornerRadiusWithColor (CustomColors.LightColor, new float[] { 0, 0, 0, 0, radius, radius, radius, radius } ); startParkingButton.Click += HandleStartParkingClick; separator = new UIView (activity); separator.BackgroundColor = CustomColors.LightColor; infoContainer.AddViews ( nameLabel, separator, // locationLabel, freeSpotsLabel ); navigateButton = new ParkingLotLabel (activity); navigateButton.Text = Strings.Navigate; navigateButton.TextSize = Sizes.GetRealSize (10); navigateButton.Click += HandleNavigateClick; navigateButtonContainer = new UIView (activity); navigateButtonContainer.SetRoundBordersWithColor ( CustomColors.LightColor, Sizes.LoginInputHeight / 3, Sizes.LoginSeparatorSize ); navigateButtonContainer.AddView (navigateButton); AddViews ( backgroundImage, infoContainer, startParkingButton, navigateButtonContainer ); Frame = new Frame (DeviceInfo.ScreenWidth, DeviceInfo.TrueScreenHeight); }