我目前正在使用翻新1.9,在那里我有很多问题使用它,像我得到翻新管道损坏的错误和许多东西,所以基本上现在我打算从1.9迁移到2.0,但我很困惑,完全沮丧尝试不同的步骤来完成它。如果你能帮我克服它,我会非常感谢你们。我有我的翻新1.9代码发布和获取请求下面。请帮助我的步骤来改变我的代码Android翻新:从翻新1.9迁移到翻新2.0的步骤
1>这是我唯一的当前正在使用的 编译1个改装依赖“com.squareup.retrofit:改造:1.9.0” 所以我该怎么变革依赖
2>我的改装接口后,让
@POST("/trinkingu/operations.php")
void createNewSeekerProfile(@Query("module") String module,
@Query("action") String action,
@Body SeekerProfileModel body, Callback<Response> callback);
@GET("/synkku/services.php")
void getAlljobPosts(@Query("module") String module,
@Query("action") String action,
@Query("key") String key,
@Query("value") String value, Callback<ArrayList<JobsModel>> response);
3>我的改造Helper类
public void addNewSeekerProfile(String module,String action,SeekerProfileModel seekerProfileModel) {
//Here we will handle the http request to insert user to mysql db
//Creating a RestAdapter
System.out.println("##coming here");
RestAdapter adapter = new RestAdapter.Builder()
.setEndpoint(Allconstants.MAIN_URL) //Setting the Root URL
.build(); //Finally building the adapter
//Creating object for our interface
RetroApiInterface api = adapter.create(RetroApiInterface.class);
//Defining the method insertuser of our interface
api.createNewSeekerProfile(
module,
action,
seekerProfileModel,
new Callback<Response>() {
@Override
public void success(Response response, Response response2) {
TypedInput body = response.getBody();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(body.in()));
StringBuilder out = new StringBuilder();
String newLine = System.getProperty("line.separator");
String line;
while ((line = reader.readLine()) != null) {
out.append(line);
out.append(newLine);
}
// Prints the correct String representation of body.
System.out.println(out);
Toast.makeText(mContext,"result"+out,Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void failure(RetrofitError error) {
Toast.makeText(mContext,"error"+error.toString(),Toast.LENGTH_LONG).show();
error.printStackTrace();
}
}
);
}
这里是得到
public void getAllMyPostedJobs(String inputKey, String inputValue) {
//While the app fetched data we are displaying a progress dialog
//Creating a rest adapter
RestAdapter adapter = new RestAdapter.Builder()
.setEndpoint(Allconstants.MAIN_URL)
.build();
//Creating an object of our api interface
RetroApiInterface api = adapter.create(RetroApiInterface.class);
api.getAlljobPosts(Allconstants.JOBS, Allconstants.ACTION_GET_ALL_MY_POSTEDJOBS, inputKey, inputValue, new Callback<ArrayList<JobsModel>>() {
@Override
public void success(ArrayList<JobsModel> jobsModels, Response response) {
if (mResultCallback != null)
mResultCallback.notifySuccess(jobsModels, response);
System.out.println("###successfull ");
}
@Override
public void failure(RetrofitError error) {
if (mResultCallback != null)
mResultCallback.notifyError(error);
}
});
}
请帮助我作出改变,现在序迁移到2.0 你的帮助会更感谢提前:)
我给你所有的代码。一旦我的笔记本电脑可用。直到然后改变依赖才能编译'com.squareup.retrofit2:retrofit:2.1.0' –
需要多少时间? @Divyesh –
只需10分钟,我有笔记本电脑。我正在做。 –