将参数发送到订阅 CompositeDisposable 的方法 - Android?

Send parameter to method's of subscribe CompositeDisposable - Android?

我从 rx 使用 retrofit 连接到 service,波纹管是 RetrofitApi.java :

public class RetrofitApi {
    private static PublicApi retrofit = null;

    public static PublicApi getClient(String url) {
        retrofit = new Retrofit.Builder()
                .baseUrl(url)
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build().create(PublicApi.class);
        return retrofit;
    }
}

这里是 PublicApi.java :

public interface PublicApi {
    @GET("/web_service/mobile/rest")
    Observable<LastNews> lastNews(@Query("function") String function);
}

下面我正在连接到我的服务:

@Override
public void fetchLastNewsStartPage(RemoteDataSource.ResultListener<List<LastNews>> resultListener) {
    PublicApi publicApi = RetrofitApi.getClient("https://xxx.xxx.xxx/web_service/");
    CompositeDisposable mCompositeDisposable = new CompositeDisposable();
    mCompositeDisposable.add(publicApi.lastNews("getLastNews")
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.io())
            .subscribe(this::handleResponse, this::handleError));
}

我的问题是,如何将参数发送到handleResponsehandleError。我需要将此 RemoteDataSource.ResultListener<List<LastNews>> resultListener 发送到 handleResponsehandleError:

private void handleResponse(LastNews lastNewses) {

}


private void handleError(Throwable error) {

}

只是不要使用方法引用,因为它只能接受一个参数。您可以使用 lambda 表达式实现结果。而不是

this::handleResponse

lastNews -> handleResponse(lastNews, resultListener)