Skip to content

Commit

Permalink
update refresh button
Browse files Browse the repository at this point in the history
Weiwei Chen committed Mar 23, 2015
1 parent 90b61c1 commit c25fbeb
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ public class RestaurantApiClient {

// If tested in android simulator, this must be the actual ip address of the server, not localhost
// or 127.0.0.1
private static final String BASE_HOSTNAME = "192.168.43.14";
private static final String BASE_HOSTNAME = "172.17.193.69";
private static final String BASE_PORT = "8080";
private static final String BASE_URL = "http://" + BASE_HOSTNAME + ":" + BASE_PORT + "/Rest/";

Original file line number Diff line number Diff line change
@@ -45,6 +45,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
//noinspection SimplifiableIfStatement
if (id == R.id.action_refresh) {
// Implement the action here!
GetRestaurantsNearbyAsyncTask task = new GetRestaurantsNearbyAsyncTask();
task.execute("GetRestaurantsNearby");
fragment.getRestaurantListAdapter().notifyDataSetChanged();
return true;
} else if (id == R.id.action_location) {
switchToMapView(restaurant_loc);
@@ -77,6 +80,21 @@ private void switchToMapView(ArrayList<LatLng> restaurant_loc) {
// Store the locations of all restaurants.
private ArrayList<LatLng> restaurant_loc = new ArrayList<>();

class GetRestaurantsNearbyAsyncTask extends AsyncTask<String, Void, List<Restaurant>> {

@Override
protected List<Restaurant> doInBackground(String... params) {
return RestaurantApiClient.post(params);
}
// onPostExecute displays the results of the AsyncTask.
@Override
protected void onPostExecute(List<Restaurant> restaurants) {
super.onPostExecute(restaurants);
fragment.getRestaurantListAdapter().updateRestaurants(restaurants);
fragment.getRestaurantListAdapter().notifyDataSetChanged();
}
}

private class RecommendRestaurantsAsyncTask extends AsyncTask<String, Void, List<Restaurant>> {

@Override
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
}
}

private class GetRestaurantsNearbyAsyncTask extends AsyncTask<String, Void, List<Restaurant>> {
class GetRestaurantsNearbyAsyncTask extends AsyncTask<String, Void, List<Restaurant>> {

@Override
protected List<Restaurant> doInBackground(String... params) {

0 comments on commit c25fbeb

Please sign in to comment.