-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventModule.java
More file actions
53 lines (42 loc) · 1.76 KB
/
EventModule.java
File metadata and controls
53 lines (42 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.tom.meeter;
import static com.tom.meeter.infrastructure.common.Globals.getServerPath;
import static com.tom.meeter.infrastructure.common.InfrastructureHelper.logMethod;
import android.app.Application;
import androidx.annotation.NonNull;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.tom.meeter.context.event.service.EventService;
import java.util.TimeZone;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
@Module
public class EventModule {
private static final String TAG = EventModule.class.getCanonicalName();
public EventModule() {
logMethod(TAG, this);
}
@Singleton
@NonNull
@Provides
public EventService provideEventService(Application app) {
return new Retrofit.Builder()
.baseUrl(getServerPath(app))
.addConverterFactory(JacksonConverterFactory.create(
JsonMapper.builder()
.addModule(new JavaTimeModule())
//.addModule(new Jdk8Module().configureReadAbsentAsNull(false))
.addModule(new Jdk8Module())
.serializationInclusion(JsonInclude.Include.NON_NULL)
.build()
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.setTimeZone(TimeZone.getDefault())))
.build()
.create(EventService.class);
}
}