Commit ae173688 by wjg

添加空闲时间清空购物车,并回到首页

parent 83340ba8
......@@ -83,6 +83,7 @@ public class ConfirmOrderDialog extends Dialog {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.view_confirm_order);
initViews();
LauncherActivity.TIMEOUT_TOGGLE = false;
}
private void initViews() {
......@@ -171,6 +172,7 @@ public class ConfirmOrderDialog extends Dialog {
OnDismissListener dismissListener = new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
LauncherActivity.TIMEOUT_TOGGLE = true;
Utils.fastBroadcast(getContext(), Base.BROADCAST_ACTION_CLEAR_GOODS);
if (expireThread != null) {
expireThread.interrupt();
......
......@@ -700,6 +700,8 @@ public class LauncherActivity extends Activity {
}
public static Long TIMESTAMP = System.currentTimeMillis();
public static Boolean TIMEOUT_TOGGLE = true;
/** 判断空闲时间定时器 */
private class TimeoutThread extends Thread {
@Override
......@@ -708,8 +710,12 @@ public class LauncherActivity extends Activity {
try {
while (true) {
Thread.sleep(1000);
if (!TIMEOUT_TOGGLE) { // 打开确认订单弹窗,停止判断空闲
TIMESTAMP = Utils.getTimestamp();
continue;
}
Log.i(AppConfig.TAG, String.valueOf(Utils.getTimestamp() - TIMESTAMP));
if (Utils.getTimestamp() - TIMESTAMP > 1000 * 5) {
if (Utils.getTimestamp() - TIMESTAMP > 1000 * 30) {
TIMESTAMP = Utils.getTimestamp();
Utils.fastBroadcast(HLApplication.SELF, Base.BROADCAST_ACTION_CLEAR_GOODS);
Utils.fastBroadcast(HLApplication.SELF, Base.BROADCAST_ACTION_TIMEOUT);
......
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 to comment