Search in sources :

Example 1 with MapNeshan

use of com.fanap.podchat.mainmodel.MapNeshan in project pod-chat-android-sdk by FanapSoft.

the class MapManager method searchMap.

public static Observable<OutPutMapNeshan> searchMap(String apiKey, String api, String searchTerm, double latitude, double longitude) {
    return Observable.create(subscriber -> {
        RetrofitHelperMap retrofitHelperMap = new RetrofitHelperMap(api);
        MapApi mapApi = retrofitHelperMap.getService(MapApi.class);
        Observable<Response<MapNeshan>> observable = mapApi.mapSearch(apiKey, searchTerm, latitude, longitude);
        observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(mapNeshanResponse -> {
            OutPutMapNeshan outPutMapNeshan = new OutPutMapNeshan();
            if (mapNeshanResponse.isSuccessful()) {
                MapNeshan mapNeshan = mapNeshanResponse.body();
                if (mapNeshan == null) {
                    subscriber.onError(new PodChatException(mapNeshanResponse.message(), mapNeshanResponse.code()));
                    return;
                }
                outPutMapNeshan = new OutPutMapNeshan();
                outPutMapNeshan.setCount(mapNeshan.getCount());
                ResultMap resultMap = new ResultMap();
                resultMap.setMaps(mapNeshan.getItems());
                outPutMapNeshan.setResult(resultMap);
                subscriber.onNext(outPutMapNeshan);
            } else {
                subscriber.onError(new PodChatException(mapNeshanResponse.message(), mapNeshanResponse.code()));
            }
        }, subscriber::onError);
    });
}
Also used : RetrofitHelperMap(com.fanap.podchat.networking.retrofithelper.RetrofitHelperMap) Response(retrofit2.Response) MapApi(com.fanap.podchat.networking.api.MapApi) ResultMap(com.fanap.podchat.model.ResultMap) PodChatException(com.fanap.podchat.util.PodChatException) MapNeshan(com.fanap.podchat.mainmodel.MapNeshan) OutPutMapNeshan(com.fanap.podchat.model.OutPutMapNeshan) OutPutMapNeshan(com.fanap.podchat.model.OutPutMapNeshan)

Aggregations

MapNeshan (com.fanap.podchat.mainmodel.MapNeshan)1 OutPutMapNeshan (com.fanap.podchat.model.OutPutMapNeshan)1 ResultMap (com.fanap.podchat.model.ResultMap)1 MapApi (com.fanap.podchat.networking.api.MapApi)1 RetrofitHelperMap (com.fanap.podchat.networking.retrofithelper.RetrofitHelperMap)1 PodChatException (com.fanap.podchat.util.PodChatException)1 Response (retrofit2.Response)1