Skip to content
/ rsm Public

Getting data from (Local) android assets file like retrofit.

Notifications You must be signed in to change notification settings

classops/rsm

Repository files navigation

Rsm

以类Retrofit的形式,获取Assets目录的数据。

使用方法

添加依赖

  1. 添加仓库到根build.gradle
    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
  2. 添加依赖
    dependencies {
        implementation 'com.github.wangmingshuo:rsm:0.1.3'
    }
初始化
Rsm.init(this);
Rsm.get().addCallAdapterFactory(RxJava2CallAdapterFactory.create());
Rsm.get().addCallAdapterFactory(ObjectCallAdapterFactory.create());
Rsm.get().addConverterFactory(GsonConverterFactory.create());
获取Assets目录数据

和Retrofit方法一样,先定义Service

public interface AssetService {

    @AssetName("test.json")
    List<TestBean> test();
}

调用方法

List<TestBean> list = Rsm.getInstance().create(AssetService.class).test();

支持RxJava2返回类型

public interface AssetService {

    @AssetName("test.json")
    Observable<List<TestBean>> testAsync();
}

About

Getting data from (Local) android assets file like retrofit.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages