// Callback method used by PlaceDownloaderTask public void addNewPlace(PlaceRecord place) { Log.i(TAG, "Entered addNewPlace()"); if (place.getCountryName() == null || place.getCountryName().isEmpty()) { showToast(getString(R.string.no_country_string)); } else if (!mAdapter.intersects(place.getLocation())) { place.setDateVisited(new Date()); mAdapter.add(place); mAdapter.notifyDataSetChanged(); } else { showToast(getString(R.string.duplicate_location_string)); } }
// Callback method used by PlaceDownloaderTask public void addNewPlace(PlaceRecord place) { // TODO - Attempt to add place to the adapter, considering the following cases // A PlaceBadge for this location already exists - issue a Toast message // with the text - "You already have this location badge." Use the PlaceRecord // class' intersects() method to determine whether a PlaceBadge already exists // for a given location. Do not add the PlaceBadge to the adapter // The place is null - issue a Toast message with the text // "PlaceBadge could not be acquired" // Do not add the PlaceBadge to the adapter // The place has no country name - issue a Toast message // with the text - "There is no country at this location". // Do not add the PlaceBadge to the adapter // Otherwise - add the PlaceBadge to the adapter if (null == place) { Toast.makeText( this.getApplicationContext(), "PlaceBadge could not be acquired", Toast.LENGTH_LONG) .show(); } else if (mAdapter.intersects(place.getLocation())) { Toast.makeText( this.getApplicationContext(), getText(R.string.duplicate_location_string), Toast.LENGTH_LONG) .show(); } else if (null == place.getCountryName() || place.getCountryName().equals("")) { Toast.makeText( this.getApplicationContext(), getText(R.string.no_country_string), Toast.LENGTH_LONG) .show(); } else { mAdapter.add(place); } }