Search in sources :

Example 1 with ApacheBaseApi

use of de.geeksfactory.opacclient.apis.ApacheBaseApi in project opacclient by opacapp.

the class GetSearchFieldsCallable method call.

@Override
public Map<String, List<SearchField>> call() {
    OpacApi api = OpacApiFactory.create(lib, "OpacApp/Test");
    if (api instanceof ApacheBaseApi) {
        ((ApacheBaseApi) api).setHttpLoggingEnabled(false);
    }
    Set<String> langs = null;
    try {
        langs = api.getSupportedLanguages();
    } catch (IOException e) {
    }
    if (langs == null) {
        // Use default language
        try {
            Map<String, List<SearchField>> map = new HashMap<>();
            map.put("default", api.getSearchFields());
            return map;
        } catch (IOException | OpacErrorException | JSONException e) {
        }
    } else {
        Map<String, List<SearchField>> map = new HashMap<>();
        for (String lang : langs) {
            api.setLanguage(lang);
            try {
                map.put(lang, api.getSearchFields());
            } catch (IOException | OpacErrorException | JSONException e) {
            }
        }
        return map;
    }
    return null;
}
Also used : HashMap(java.util.HashMap) OpacApi(de.geeksfactory.opacclient.apis.OpacApi) JSONException(org.json.JSONException) List(java.util.List) OpacErrorException(de.geeksfactory.opacclient.apis.OpacApi.OpacErrorException) IOException(java.io.IOException) ApacheBaseApi(de.geeksfactory.opacclient.apis.ApacheBaseApi)

Example 2 with ApacheBaseApi

use of de.geeksfactory.opacclient.apis.ApacheBaseApi in project opacclient by opacapp.

the class CoverDownloadTask method getImage.

protected byte[] getImage() throws IOException {
    try {
        OpacApi api = ((OpacClient) context.getApplicationContext()).getApi();
        if (api instanceof ApacheBaseApi) {
            return getImageApacheClient(((ApacheBaseApi) api).http_client);
        } else if (api instanceof OkHttpBaseApi) {
            return getImageOkHttpClient(((OkHttpBaseApi) api).http_client);
        }
    } catch (OpacClient.LibraryRemovedException e) {
    }
    HttpClient httpClient;
    httpClient = new AndroidHttpClientFactory().getNewApacheHttpClient(false, true, false, false);
    return getImageApacheClient(httpClient);
}
Also used : OpacClient(de.geeksfactory.opacclient.OpacClient) OkHttpBaseApi(de.geeksfactory.opacclient.apis.OkHttpBaseApi) AndroidHttpClient(android.net.http.AndroidHttpClient) OkHttpClient(okhttp3.OkHttpClient) HttpClient(org.apache.http.client.HttpClient) OpacApi(de.geeksfactory.opacclient.apis.OpacApi) ApacheBaseApi(de.geeksfactory.opacclient.apis.ApacheBaseApi)

Aggregations

ApacheBaseApi (de.geeksfactory.opacclient.apis.ApacheBaseApi)2 OpacApi (de.geeksfactory.opacclient.apis.OpacApi)2 AndroidHttpClient (android.net.http.AndroidHttpClient)1 OpacClient (de.geeksfactory.opacclient.OpacClient)1 OkHttpBaseApi (de.geeksfactory.opacclient.apis.OkHttpBaseApi)1 OpacErrorException (de.geeksfactory.opacclient.apis.OpacApi.OpacErrorException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 OkHttpClient (okhttp3.OkHttpClient)1 HttpClient (org.apache.http.client.HttpClient)1 JSONException (org.json.JSONException)1