Ejemplo n.º 1
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            var count = status == BikeActionStatus.Stop ? station.BikeCount : station.EmptySlotCount;
            var ratio = ((float)count) / station.Capacity;
            var color = InterpolateColor(Color.Rgb(0xff, 0x44, 0x44),
                                         Color.Rgb(0x99, 0xcc, 0x00),
                                         ratio);
            var bg = new RoundRectDrawable(color, TypedValue.ApplyDimension(ComplexUnitType.Dip, 2, view.Resources.DisplayMetrics));

            var countText = view.FindViewById <TextView> (Resource.Id.count);

            countText.Text = count.ToString();
            countText.SetBackgroundDrawable(bg);

            string secondary;
            var    primary = StationUtils.CutStationName(station.Name, out secondary);

            view.FindViewById <TextView> (Resource.Id.stationPrimary).Text   = primary;
            view.FindViewById <TextView> (Resource.Id.stationSecondary).Text = secondary;

            var distance     = GeoUtils.Distance(currentLocation, station.Location);
            var distanceText = view.FindViewById <TextView> (Resource.Id.distance);

            if (distance < 1)
            {
                distanceText.Text = (distance * 1000).ToString("N0") + " meters";
            }
            else
            {
                distanceText.Text = distance.ToString("N1") + " km";
            }
        }
Ejemplo n.º 2
0
        void SetCountText(View view)
        {
            var count = status == BikeActionStatus.Start ? station.Bikes : station.Racks;
            var ratio = ((float)count) / (station.Racks + station.Bikes);
            var color = InterpolateColor(Color.Rgb(0xff, 0x44, 0x44),
                                         Color.Rgb(0x99, 0xcc, 0x00),
                                         ratio);
            var bg        = new RoundRectDrawable(color, TypedValue.ApplyDimension(ComplexUnitType.Dip, 2, view.Resources.DisplayMetrics));
            var countText = View.FindViewById <TextView> (Resource.Id.count);

            countText.Text = count.ToString();
            ((View)countText.Parent).SetBackgroundDrawable(bg);
        }