From 41078c2c469d9704db6ae2be4f0a9747d2f6a2dd Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Thu, 24 Mar 2022 15:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=AF=E5=8A=A8=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=97=B6=E9=97=B4=E4=B8=BA10s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myreader/ui/activity/SplashActivity.java | 34 ++++++++----------- app/version_code.properties | 2 +- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java index 8133206..ede69cc 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.os.Handler; import android.util.Log; import android.view.KeyEvent; import android.view.View; @@ -53,7 +54,8 @@ public class SplashActivity extends BaseActivity { private boolean hasStart = false; private boolean startToAd = false; private static final String INTENT_TO_AD = "startToAd"; - + private int timeOut = 10; + private Handler handler = new Handler(); //创建子线程 private Runnable start = () -> { @@ -71,23 +73,7 @@ public class SplashActivity extends BaseActivity { } }; - private Thread countTime = new Thread() { - @Override - public void run() { - App.runOnUiThread(() -> binding.tvSkip.setVisibility(View.VISIBLE)); - for (int i = 0; i < 5; i++) { - int time = 5 - i; - App.runOnUiThread(() -> binding.tvSkip.setText(getString(R.string.skip_ad, time))); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - WAIT_INTERVAL = 0; - startNormal(); - } - }; + private Runnable adTimeOutRunnable = () -> adTimeout(--timeOut); public static void start(Context context) { Intent intent = new Intent(context, SplashActivity.class); @@ -233,11 +219,11 @@ public class SplashActivity extends BaseActivity { // 展示成功 @Override public void show() { + handler.removeCallbacks(adTimeOutRunnable); SharedPreUtils.getInstance(true).putLong("splashAdTime", System.currentTimeMillis()); Log.d(TAG, "广告展示成功"); AdUtils.adRecord("splash", "adShow"); countTodayAd(); - //countTime.start(); } // 广告被点击 @@ -265,6 +251,7 @@ public class SplashActivity extends BaseActivity { startNormal(); } }); + adTimeout(timeOut); } catch (Exception e) { e.printStackTrace(); WAIT_INTERVAL = 1500; @@ -374,4 +361,13 @@ public class SplashActivity extends BaseActivity { todayAdCount++; SharedPreUtils.getInstance().putString("splashAdCount", today + ":" + todayAdCount); } + + private void adTimeout(int time) { + if (time == 0) { + WAIT_INTERVAL = 0; + startNormal(); + } else { + handler.postDelayed(adTimeOutRunnable, 1000); + } + } } diff --git a/app/version_code.properties b/app/version_code.properties index 4fa1152..d3ee365 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,3 +1,3 @@ #Fri Jun 18 21:45:31 CST 2021 -VERSION_CODE=240 +VERSION_CODE=241 NEED_CREATE_RELEASE=true