| | |
| | | // 调用后台 |
| | | String gridNo = editable.toString(); |
| | | if (null == gridNo || "".equals(gridNo.trim())) { |
| | | showResult("Please enter pickup code."); |
| | | showResult("Please enter pickup code.",false); |
| | | return; |
| | | } else { |
| | | if (gridNo.length() !=6) { |
| | | editText.setText(""); |
| | | showResult("The pickup code input is incorrect,\nplease try again."); |
| | | return; |
| | | } |
| | | // if (gridNo.length() !=6) { |
| | | // editText.setText(""); |
| | | // showResult("The pickup code input is incorrect,\nplease try again."); |
| | | // return; |
| | | // } |
| | | //调用判断是否可以取餐 |
| | | editText.setText(""); |
| | | takeCheckCode(gridNo); |
| | |
| | | .callTimeout(20, TimeUnit.SECONDS) |
| | | .addInterceptor(loggingInterceptor)//添加日志拦截器 |
| | | .build(); |
| | | |
| | | LogUtils.i(CacheDiskUtils.getInstance().getString(SettingConfig.getInstance().Cache_Device_Code), code); |
| | | String sn = CacheDiskUtils.getInstance().getString(SettingConfig.getInstance().Cache_Device_Code); |
| | | RequestBody body = new FormBody.Builder() |
| | | .build(); |
| | | |
| | | final Request request = new Request.Builder() |
| | | .url(HttpUrlDefine.pickOrder+"?pickNum="+code) |
| | | .url(HttpUrlDefine.pickOrder+"?pickNum="+code+"&sn="+sn) |
| | | /* .addHeader("language", "zh-CN")*/ |
| | | .post(body) |
| | | .build(); |
| | |
| | | message.setMessageByte(command); |
| | | EventBus.getDefault().post(message); |
| | | showResult("Door opened succcessfully! \n" + |
| | | "Please pickup your meal."); |
| | | "Please pickup your meal.",true); |
| | | }else{ |
| | | showResult(baseDto.getMsg()); |
| | | showResult(baseDto.getMsg(),false); |
| | | } |
| | | } |
| | | }); |
| | |
| | | }); |
| | | } |
| | | |
| | | public void showResult(String msg){ |
| | | public void showResult(String msg,boolean isCountdown){ |
| | | TipDialog tipDialog = new TipDialog(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putString("msg",msg); |
| | | bundle.putBoolean("isCountdown",isCountdown); |
| | | tipDialog.setArguments(bundle); |
| | | tipDialog.show(getSupportFragmentManager(),"res"); |
| | | } |
| | | |
| | | |
| | | public void pickOrder(String code) { |
| | | HttpLoggerInterceptor loggingInterceptor = new HttpLoggerInterceptor(true); |
| | | OkHttpClient client = new OkHttpClient.Builder() |
| | | .connectTimeout(20, TimeUnit.SECONDS)//响应时间,读取时间 |
| | | .readTimeout(20, TimeUnit.SECONDS) |
| | | .callTimeout(20, TimeUnit.SECONDS) |
| | | .addInterceptor(loggingInterceptor)//添加日志拦截器 |
| | | .build(); |
| | | |
| | | LogUtils.i(CacheDiskUtils.getInstance().getString(SettingConfig.getInstance().Cache_Device_Code), code); |
| | | RequestBody body = new FormBody.Builder() |
| | | .build(); |
| | | |
| | | final Request request = new Request.Builder() |
| | | .url(HttpUrlDefine.pickOrder+"?pickNum="+code) |
| | | /* .addHeader("language", "zh-CN")*/ |
| | | .post(body) |
| | | .build(); |
| | | client.newCall(request).enqueue(new Callback() { |
| | | @Override |
| | | public void onFailure(Call call, IOException e) { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | DynamicToast.makeError(context, "请求失败!", 3).show(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onResponse(Call call, Response response) throws IOException { |
| | | String result = response.body().string(); |
| | | LogUtils.i("获取到的数据:" + result); |
| | | final BaseDto baseDto = GsonUtils.fromJson(result, BaseDto.class); |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (baseDto.isData()) { |
| | | DynamicToast.makeSuccess(context, "验证成功!", 3).show(); |
| | | }else{ |
| | | DynamicToast.makeError(context, "验证失败!", 3).show(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |