Search in sources :

Example 6 with MapApi

use of com.fanap.podchat.networking.api.MapApi 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

MapApi (com.fanap.podchat.networking.api.MapApi)6 RetrofitHelperMap (com.fanap.podchat.networking.retrofithelper.RetrofitHelperMap)6 ChatResponse (com.fanap.podchat.model.ChatResponse)5 Response (retrofit2.Response)4 PodChatException (com.fanap.podchat.util.PodChatException)3 IOException (java.io.IOException)3 JSONException (org.json.JSONException)3 Bitmap (android.graphics.Bitmap)2 Uri (android.net.Uri)2 ResultDownloadFile (com.fanap.podchat.chat.file_manager.download_file.model.ResultDownloadFile)2 MapRout (com.fanap.podchat.mainmodel.MapRout)2 MetaDataFile (com.fanap.podchat.model.MetaDataFile)2 OutPutMapRout (com.fanap.podchat.model.OutPutMapRout)2 ResultFile (com.fanap.podchat.model.ResultFile)2 ResultImageFile (com.fanap.podchat.model.ResultImageFile)2 ResultStaticMapImage (com.fanap.podchat.model.ResultStaticMapImage)2 ProgressResponseBody (com.fanap.podchat.networking.ProgressResponseBody)2 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)2 RequestCreateThreadWithFile (com.fanap.podchat.requestobject.RequestCreateThreadWithFile)2 RequestGetFile (com.fanap.podchat.requestobject.RequestGetFile)2