Generic Recycler Adapter

Generic adapters for Android based on https://github.com/MaximeJallu/retrofit_factory

License

License

The Code Project Open License (CPOL) 1.02
GroupId

GroupId

com.github.maximejallu
ArtifactId

ArtifactId

factory
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

aar
Description

Description

Generic Recycler Adapter
Generic adapters for Android based on https://github.com/MaximeJallu/retrofit_factory
Project URL

Project URL

https://github.com/MaximeJallu/retrofit_factory
Source Code Management

Source Code Management

https://github.com/MaximeJallu/retrofit_factory

Download factory

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.maximejallu/factory/ -->
<dependency>
    <groupId>com.github.maximejallu</groupId>
    <artifactId>factory</artifactId>
    <version>1.0.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.maximejallu/factory/
implementation 'com.github.maximejallu:factory:1.0.0'
// https://jarcasting.com/artifacts/com.github.maximejallu/factory/
implementation ("com.github.maximejallu:factory:1.0.0")
'com.github.maximejallu:factory:aar:1.0.0'
<dependency org="com.github.maximejallu" name="factory" rev="1.0.0">
  <artifact name="factory" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.maximejallu', module='factory', version='1.0.0')
)
libraryDependencies += "com.github.maximejallu" % "factory" % "1.0.0"
[com.github.maximejallu/factory "1.0.0"]

Dependencies

compile (6)

Group / Artifact Type Version
com.squareup.okhttp3 : okhttp jar 3.9.0
com.squareup.okhttp3 : logging-interceptor jar 3.9.0
com.squareup.retrofit2 : retrofit jar 2.0.2
com.squareup.retrofit2 : converter-gson jar 2.0.2
com.squareup.retrofit2 : adapter-rxjava jar 2.0.2
com.android.support » appcompat-v7 jar 27.1.1

Project Modules

There are no modules declared in this project.

Status

alt text API

Generic-Factory for Retrofit:

This tool allows you to no longer worry about adapters. Now you will only create your ViewHolder. Communication management between your Views and your ViewHolders is possible. Creating sections is now very easily. Enjoy.

Download Maven Central

buildtool used is 27 use {exclude group: 'com.android.support'} only if you have problems

dependencies {
    ...
    implementation ('com.github.maximejallu:factory:{version}')
    ...
}

Init Factory

class ProviderModule {

    @Provides
    Gson provideTestGson() {
        return new GsonBuilder()
                .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
                .create();
    }

    @Provides
    OkHttpClient providesClientDefault(Gson gson){
        return new OkHttpBuilder().loggingLevel(BuildConfig.DEBUG).build();
    }

    @Provides
    OkHttpConfiguration providesClientHttpHelper(OkHttpClient client, Gson gson) {
        return new OkHttpConfiguration.Builder(client, GsonConverterFactory.create(gson))
                .registerCallAdapter(RxAdapterFactory.create(), "proxy_v3")
                .addApiKey("apiKey1", "fail111c-dc6d-4f4c-8adc-2fg9a90z249z")
                .addUrlConfiguration("proxy_v3", "https://apiproxy-v3.preprod.marque.net/")
                .build();
    }

    @Provides
    ApiFactory providesApiFactory(OkHttpConfiguration configuration) {
        return new ApiFactory(configuration);
    }
}

1- Create yours Services Interface with @nnotation

@ApiKeyService("apiKey1", "proxy_v3")
interface GeoDataService{
    @POST("...")
    Observable<Response> postObject(...);
}

@ApiKeyService("apiKey1", "http://base-url-service.net/api/")
interface GeoDataService2{
    @POST("...")
    Observable<Response> postObject(...);
}

Or Create yours Services Interface without annotation

interface GeoDataService3{
    @GET("...")
    Observable<Result> getObject(...);
}

2 - Provides Services

    @Provides
    @Singleton
    GeoDataService provideGeoDataService(ApiFactory factory) {
    /*if GeoDataService with annotation*/
    return factory.create(GeoDataService.class);    
    /*else create manually*/
    return factory.create(GeoDataService.class, /*tag: http client*/ "proxy_v3", "apiKey1");
    }

Versions

Version
1.0.0