Ver código fonte

set 3 sec limit for click to download

hanjing 6 anos atrás
pai
commit
8d4bc20dfd

+ 12 - 1
app/src/main/java/com/sheep/gamegroup/helper/DownloadHelper.java

@@ -35,6 +35,9 @@ import static com.sheep.gamegroup.model.entity.TaskEty.TASK_TYPE_APP;
  * 下载游戏辅助类
  */
 public class DownloadHelper {
+
+    private final static int LAST_CLICK_TIME = 101;
+
     private int downLoadType;
 
     /**
@@ -74,9 +77,17 @@ public class DownloadHelper {
             down_tv.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
+                    Object obj = view.getTag(LAST_CLICK_TIME);
+                    if (obj != null) {
+                        Long lastClickTime = (Long) obj;
+                        if (System.currentTimeMillis() - lastClickTime < 3000) {
+                            return;
+                        }
+                    }
                     if (callBack != null)
                         callBack.call(-1);
                     downloadApp(iTask);
+                    view.setTag(LAST_CLICK_TIME, new Long(System.currentTimeMillis()));
                 }
             });
         }
@@ -167,7 +178,7 @@ public class DownloadHelper {
         action1.call(true);
         if (isInstalled) {
             boolean needUpgrade = false;
-            if(!TextUtils.isEmpty(taskEty.getVersions())) {
+            if (!TextUtils.isEmpty(taskEty.getVersions())) {
                 needUpgrade = PackageUtil.needAppUpgrade(SheepApp.getInstance(), taskEty.getPackage_names(), taskEty.getVersions());
             }
             if (!needUpgrade) {