android - Unable to Create EndPoint with RxJava and Reterofit2 -
i following github link consume api using reterofit , rxjava while changing type call observer in interface class getting error message.
type 'java.util.observable' doesnot have type parameters
apiclient:
public class apiclient { public static final string base_url = "*********"; private static retrofit retrofit = null; public static retrofit getclient() { final okhttpclient okhttpclient = new okhttpclient.builder() .readtimeout(60, timeunit.seconds) .connecttimeout(60, timeunit.seconds) .build(); if (retrofit==null) { gson gson = new gsonbuilder() .setlenient() .create(); retrofit = new retrofit.builder() .addcalladapterfactory(rxjava2calladapterfactory.create()) .baseurl(base_url) .client(okhttpclient) .addconverterfactory(gsonconverterfactory.create(gson)) .build(); } return retrofit; } }
apiinterface
public interface apiinterface { @formurlencoded @post("user/get_user") observable<userresponse> getusers(@field("email") string email, @field("password") string password); }
userresponse:
public class userresponse { private list<user> result; private string status_message; private int status_code; public int getstatus_code() { return status_code; } public void setstatus_code(int status_code) { this.status_code = status_code; } public list<user> getresult() { return result; } public void setresult(list<user> result) { this.result = result; } public string getstatus_message() { return status_message; } public void setstatus_message(string status_message) { this.status_message = status_message; } }
dependencies:
compile 'io.reactivex.rxjava2:rxjava:2.0.1' compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
change import java.util.observable;
in code import io.reactivex.observable;
Comments
Post a Comment