Skip to content

Instantly share code, notes, and snippets.

@moltak
Created February 9, 2015 04:51
Show Gist options
  • Save moltak/4347e6bd07fc383a09d7 to your computer and use it in GitHub Desktop.
Save moltak/4347e6bd07fc383a09d7 to your computer and use it in GitHub Desktop.
retrofit business logic for google place api
package com.limo.limo_passenger.rest.google.place.service;
import com.limo.limo_passenger.rest.google.place.model.PlaceSearchResponse;
import com.limo.limo_passenger.rest.google.place.PlaceApiRetrofitAdapterBuilder;
import com.limo.limo_passenger.rest.limo.LMCallback;
import com.limo.limo_passenger.rest.limo.LMNetworkBus;
import retrofit.RestAdapter;
import retrofit.client.Response;
import retrofit.http.GET;
import retrofit.http.Query;
/**
* Created by moltak on 2014. 10. 7..
*/
public class NearByPlaceSearch {
public static void search(String location, String types, String sensor, String key,
String language) {
RestAdapter restAdapter = PlaceApiRetrofitAdapterBuilder.getAdapter();
restAdapter.create(Request.class)
.search(location, types, key, language,
new LMCallback<PlaceSearchResponse>() {
@Override
public void success(PlaceSearchResponse placeSearchResult, Response response) {
LMNetworkBus.getInstance().post(placeSearchResult);
}
});
}
public interface Request {
@GET("/nearbysearch/json?sensor=true&rankby=distance")
public void search(
@Query("location") String location,
@Query("types") String types,
@Query("key") String key,
@Query("language") String language,
LMCallback<PlaceSearchResponse> callback);
}
public interface SyncRequest {
@GET("/nearbysearch/json?sensor=true&rankby=distance")
public PlaceSearchResponse search(
@Query("location") String location,
@Query("types") String types,
@Query("key") String key,
@Query("language") String language);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment