我正在学习android并知道基本的编辑等。我有一个由一个自由职业者开发的应用程序。我们正在使用Retrofit 2.0来完成一些任务。我的一个功能就像下面的
private void serverCall() {
progressDialog = new ProgressDialog(WithdrawActivity.this);
progressDialog.setMessage("Please wait...");
progressDialog.setCancelable(false);
progressDialog.show();
HashMap<String, String> payload = new HashMap<>();
String uid = settings.getString("userid", "");
payload.put("UID", uid);
payload.put("Name", etName.getText().toString().trim());
payload.put("MobileNumber", etPaytmMobileNumber.getText().toString().trim());
payload.put("Amount", etAmount.getText().toString().trim());
// NetworkApiInterface apiClient = NetworkApiClient.getClient().create(NetworkApiInterface.class);
NetworkApiInterface apiClient = retrofit.create(NetworkApiInterface.class);
Call<WithdrawalCreditResponseModel> call = apiClient.withdrawalCredit(payload);
call.enqueue(new Callback<WithdrawalCreditResponseModel>() {
@Override
public void onResponse(Call<WithdrawalCreditResponseModel> call, Response<WithdrawalCreditResponseModel> response) {
if (response != null) {
WithdrawalCreditResponseModel responseModel = response.body();
if (responseModel != null) {
Log.d(TAG, new Gson().toJson(responseModel));
if (!TextUtils.isEmpty(responseModel.getMsg())) {
Toast.makeText(WithdrawActivity.this, responseModel.getMsg(), Toast.LENGTH_SHORT).show();
}
if (responseModel.isSuccess()) {
setResult(RESULT_OK);
finish();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
}
}
if (progressDialog != null) {
progressDialog.dismiss();
}
}
@Override
public void onFailure(Call<WithdrawalCreditResponseModel> call, Throwable t) {
t.printStackTrace();
Log.e(TAG, t.getCause() + "");
if (progressDialog != null) {
progressDialog.dismiss();
}
}
});
}
当电话成功时,我想要表演敬酒。我试图将它放在很多地方,但它没有显示出来。我试过把它放在这行等之后
if (responseModel.isSuccess()) {
setResult(RESULT_OK);
Toast.makeText(WithdrawActivity.this, "This Toast Need toShow.", Toast.LENGTH_SHORT).show();
finish();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
这是响应模型
public class WithdrawalCreditResponseModel implements Serializable {
@SerializedName("msg")
@Expose
private String msg;
@SerializedName("success")
@Expose
private boolean success;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
}
但它没有显示任何东西。但是我的任务完成没有任何问题。有人可以检查并告诉我它的问题是什么吗?
由于
答案 0 :(得分:1)
确保你作为一个真正的成功并且它在布尔中,因为在你的模型类中你已经成功地作为一个布尔