如何在改造2.0中处理故障响应

时间:2018-03-05 06:28:15

标签: java retrofit retrofit2

我正在进行改造2.0我已经把一切都设置得正确我得到了正确的令牌,但最后消息却失败了。我还做了一个回复课程,我通过邮递员。我还在那里附加了一个持票人令牌。我已经尝试了所有的东西,但是没有它们工作。主要活动 `private void hitApi(String token){

    startLoading();
    RetrofitRequest.retrofitGetRequest().listAuth( AppContants.getBearerToken(token) , "0")
            .enqueue(new Callback<ListCallback>() {
                @Override
                public void onResponse (Call<ListCallback> call, Response<ListCallback> response) {
                    stopLoading();

                    if (response.code() == 200) {
                        Log.e("tag",response.toString());
                        Toast.makeText(getApplicationContext(),response.toString(),Toast.LENGTH_LONG).show();
                    } else if (response.code() == 401) {
                        showErrorDialog("Authentication Failed");
                    }
                }

                @Override
                public void onFailure (Call<ListCallback> call, Throwable t) {
                    stopLoading();
                    showToast(getString(R.string.error_message));
                }
            });
}

Api课程

@GET("devices/list")
Call<ListCallback> listAuth( @Header("Authorization") String authToken, 
@Query("pageNumber")String pageNumber);

 Response class`@SerializedName("id")
 @Expose
  private int id;

@SerializedName("machineId")
@Expose
private String machineId;
@SerializedName("name")
@Expose
private String name;

@SerializedName("locationCountry")
@Expose
private String locationCountry;


@SerializedName("manufacturer")
@Expose
private String manufacturer;

@SerializedName("productType")
@Expose
private String productType;

@SerializedName("currentStatus")
@Expose
private String currentStatus;

@SerializedName("completedPercentages")
@Expose
private int completedPercentages;


public int getId () {
    return id;
}

public String getMachineId () {
    return machineId;
    }

public String getName () {
    return name;
   }

public String getLocationCountry() {
    return locationCountry;
}
public String getProductType () {
    return productType;
}

public String getCurrentStatus () {
    return currentStatus;
    }
public int getCompletedPercentages () {
    return completedPercentages;
      }

}

0 个答案:

没有答案