prof18 / RSS-Parser

A Kotlin Multiplatform library to parse a RSS Feed
Apache License 2.0
513 stars 129 forks source link

OkHttpClient setter or constructor #43

Closed FriedrichM closed 5 years ago

FriedrichM commented 5 years ago

Hi, Great library you've made there. I am using it on my app with minsdk 17, which makes default tlsv1.2 support a bit of a pain. It would be great, if there was a way to set a custom OkHttpClient for the library to be used. I would do a pull request but i dont know Kotlin :( But i think its not that hard of a feature to implement. Just make the constructor take an OkHttpClient instance as an argument or do a setter for the client. I've done it in java and it wokrs fine .

`

private OkHttpClient myclient;
private OnTaskCompleted onComplete;
public Parser() {
    xmlParser = new XMLParser();
    xmlParser.addObserver(this);
}
public Parser(OkHttpClient client) {
    this.myclient = client;
    xmlParser = new XMLParser();
    xmlParser.addObserver(this);
}
public interface OnTaskCompleted {
    void onTaskCompleted(ArrayList<com.prof.rssparser.Article> list);

    void onError(Exception exception);
}
public void onFinish(OnTaskCompleted onComplete) {
    this.onComplete = onComplete;
}
@Override
protected String doInBackground(String... ulr) {
    Response response = null;
    OkHttpClient client = null;
    if(myclient!=null)
        client=myclient;
    else
        client=new OkHttpClient();
    Request request = new Request.Builder()`
prof18 commented 5 years ago

Thanks for sharing, it's definitely an improvement to do.

prof18 commented 5 years ago

Fixed with release 2.0.5