|
20 | 20 | */ |
21 | 21 | public abstract class MapboxService<T> { |
22 | 22 |
|
23 | | - private boolean enableDebug = false; |
| 23 | + private boolean enableDebug = false; |
24 | 24 |
|
25 | | - public abstract Response<T> executeCall() throws IOException; |
| 25 | + public abstract Response<T> executeCall() throws IOException; |
26 | 26 |
|
27 | | - public abstract void enqueueCall(Callback<T> callback); |
| 27 | + public abstract void enqueueCall(Callback<T> callback); |
28 | 28 |
|
29 | | - public abstract void cancelCall(); |
| 29 | + public abstract void cancelCall(); |
30 | 30 |
|
31 | | - public abstract Call<T> cloneCall(); |
| 31 | + public abstract Call<T> cloneCall(); |
32 | 32 |
|
33 | | - public boolean isEnableDebug() { |
34 | | - return enableDebug; |
35 | | - } |
| 33 | + public boolean isEnableDebug() { |
| 34 | + return enableDebug; |
| 35 | + } |
36 | 36 |
|
37 | | - public void setEnableDebug(boolean enableDebug) { |
38 | | - this.enableDebug = enableDebug; |
39 | | - } |
| 37 | + public void setEnableDebug(boolean enableDebug) { |
| 38 | + this.enableDebug = enableDebug; |
| 39 | + } |
40 | 40 |
|
41 | | - /** |
42 | | - * Used Internally. |
43 | | - * |
44 | | - * @return OkHttpClient |
45 | | - * @since 1.0.0 |
46 | | - */ |
47 | | - public OkHttpClient getOkHttpClient() { |
48 | | - if (isEnableDebug()) { |
49 | | - HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); |
50 | | - logging.setLevel(HttpLoggingInterceptor.Level.BASIC); |
51 | | - OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); |
52 | | - httpClient.addInterceptor(logging); |
53 | | - return httpClient.build(); |
54 | | - } else { |
55 | | - return new OkHttpClient(); |
56 | | - } |
| 41 | + /** |
| 42 | + * Used Internally. |
| 43 | + * |
| 44 | + * @return OkHttpClient |
| 45 | + * @since 1.0.0 |
| 46 | + */ |
| 47 | + public OkHttpClient getOkHttpClient() { |
| 48 | + if (isEnableDebug()) { |
| 49 | + HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); |
| 50 | + logging.setLevel(HttpLoggingInterceptor.Level.BASIC); |
| 51 | + OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); |
| 52 | + httpClient.addInterceptor(logging); |
| 53 | + return httpClient.build(); |
| 54 | + } else { |
| 55 | + return new OkHttpClient(); |
57 | 56 | } |
| 57 | + } |
58 | 58 |
|
59 | | - /** |
60 | | - * Computes a full user agent header of the form: MapboxJava/1.2.0 Mac OS X/10.11.5 (x86_64) |
61 | | - * |
62 | | - * @return {@link String} |
63 | | - * @since 1.0.0 |
64 | | - */ |
65 | | - public static String getHeaderUserAgent() { |
66 | | - String osName; |
67 | | - String osVersion; |
68 | | - String osArch; |
| 59 | + /** |
| 60 | + * Computes a full user agent header of the form: MapboxJava/1.2.0 Mac OS X/10.11.5 (x86_64) |
| 61 | + * |
| 62 | + * @return {@link String} |
| 63 | + * @since 1.0.0 |
| 64 | + */ |
| 65 | + public static String getHeaderUserAgent() { |
| 66 | + String osName; |
| 67 | + String osVersion; |
| 68 | + String osArch; |
69 | 69 |
|
70 | | - try { |
71 | | - osName = System.getProperty("os.name"); |
72 | | - osVersion = System.getProperty("os.version"); |
73 | | - osArch = System.getProperty("os.arch"); |
74 | | - } catch (Exception e) { |
75 | | - return Constants.HEADER_USER_AGENT; |
76 | | - } |
| 70 | + try { |
| 71 | + osName = System.getProperty("os.name"); |
| 72 | + osVersion = System.getProperty("os.version"); |
| 73 | + osArch = System.getProperty("os.arch"); |
| 74 | + } catch (Exception exception) { |
| 75 | + return Constants.HEADER_USER_AGENT; |
| 76 | + } |
77 | 77 |
|
78 | | - if (TextUtils.isEmpty(osName) || TextUtils.isEmpty(osVersion) || TextUtils.isEmpty(osArch)) { |
79 | | - return Constants.HEADER_USER_AGENT; |
80 | | - } else { |
81 | | - String osInfo = String.format(Locale.US, "%s/%s (%s)", osName, osVersion, osArch); |
82 | | - return String.format(Locale.US, "%s %s", Constants.HEADER_USER_AGENT, osInfo); |
83 | | - } |
| 78 | + if (TextUtils.isEmpty(osName) || TextUtils.isEmpty(osVersion) || TextUtils.isEmpty(osArch)) { |
| 79 | + return Constants.HEADER_USER_AGENT; |
| 80 | + } else { |
| 81 | + String osInfo = String.format(Locale.US, "%s/%s (%s)", osName, osVersion, osArch); |
| 82 | + return String.format(Locale.US, "%s %s", Constants.HEADER_USER_AGENT, osInfo); |
84 | 83 | } |
| 84 | + } |
85 | 85 | } |
0 commit comments