Search in sources :

Example 1 with ConfigurationModel

use of org.hisp.dhis.android.core.configuration.ConfigurationModel in project dhis2-android-sdk by dhis2.

the class D2Factory method create.

public static D2 create(String url, DatabaseAdapter databaseAdapter) {
    ConfigurationModel config = ConfigurationModel.builder().serverUrl(HttpUrl.parse(url)).build();
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
    return new D2.Builder().configuration(config).databaseAdapter(databaseAdapter).okHttpClient(new OkHttpClient.Builder().addInterceptor(BasicAuthenticatorFactory.create(databaseAdapter)).addInterceptor(loggingInterceptor).build()).build();
}
Also used : ConfigurationModel(org.hisp.dhis.android.core.configuration.ConfigurationModel) OkHttpClient(okhttp3.OkHttpClient) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor)

Example 2 with ConfigurationModel

use of org.hisp.dhis.android.core.configuration.ConfigurationModel in project dhis2-android-sdk by dhis2.

the class DataBaseMigrationShould method buildD2.

private void buildD2(DatabaseAdapter databaseAdapter) {
    ConfigurationModel config = ConfigurationModel.builder().serverUrl(mockWebServer.url("/")).build();
    d2 = new D2.Builder().configuration(config).okHttpClient(new OkHttpClient.Builder().addInterceptor(BasicAuthenticatorFactory.create(databaseAdapter)).build()).databaseAdapter(databaseAdapter).build();
}
Also used : ConfigurationModel(org.hisp.dhis.android.core.configuration.ConfigurationModel) D2(org.hisp.dhis.android.core.D2)

Aggregations

ConfigurationModel (org.hisp.dhis.android.core.configuration.ConfigurationModel)2 OkHttpClient (okhttp3.OkHttpClient)1 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)1 D2 (org.hisp.dhis.android.core.D2)1