我目前正在使用改造1.9,我有很多问题使用它,如我得到改造管道破坏错误和许多东西所以基本上现在我打算从1.9迁移到2.0但我很困惑,完全沮丧尝试不同的步骤来克服它 . 如果你能帮助我克服它,我将非常感谢你们 . 我有我的改装1.9代码发布和获取请求下面 . 请帮我改变我的代码的步骤
1>这是我目前唯一使用的1个改进依赖项编译'com.squareup.retrofit: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>我的改装助手课程
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您的帮助将更加感谢提前感谢:)
2 回答
编译:
创建界面:
创建类:
现在,在你的活动中:
public class JobsModel实现Serializable {
}