Skip to content

Commit

Permalink
fixed the configuration for android / retrofit
Browse files Browse the repository at this point in the history
  • Loading branch information
egandro committed Jul 1, 2017
1 parent a983479 commit c915683
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

nicassa-generator is a CLI toolkit for creating source code.

You require parsers such as nicassa-db-parser or nicassa-parser-ts-express-api
You require parsers such as nicassa-db-parser or tsoa / swagger

## Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import retrofit2.converter.scalars.ScalarsConverterFactory;

public class Configuration {
public static Retrofit getConnection(String baseUrl, HashMap<String, String> headers) {
OkHttpClient client = new OkHttpClient.Builder()
.build();
OkHttpClient.Builder builder = new OkHttpClient.Builder();

addHeaders(client, headers);
addHeaders(builder, headers);
OkHttpClient client = builder.build();

Retrofit result = new Retrofit.Builder()
.addConverterFactory(ScalarsConverterFactory.create())
Expand All @@ -44,7 +44,7 @@ public class Configuration {
return getConnection(baseUrl, timeout, timeout, headers);
}

public static void addHeaders(OkHttpClient client, HashMap<String, String> customHeaders) {
public static void addHeaders(OkHttpClient.Builder builder, HashMap<String, String> customHeaders) {
final HashMap<String, String> headers = new HashMap<>();

headers.put("Content-Type", "application/json");
Expand All @@ -68,7 +68,7 @@ public class Configuration {
}
}

client.networkInterceptors().add(new Interceptor() {
builder.networkInterceptors().add(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
final Request.Builder builder = chain.request().newBuilder();
Expand All @@ -85,13 +85,14 @@ public class Configuration {

public static Retrofit getConnection(String baseUrl, int connectTimeout, int readWriteTimeout,
HashMap<String, String> headers) {
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(connectTimeout, TimeUnit.SECONDS)
.writeTimeout(readWriteTimeout, TimeUnit.SECONDS)
.readTimeout(readWriteTimeout, TimeUnit.SECONDS)
.build();

addHeaders(client, headers);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.connectTimeout(connectTimeout, TimeUnit.SECONDS)
.writeTimeout(readWriteTimeout, TimeUnit.SECONDS)
.readTimeout(readWriteTimeout, TimeUnit.SECONDS);

addHeaders(builder, headers);
OkHttpClient client = builder.build();

Retrofit result = new Retrofit.Builder()
.addConverterFactory(ScalarsConverterFactory.create())
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nicassa-generator",
"description": "CLI based code generator for Sequelize, Node, Typescript, Angular 2, Android, Swagger, ORM Lite",
"version": "0.0.32",
"version": "0.0.33",
"author": "Harald Fielker <harald.fielker@gmail.com>",
"repository": {
"type": "git",
Expand Down

0 comments on commit c915683

Please sign in to comment.