hanjing лет назад: 6
Родитель
Сommit
e7121c91f6
1 измененных файлов с 22 добавлено и 0 удалено
  1. 22 0
      app/src/main/java/com/sheep/gamegroup/absBase/BaseActivity.java

+ 22 - 0
app/src/main/java/com/sheep/gamegroup/absBase/BaseActivity.java

@@ -9,6 +9,7 @@ import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.v7.app.ActionBar;
 import android.support.v7.widget.Toolbar;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.Window;
 import android.view.WindowManager;
@@ -56,6 +57,27 @@ public abstract class BaseActivity extends RxAppCompatActivity implements BackHa
         return true;
     }
 
+    private static long lastClickTime;
+    public static boolean isFastDoubleClick() {
+        long time = System.currentTimeMillis();
+        long timeD = time - lastClickTime;
+        if (0 < timeD && timeD < 1000) {
+            return true;
+        }
+        lastClickTime = time;
+        return false;
+    }
+
+    @Override
+    public boolean dispatchTouchEvent(MotionEvent ev) {
+        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+            if (isFastDoubleClick()) {
+                return true;
+            }
+        }
+        return super.dispatchTouchEvent(ev);
+    }
+
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
 //        if (BuildConfig.DEBUG) {