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

Viewed 598

I am using from rx for connect to service with retrofit, bellow is 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;
    }
}

And here is PublicApi.java :

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

Bellow I am connecting to my service :

@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));
}

My problem is here, how can I send parameter to handleResponse and handleError. I need to send this RemoteDataSource.ResultListener<List<LastNews>> resultListener to handleResponse and handleError:

private void handleResponse(LastNews lastNewses) {

}


private void handleError(Throwable error) {

}
1 Answers
Related