public void testDataProvider() { assertNotNull(mDataManager); android.location.Location currentLocation = AppLocationManager.getCurrentLocation(); Location location = new Location( String.valueOf(currentLocation.getLatitude()), String.valueOf(currentLocation.getLongitude())); final List<Place> eventList = mDataManager.getPlaceList(location, PlaceCategoryFilter.HOTEL, "8", ""); // see parameters assertNotNull(eventList); assertTrue(eventList.size() > 0); final Place place = eventList.get(0); final CountDownLatch latch = new CountDownLatch(1); mPlaceActivity.runOnUiThread( new Runnable() { @Override public void run() { mPlaceActivity.showPlace(place); latch.countDown(); } }); try { latch.await(); } catch (InterruptedException e) { e.printStackTrace(); } } // end testDataProvider
public void testDataProvider() { assertNotNull(mDataManager); android.location.Location currentLocation = AppLocationManager.getCurrentLocation(); Location location = new Location( String.valueOf(currentLocation.getLatitude()), String.valueOf(currentLocation.getLongitude())); final List<Event> eventList = mDataManager.getEventList( location, EventCategoryFilter.Music, "10", null, DateFilter.THIS_WEEK); assertNotNull(eventList); assertTrue(eventList.size() > 0); final Event event = eventList.get(0); final CountDownLatch latch = new CountDownLatch(1); mEventActivity.runOnUiThread( new Runnable() { @Override public void run() { mEventActivity.showEvent(event); latch.countDown(); } }); try { latch.await(); } catch (InterruptedException e) { e.printStackTrace(); } }
@Override protected void setUp() { setActivityInitialTouchMode(false); mPlaceActivity = getActivity(); mDataManager = DataManager.getSingleton(); } // end setUp
@Override protected Place doInBackground(PlaceSearchData... params) { return DataManager.getSingleton().getPlaceDetails(params[0].id, params[0].source); }
public void showPlace(Place place) { if (place != null) { this.currentPlace = place; // create place name. TextView name = (TextView) findViewById(R.id.place_name); if (name != null) { name.setText(place.getName()); } // create PLACE description. TextView description = (TextView) findViewById(R.id.place_description); if (description != null) { String descStr = place.getDescription(); if (descStr != null && !descStr.isEmpty() && !descStr.equals("null")) { description.setText(descStr); } else { description.setVisibility(View.GONE); } } if (place.getImage() != null && !place.getImage().isEmpty()) { // place image ImageView image = (ImageView) findViewById(R.id.place_image); if (image != null) { DataManager.getSingleton().downloadBitmap(place.getImage(), image); } } // place location Location location = place.getLocation(); if (location != null) { TextView placeLocation = (TextView) findViewById(R.id.place_location); if (placeLocation != null) { placeLocation.setText(location.getAddress()); } // place distance. TextView distance = (TextView) findViewById(R.id.place_distance); if (distance != null) { float[] distanceResults = new float[1]; android.location.Location currentLocation = AppLocationManager.getCurrentLocation(); DecimalFormat df = new DecimalFormat("#.#"); if (currentLocation != null) { android.location.Location.distanceBetween( currentLocation.getLatitude(), currentLocation.getLongitude(), Double.valueOf(location.getLatitude()), Double.valueOf(location.getLongitude()), distanceResults); double miles = distanceResults[0] / 1609.34; // i mile = // 1.60934km distance.setText(df.format(miles) + "mi"); } else { distance.setText("--"); } } MapView map = (MapView) findViewById(R.id.mapview); if (map != null) { MapController mc = map.getController(); if (mc != null) { List<Overlay> mapOverlaysList = map.getOverlays(); Drawable drawable = this.getResources().getDrawable(R.drawable.red_pointer_icon); // creating an ItemizedOverlayActivity object so we can // have multiple overlays // added to a list to show them in a map ItemizedOverlayActivity itemizedoverlay = new ItemizedOverlayActivity(drawable, this); GeoPoint geoPoint = new GeoPoint( (int) (Double.valueOf(location.getLatitude()) * 1E6), (int) (Double.valueOf(location.getLongitude()) * 1E6)); // Creates an overlay item with a geopoint to show in // the map OverlayItem overlayitem = new OverlayItem(geoPoint, "Place", place.getName()); itemizedoverlay.addOverlay(overlayitem); mapOverlaysList.add(itemizedoverlay); mc.setCenter(geoPoint); mc.setZoom(17); } } showEventList(place.getEventsAtPlace()); } } } // end showPlace