Example #1
0
        public void OnMessageReceived(IMessageEvent message)
        {
            if (!message.Path.EndsWith("/Answer"))
            {
                return;
            }

            IList <Station> stations = null;
            GeoPoint        currentLocation;

            using (var content = new System.IO.MemoryStream(message.GetData())) {
                currentLocation = GeoUtils.ParseFromStream(content);
                stations        = StationUtils.ParseStations(content);
            }

            if (stations != null)
            {
                handler.Post(() => {
                    var adapter              = new StationGridAdapter(FragmentManager, stations, currentLocation, ActionStatus);
                    pager.Adapter            = adapter;
                    pager.OffscreenPageCount = 2;
                    label.Visibility         = ViewStates.Gone;
                    pager.Visibility         = ViewStates.Visible;
                });
            }
        }
Example #2
0
        async void ProcessRawStationData(IList <DataMap> data)
        {
            var stations = new List <SimpleStation> ();

            foreach (var d in data)
            {
                stations.Add(new SimpleStation {
                    Id         = d.GetInt("Id", 0),
                    Primary    = d.GetString("Primary", "<no name>"),
                    Secondary  = d.GetString("Secondary", "<no name>"),
                    Background = await GetBitmapForAsset(d.GetAsset("Background")),
                    Bikes      = d.GetInt("Bikes", 0),
                    Racks      = d.GetInt("Racks", 0),
                    Distance   = d.GetDouble("Distance", 0),
                    Lat        = d.GetDouble("Lat", 0),
                    Lon        = d.GetDouble("Lon", 0),
                    IsFavorite = d.GetBoolean("IsFavorite", false),
                });
            }

            if (stations.Any())
            {
                adapter = new StationGridAdapter(FragmentManager,
                                                 stations,
                                                 this);
                pager.Adapter            = adapter;
                pager.OffscreenPageCount = 5;
                loading.Visibility       = ViewStates.Invisible;
                pager.Visibility         = ViewStates.Visible;
                countSwitch.Visibility   = ViewStates.Visible;
                dotsIndicator.Visibility = ViewStates.Visible;
            }
        }
Example #3
0
        public void OnDataChanged(DataEventBuffer dataEvents)
        {
            var dataEvent = Enumerable.Range(0, dataEvents.Count)
                            .Select(i => dataEvents.Get(i).JavaCast <IDataEvent> ())
                            .FirstOrDefault(de => de.Type == DataEvent.TypeChanged && de.DataItem.Uri.Path == SearchStationPath + "/Answer");

            if (dataEvent == null)
            {
                return;
            }
            var dataMapItem = DataMapItem.FromDataItem(dataEvent.DataItem);
            var map         = dataMapItem.DataMap;

            var stations = new List <SimpleStation> ();
            var data     = map.GetDataMapArrayList("Stations");

            foreach (var d in data)
            {
                stations.Add(new SimpleStation {
                    Id         = d.GetInt("Id", 0),
                    Primary    = d.GetString("Primary", "<no name>"),
                    Secondary  = d.GetString("Secondary", "<no name>"),
                    Background = GetBitmapForAsset(d.GetAsset("Background")),
                    Bikes      = d.GetInt("Bikes", 0),
                    Racks      = d.GetInt("Racks", 0),
                    Distance   = d.GetDouble("Distance", 0),
                    Lat        = d.GetDouble("Lat", 0),
                    Lon        = d.GetDouble("Lon", 0),
                    IsFavorite = d.GetBoolean("IsFavorite", false),
                });
            }

            if (stations.Any())
            {
                handler.Post(() => {
                    adapter = new StationGridAdapter(FragmentManager,
                                                     stations,
                                                     this);
                    pager.Adapter            = adapter;
                    pager.OffscreenPageCount = 5;
                    loading.Visibility       = ViewStates.Invisible;
                    pager.Visibility         = ViewStates.Visible;
                    countSwitch.Visibility   = ViewStates.Visible;
                    dotsIndicator.Visibility = ViewStates.Visible;
                });
            }
        }
Example #4
0
        public void OnDataChanged(DataEventBuffer dataEvents)
        {
            var dataEvent = Enumerable.Range (0, dataEvents.Count)
                .Select (i => dataEvents.Get (i).JavaCast<IDataEvent> ())
                .FirstOrDefault (de => de.Type == DataEvent.TypeChanged && de.DataItem.Uri.Path == SearchStationPath + "/Answer");
            if (dataEvent == null)
                return;
            var dataMapItem = DataMapItem.FromDataItem (dataEvent.DataItem);
            var map = dataMapItem.DataMap;

            var stations = new List<SimpleStation> ();
            var data = map.GetDataMapArrayList ("Stations");
            foreach (var d in data) {
                stations.Add (new SimpleStation {
                    Id = d.GetInt ("Id", 0),
                    Primary = d.GetString ("Primary", "<no name>"),
                    Secondary = d.GetString ("Secondary", "<no name>"),
                    Background = GetBitmapForAsset (d.GetAsset ("Background")),
                    Bikes = d.GetInt ("Bikes", 0),
                    Racks = d.GetInt ("Racks", 0),
                    Distance = d.GetDouble ("Distance", 0),
                    Lat = d.GetDouble ("Lat", 0),
                    Lon = d.GetDouble ("Lon", 0),
                    IsFavorite = d.GetBoolean ("IsFavorite", false),
                });
            }

            if (stations.Any ()) {
                handler.Post (() => {
                    adapter = new StationGridAdapter (FragmentManager,
                                                      stations,
                                                      this);
                    pager.Adapter = adapter;
                    pager.OffscreenPageCount = 5;
                    loading.Visibility = ViewStates.Invisible;
                    pager.Visibility = ViewStates.Visible;
                    countSwitch.Visibility = ViewStates.Visible;
                    dotsIndicator.Visibility = ViewStates.Visible;
                });
            }
        }
Example #5
0
		public void OnMessageReceived (IMessageEvent message)
		{
			if (!message.Path.EndsWith ("/Answer"))
				return;

			IList<Station> stations = null;
			GeoPoint currentLocation;
			using (var content = new System.IO.MemoryStream (message.GetData ())) {
				currentLocation = GeoUtils.ParseFromStream (content);
				stations = StationUtils.ParseStations (content);
			}

			if (stations != null) {
				handler.Post (() => {
					var adapter = new StationGridAdapter (FragmentManager, stations, currentLocation, ActionStatus);
					pager.Adapter = adapter;
					pager.OffscreenPageCount = 2;
					label.Visibility = ViewStates.Gone;
					pager.Visibility = ViewStates.Visible;
				});
			}
		}