Android改型:从改型1.9迁移到改型2.0的步骤

Android改型:从改型1.9迁移到改型2.0的步骤,android,android-volley,retrofit,retrofit2,asynccallback,Android,Android Volley,Retrofit,Retrofit2,Asynccallback,我目前使用的是翻新1.9,我在使用它的时候遇到了很多问题,比如我遇到了翻新管道断裂的错误和很多东西,所以基本上现在我正计划从1.9迁移到2.0,但是我很困惑,并且完全受挫于尝试不同的步骤来解决它。如果你们能帮助我克服困难,我将非常感谢你们。我有我的改装1.9的邮政编码,并得到以下要求。请帮助我更改代码的步骤 1> 这是我目前使用的唯一1个改装依赖项 编译'com.squareup.Reformation:Reformation:1.9.0' 那么,对于依赖项,我应该做哪些更改 2> 我的post

我目前使用的是翻新1.9,我在使用它的时候遇到了很多问题,比如我遇到了翻新管道断裂的错误和很多东西,所以基本上现在我正计划从1.9迁移到2.0,但是我很困惑,并且完全受挫于尝试不同的步骤来解决它。如果你们能帮助我克服困难,我将非常感谢你们。我有我的改装1.9的邮政编码,并得到以下要求。请帮助我更改代码的步骤

1> 这是我目前使用的唯一1个改装依赖项 编译'com.squareup.Reformation:Reformation:1.9.0' 那么,对于依赖项,我应该做哪些更改

2> 我的post和get改造界面

 @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);
@POST(“/trinkingu/operations.php”)
void createNewSeekerProfile(@Query(“module”)字符串模块,
@查询(“操作”)字符串操作,
@Body SeekerProfileModel Body,回调);
@获取(“/synkku/services.php”)
void getAlljobPosts(@Query(“module”)字符串模块,
@查询(“操作”)字符串操作,
@查询(“键”)字符串键,
@查询(“值”)字符串值,回调响应);
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 addNewSeekerProfile(字符串模块、字符串操作、SeekerProfileModel SeekerProfileModel){
//这里我们将处理将用户插入mysql数据库的http请求
//创建重新适应程序
System.out.println(“过来”);
RestAdapter adapter=new RestAdapter.Builder()
.setEndpoint(Allconstants.MAIN\u URL)//设置根URL
.build();//最终生成适配器
//为我们的接口创建对象
RetroApiInterface api=adapter.create(RetroApiInterface.class);
//定义接口的插入器方法
api.createNewSeekerProfile(
模块,
行动,
seekerProfileModel,
新回调函数(){
@凌驾
公共无效成功(响应,响应2){
TypedInput body=response.getBody();
试一试{
BufferedReader=新的BufferedReader(新的InputStreamReader(body.in());
StringBuilder out=新的StringBuilder();
字符串newLine=System.getProperty(“line.separator”);
弦线;
而((line=reader.readLine())!=null){
out.追加(行);
out.append(换行符);
}
//打印正文的正确字符串表示形式。
System.out.println(out);
Toast.makeText(mContext,“result”+out,Toast.LENGTH_SHORT.show();
}捕获(IOE异常){
e、 printStackTrace();
}
}
@凌驾
公共无效失败(错误){
Toast.makeText(mContext,“error”+error.toString(),Toast.LENGTH_LONG.show();
错误。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);
            }
        });
    }
public void getAllMyPostedJobs(String inputKey,String inputValue){
//当应用程序获取数据时,我们将显示一个进度对话框
//创建rest适配器
RestAdapter adapter=new RestAdapter.Builder()
.setEndpoint(Allconstants.MAIN_URL)
.build();
//创建api接口的对象
RetroApiInterface api=adapter.create(RetroApiInterface.class);
api.getAlljobPosts(Allconstants.JOBS,Allconstants.ACTION\u GET\u ALL\u MY\u POSTEDJOBS,inputKey,inputValue,new Callback(){
@凌驾
public void成功(ArrayList作业模型、响应){
if(mResultCallback!=null)
mResultCallback.notifySuccess(作业模型,响应);
System.out.println(“成功”);
}
@凌驾
公共无效失败(错误){
if(mResultCallback!=null)
mResultCallback.notifyError(错误);
}
});
}
为了迁移到2.0,请帮助我现在进行更改 你的帮助将不胜感激 提前感谢:)

编译:

compile 'com.squareup.retrofit2:retrofit:2.1.0'
创建接口:

public interface ItemAPI {

@GET("/synkku/services.php")
call<JobsModel>  getAlljobPosts(@Query("module") String module,
                    @Query("action") String action,
                    @Query("key") String key,
                    @Query("value") String value);

                    }
现在,在您的活动中:

ItemAPI itemAPI = Apiclient.getClient().create(ItemAPI.class);
Call<JobsModel> call=itemAPI.getAlljobPosts(Allconstants.JOBS, Allconstants.ACTION_GET_ALL_MY_POSTEDJOBS, inputKey, inputValue);

call.enqueue(new Callback<JobsModel>() {
    @Override
    public void onResponse(Call<JobsModel> call, Response<JobsModel> response) {
        try {
            HERE YOU CAN GET JoBSModel VIA RESPONSE.BODY."your model method name"
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public void onFailedAfterRetry(Throwable t) {

    }
});
ItemAPI ItemAPI=Apiclient.getClient().create(ItemAPI.class);
Call Call=itemAPI.getAlljobPosts(Allconstants.JOBS,Allconstants.ACTION\u GET\u ALL\u MY\u POSTEDJOBS,inputKey,inputValue);
call.enqueue(新回调(){
@凌驾
公共void onResponse(调用、响应){
试一试{
在这里,您可以通过RESPONSE.BODY获得JoBSModel。“您的模型方法名称”
}捕获(例外e){
e、 printStackTrace();
}
}
@凌驾
重试后失败的公共无效(可丢弃的t){
}
});
编译:

compile 'com.squareup.retrofit2:retrofit:2.1.0'
创建接口:

public interface ItemAPI {

@GET("/synkku/services.php")
call<JobsModel>  getAlljobPosts(@Query("module") String module,
                    @Query("action") String action,
                    @Query("key") String key,
                    @Query("value") String value);

                    }
现在,在您的活动中:

ItemAPI itemAPI = Apiclient.getClient().create(ItemAPI.class);
Call<JobsModel> call=itemAPI.getAlljobPosts(Allconstants.JOBS, Allconstants.ACTION_GET_ALL_MY_POSTEDJOBS, inputKey, inputValue);

call.enqueue(new Callback<JobsModel>() {
    @Override
    public void onResponse(Call<JobsModel> call, Response<JobsModel> response) {
        try {
            HERE YOU CAN GET JoBSModel VIA RESPONSE.BODY."your model method name"
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public void onFailedAfterRetry(Throwable t) {

    }
});
ItemAPI ItemAPI=Apiclient.getClient().create(ItemAPI.class);
Call Call=itemAPI.getAlljobPosts(Allconstants.JOBS,Allconstants.ACTION\u GET\u ALL\u MY\u POSTEDJOBS,inputKey,inputValue);
call.enqueue(新回调(){
@凌驾
公共void onResponse(调用、响应){
试一试{
在这里,您可以通过RESPONSE.BODY获得JoBSModel。“您的模型方法名称”
}捕获(例外e){
e、 printStackTrace();
}
}
@凌驾
重试后失败的公共无效(可丢弃的t){
}
});

公共类JobsModel实现可序列化{

@SerializedName("_id")
private String _id = null;
@SerializedName("posted_by")
private String userId = null;
@SerializedName("company_name")
private String companyName = null;
@SerializedName("position")
private String position = null;
@SerializedName("eligiblity")
private String eligiblity = null;
@SerializedName("experience")
private String experience = null;
@SerializedName("interview_from_date")
private String interviewFromDate = null;
@SerializedName("interview_to_date")
private String interviewToDate = null;
@SerializedName("interview_frm_timing")
private String interviewTimeFrom = null;
@SerializedName("interview_to_timing")
private String interviewTimeTo = null;
@SerializedName("describtion")
private String desc = null;
@SerializedName("skills")
private String skills = null;
@SerializedName("interview_location")
private String interviewLocation = null;
@SerializedName("interview_lat")
private float lat;
@SerializedName("interview_lon")
private float lon;
@SerializedName("contact_person")
private String contactPerson = null;
@SerializedName("contact_phone")
private String contactPhone = null;
@SerializedName("contact_email")
private String contactMail = null;
@SerializedName("total_vocancies")
private int totalVocancies;
@SerializedName("posted_on")
private String postedOn;
@SerializedName("currently_active")
private String currently_active;
@SerializedName("sal_pckg")
private String salPckg;

public JobsModel(String _id, String userId, String companyName, String position, String eligiblity,
                 String experience, String interviewFromDate, String interviewToDate, String interviewTimeFrom, String interviewTimeTo,
                 String desc, String skills, String interviewLocation,
                 String contactPerson, String contactPhone, String contactMail, int totalVocancies, String postedOn, String isActive,String salPckg) {
    this._id=_id;
    this.userId = userId;
    this.companyName = companyName;
    this.position = position;
    this.eligiblity = eligiblity;
    this.experience = experience;
    this.interviewFromDate = interviewFromDate;
    this.interviewToDate = interviewToDate;
    this.interviewTimeFrom = interviewTimeFrom;
    this.interviewTimeTo = interviewTimeTo;
    this.desc = desc;
    this.skills = skills;
    this.interviewLocation = interviewLocation;
    this.contactPerson = contactPerson;
    this.contactPhone = contactPhone;
    this.contactMail = contactMail;
    this.totalVocancies = totalVocancies;
    this.postedOn=postedOn;
    this.currently_active =isActive;
    this.salPckg=salPckg;
}

public String getSalPckg() {
    return salPckg;
}

public void setSalPckg(String salPckg) {
    this.salPckg = salPckg;
}

public String get_id() {
    return _id;
}

public void set_id(String _id) {
    this._id = _id;
}

public String getUserId() {
    return userId;
}

public void setUserId(String userId) {
    this.userId = userId;
}

public String getCompanyName() {
    return companyName;
}

public void setCompanyName(String companyName) {
    this.companyName = companyName;
}

public String getPosition() {
    return position;
}

public void setPosition(String position) {
    this.position = position;
}

public String getEligiblity() {
    return eligiblity;
}

public void setEligiblity(String eligiblity) {
    this.eligiblity = eligiblity;
}

public String getExperience() {
    return experience;
}

public void setExperience(String experience) {
    this.experience = experience;
}

public String getInterviewFromDate() {
    return interviewFromDate;
}

public void setInterviewFromDate(String interviewFromDate) {
    this.interviewFromDate = interviewFromDate;
}

public String getInterviewToDate() {
    return interviewToDate;
}

public void setInterviewToDate(String interviewToDate) {
    this.interviewToDate = interviewToDate;
}

public String getInterviewTimeFrom() {
    return interviewTimeFrom;
}

public void setInterviewTimeFrom(String interviewTimeFrom) {
    this.interviewTimeFrom = interviewTimeFrom;
}

public String getInterviewTimeTo() {
    return interviewTimeTo;
}

public void setInterviewTimeTo(String interviewTimeTo) {
    this.interviewTimeTo = interviewTimeTo;
}

public String getDesc() {
    return desc;
}

public void setDesc(String desc) {
    this.desc = desc;
}

public String getSkills() {
    return skills;
}

public void setSkills(String skills) {
    this.skills = skills;
}

public String getInterviewLocation() {
    return interviewLocation;
}

public void setInterviewLocation(String interviewLocation) {
    this.interviewLocation = interviewLocation;
}

public float getLat() {
    return lat;
}

public void setLat(float lat) {
    this.lat = lat;
}

public float getLon() {
    return lon;
}

public void setLon(float lon) {
    this.lon = lon;
}

public String getContactPerson() {
    return contactPerson;
}

public void setContactPerson(String contactPerson) {
    this.contactPerson = contactPerson;
}

public String getContactPhone() {
    return contactPhone;
}

public void setContactPhone(String contactPhone) {
    this.contactPhone = contactPhone;
}

public String getContactMail() {
    return contactMail;
}

public void setContactMail(String contactMail) {
    this.contactMail = contactMail;
}

public int getTotalVocancies() {
    return totalVocancies;
}

public void setTotalVocancies(int totalVocancies) {
    this.totalVocancies = totalVocancies;
}

public String getPostedOn() {
    return postedOn;
}

public void setPostedOn(String postedOn) {
    this.postedOn = postedOn;
}

public String getCurrently_active() {
    return currently_active;
}

public void setCurrently_active(String currently_active) {
    this.currently_active = currently_active;
}

}

公共类作业模型实现可序列化{

@SerializedName("_id")
private String _id = null;
@SerializedName("posted_by")
private String userId = null;
@SerializedName("company_name")
private String companyName = null;
@SerializedName("position")
private String position = null;
@SerializedName("eligiblity")
private String eligiblity = null;
@SerializedName("experience")
private String experience = null;
@SerializedName("interview_from_date")
private String interviewFromDate = null;
@SerializedName("interview_to_date")
private String interviewToDate = null;
@SerializedName("interview_frm_timing")
private String interviewTimeFrom = null;
@SerializedName("interview_to_timing")
private String interviewTimeTo = null;
@SerializedName("describtion")
private String desc = null;
@SerializedName("skills")
private String skills = null;
@SerializedName("interview_location")
private String interviewLocation = null;
@SerializedName("interview_lat")
private float lat;
@SerializedName("interview_lon")
private float lon;
@SerializedName("contact_person")
private String contactPerson = null;
@SerializedName("contact_phone")
private String contactPhone = null;
@SerializedName("contact_email")
private String contactMail = null;
@SerializedName("total_vocancies")
private int totalVocancies;
@SerializedName("posted_on")
private String postedOn;
@SerializedName("currently_active")
private String currently_active;
@SerializedName("sal_pckg")
private String salPckg;

public JobsModel(String _id, String userId, String companyName, String position, String eligiblity,
                 String experience, String interviewFromDate, String interviewToDate, String interviewTimeFrom, String interviewTimeTo,
                 String desc, String skills, String interviewLocation,
                 String contactPerson, String contactPhone, String contactMail, int totalVocancies, String postedOn, String isActive,String salPckg) {
    this._id=_id;
    this.userId = userId;
    this.companyName = companyName;
    this.position = position;
    this.eligiblity = eligiblity;
    this.experience = experience;
    this.interviewFromDate = interviewFromDate;
    this.interviewToDate = interviewToDate;
    this.interviewTimeFrom = interviewTimeFrom;
    this.interviewTimeTo = interviewTimeTo;
    this.desc = desc;
    this.skills = skills;
    this.interviewLocation = interviewLocation;
    this.contactPerson = contactPerson;
    this.contactPhone = contactPhone;
    this.contactMail = contactMail;
    this.totalVocancies = totalVocancies;
    this.postedOn=postedOn;
    this.currently_active =isActive;
    this.salPckg=salPckg;
}

public String getSalPckg() {
    return salPckg;
}

public void setSalPckg(String salPckg) {
    this.salPckg = salPckg;
}

public String get_id() {
    return _id;
}

public void set_id(String _id) {
    this._id = _id;
}

public String getUserId() {
    return userId;
}

public void setUserId(String userId) {
    this.userId = userId;
}

public String getCompanyName() {
    return companyName;
}

public void setCompanyName(String companyName) {
    this.companyName = companyName;
}

public String getPosition() {
    return position;
}

public void setPosition(String position) {
    this.position = position;
}

public String getEligiblity() {
    return eligiblity;
}

public void setEligiblity(String eligiblity) {
    this.eligiblity = eligiblity;
}

public String getExperience() {
    return experience;
}

public void setExperience(String experience) {
    this.experience = experience;
}

public String getInterviewFromDate() {
    return interviewFromDate;
}

public void setInterviewFromDate(String interviewFromDate) {
    this.interviewFromDate = interviewFromDate;
}

public String getInterviewToDate() {
    return interviewToDate;
}

public void setInterviewToDate(String interviewToDate) {
    this.interviewToDate = interviewToDate;
}

public String getInterviewTimeFrom() {
    return interviewTimeFrom;
}

public void setInterviewTimeFrom(String interviewTimeFrom) {
    this.interviewTimeFrom = interviewTimeFrom;
}

public String getInterviewTimeTo() {
    return interviewTimeTo;
}

public void setInterviewTimeTo(String interviewTimeTo) {
    this.interviewTimeTo = interviewTimeTo;
}

public String getDesc() {
    return desc;
}

public void setDesc(String desc) {
    this.desc = desc;
}

public String getSkills() {
    return skills;
}

public void setSkills(String skills) {
    this.skills = skills;
}

public String getInterviewLocation() {
    return interviewLocation;
}

public void setInterviewLocation(String interviewLocation) {
    this.interviewLocation = interviewLocation;
}

public float getLat() {
    return lat;
}

public void setLat(float lat) {
    this.lat = lat;
}

public float getLon() {
    return lon;
}

public void setLon(float lon) {
    this.lon = lon;
}

public String getContactPerson() {
    return contactPerson;
}

public void setContactPerson(String contactPerson) {
    this.contactPerson = contactPerson;
}

public String getContactPhone() {
    return contactPhone;
}

public void setContactPhone(String contactPhone) {
    this.contactPhone = contactPhone;
}

public String getContactMail() {
    return contactMail;
}

public void setContactMail(String contactMail) {
    this.contactMail = contactMail;
}

public int getTotalVocancies() {
    return totalVocancies;
}

public void setTotalVocancies(int totalVocancies) {
    this.totalVocancies = totalVocancies;
}

public String getPostedOn() {
    return postedOn;
}

public void setPostedOn(String postedOn) {
    this.postedOn = postedOn;
}

public String getCurrently_active() {
    return currently_active;
}

public void setCurrently_active(String currently_active) {
    this.currently_active = currently_active;
}

}

我给你所有的代码。一旦我的笔记本电脑可用。在此之前,将dependecy更改为编译'com.squareup.reformation2:reformation:2.1.0'h