Commit ecaa2fdd by pye52

现在在线支付执行前会有100ms的时间预留,保证扫码反馈声音能播报完毕

parent f7a10807
...@@ -37,7 +37,9 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG; ...@@ -37,7 +37,9 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
* 支付状态(空闲、发送订单信息、支付中、支付成功、支付失败)都会通过{@link PayOnlineState}发出通知 <br/><br/> * 支付状态(空闲、发送订单信息、支付中、支付成功、支付失败)都会通过{@link PayOnlineState}发出通知 <br/><br/>
*/ */
public class PayOnlineViewModel extends ViewModel { public class PayOnlineViewModel extends ViewModel {
private static final long TIMEOUT = 5; private static final long TIMEOUT = 5 * 1000;
// 在线支付延迟100ms执行,留出时间给扫码反馈
private static final long REQUEST_DELAY = 100;
private static final long DEFAULT_DELAY = 3 * 1000; private static final long DEFAULT_DELAY = 3 * 1000;
private Gson gson; private Gson gson;
private String deviceSN; private String deviceSN;
...@@ -71,9 +73,9 @@ public class PayOnlineViewModel extends ViewModel { ...@@ -71,9 +73,9 @@ public class PayOnlineViewModel extends ViewModel {
payRequest = new PayRequest(deviceSN, payData); payRequest = new PayRequest(deviceSN, payData);
cancelTimeout(); cancelTimeout();
TimeoutRunnable timeoutRunnable = new TimeoutRunnable(); TimeoutRunnable timeoutRunnable = new TimeoutRunnable();
timeoutFuture = SCTaskExecutor.getInstance().schedule(timeoutRunnable, TIMEOUT, TimeUnit.SECONDS); timeoutFuture = SCTaskExecutor.getInstance().schedule(timeoutRunnable, TIMEOUT, TimeUnit.MILLISECONDS);
RequestRunnable requestRunnable = new RequestRunnable(); RequestRunnable requestRunnable = new RequestRunnable();
SCTaskExecutor.getInstance().executeOnDiskIO(requestRunnable); SCTaskExecutor.getInstance().schedule(requestRunnable, REQUEST_DELAY, TimeUnit.MILLISECONDS);
} }
private void cancelTimeout() { private void cancelTimeout() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment