|
|
@ -59,11 +59,12 @@ public class SplashActivity extends BaseActivity { |
|
|
|
private int adTimes; |
|
|
|
private int adTimes; |
|
|
|
|
|
|
|
|
|
|
|
private PermissionsChecker mPermissionsChecker; |
|
|
|
private PermissionsChecker mPermissionsChecker; |
|
|
|
private Thread myThread = new Thread() {//创建子线程
|
|
|
|
//创建子线程
|
|
|
|
|
|
|
|
private Thread start = new Thread() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
sleep(WAIT_INTERVAL);//使程序休眠
|
|
|
|
Thread.sleep(WAIT_INTERVAL);//使程序休眠
|
|
|
|
Intent it = new Intent(SplashActivity.this, MainActivity.class);//启动MainActivity
|
|
|
|
Intent it = new Intent(SplashActivity.this, MainActivity.class);//启动MainActivity
|
|
|
|
it.putExtra("startFromSplash", true); |
|
|
|
it.putExtra("startFromSplash", true); |
|
|
|
startActivity(it); |
|
|
|
startActivity(it); |
|
|
@ -74,24 +75,23 @@ public class SplashActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
private Thread countTime = new Thread(){ |
|
|
|
private Thread countTime = new Thread() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
for (int i = 0; i < 8; i++) { |
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
|
|
|
|
int time = 5 - i; |
|
|
|
|
|
|
|
App.runOnUiThread(() -> binding.tvSkip.setText(getString(R.string.skip_ad, time))); |
|
|
|
try { |
|
|
|
try { |
|
|
|
Thread.sleep(1000); |
|
|
|
Thread.sleep(1000); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!App.isDestroy(SplashActivity.this)){ |
|
|
|
|
|
|
|
WAIT_INTERVAL = 0; |
|
|
|
WAIT_INTERVAL = 0; |
|
|
|
startNormal(); |
|
|
|
startNormal(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void bindView() { |
|
|
|
protected void bindView() { |
|
|
|
binding = ActivitySplashBinding.inflate(getLayoutInflater()); |
|
|
|
binding = ActivitySplashBinding.inflate(getLayoutInflater()); |
|
|
@ -131,13 +131,21 @@ public class SplashActivity extends BaseActivity { |
|
|
|
adTimes = spu.getInt("curAdTimes", 3); |
|
|
|
adTimes = spu.getInt("curAdTimes", 3); |
|
|
|
String[] splashAdCounts = splashAdCount.split(":"); |
|
|
|
String[] splashAdCounts = splashAdCount.split(":"); |
|
|
|
String today = DateHelper.getYearMonthDay1(); |
|
|
|
String today = DateHelper.getYearMonthDay1(); |
|
|
|
if (today.equals(splashAdCounts[0])){ |
|
|
|
if (today.equals(splashAdCounts[0])) { |
|
|
|
todayAdCount = Integer.parseInt(splashAdCounts[1]); |
|
|
|
todayAdCount = Integer.parseInt(splashAdCounts[1]); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
todayAdCount = 0; |
|
|
|
todayAdCount = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void initClick() { |
|
|
|
|
|
|
|
binding.tvSkip.setOnClickListener(v -> { |
|
|
|
|
|
|
|
WAIT_INTERVAL = 0; |
|
|
|
|
|
|
|
startNormal(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) { |
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) { |
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { |
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { |
|
|
@ -147,7 +155,7 @@ public class SplashActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void start() { |
|
|
|
private void start() { |
|
|
|
if (adTimes >= 0 && todayAdCount >= adTimes){ |
|
|
|
if (adTimes >= 0 && todayAdCount >= adTimes) { |
|
|
|
startNoAd(); |
|
|
|
startNoAd(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
AdUtils.checkHasAd() |
|
|
|
AdUtils.checkHasAd() |
|
|
@ -173,7 +181,7 @@ public class SplashActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void startNoAd(){ |
|
|
|
private void startNoAd() { |
|
|
|
Animation inAni = AnimationUtils.loadAnimation(SplashActivity.this, R.anim.fade_in); |
|
|
|
Animation inAni = AnimationUtils.loadAnimation(SplashActivity.this, R.anim.fade_in); |
|
|
|
binding.ivSplash.setVisibility(View.VISIBLE); |
|
|
|
binding.ivSplash.setVisibility(View.VISIBLE); |
|
|
|
binding.ivSplash.startAnimation(inAni); |
|
|
|
binding.ivSplash.startAnimation(inAni); |
|
|
@ -184,18 +192,26 @@ public class SplashActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void startNormal() { |
|
|
|
private void startNormal() { |
|
|
|
|
|
|
|
if (!App.isDestroy(this)) { |
|
|
|
if (BookGroupService.getInstance().curGroupIsPrivate()) { |
|
|
|
if (BookGroupService.getInstance().curGroupIsPrivate()) { |
|
|
|
App.runOnUiThread(() -> { |
|
|
|
App.runOnUiThread(() -> { |
|
|
|
MyAlertDialog.showPrivateVerifyDia(SplashActivity.this, needGoTo -> { |
|
|
|
MyAlertDialog.showPrivateVerifyDia(SplashActivity.this, needGoTo -> { |
|
|
|
myThread.start(); |
|
|
|
if (!start.isAlive()) { |
|
|
|
|
|
|
|
start.start(); |
|
|
|
|
|
|
|
} |
|
|
|
}, () -> { |
|
|
|
}, () -> { |
|
|
|
SharedPreUtils.getInstance().putString(SplashActivity.this.getString(R.string.curBookGroupId), ""); |
|
|
|
SharedPreUtils.getInstance().putString(SplashActivity.this.getString(R.string.curBookGroupId), ""); |
|
|
|
SharedPreUtils.getInstance().putString(SplashActivity.this.getString(R.string.curBookGroupName), ""); |
|
|
|
SharedPreUtils.getInstance().putString(SplashActivity.this.getString(R.string.curBookGroupName), ""); |
|
|
|
myThread.start(); |
|
|
|
if (!start.isAlive()) { |
|
|
|
|
|
|
|
start.start(); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
myThread.start(); |
|
|
|
if (!start.isAlive()) { |
|
|
|
|
|
|
|
start.start(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -206,7 +222,7 @@ public class SplashActivity extends BaseActivity { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void show() { |
|
|
|
public void show() { |
|
|
|
Log.d(TAG, "广告展示成功"); |
|
|
|
Log.d(TAG, "广告展示成功"); |
|
|
|
AdUtils.adRecord("splash","adShow"); |
|
|
|
AdUtils.adRecord("splash", "adShow"); |
|
|
|
countTodayAd(); |
|
|
|
countTodayAd(); |
|
|
|
countTime.start(); |
|
|
|
countTime.start(); |
|
|
|
} |
|
|
|
} |
|
|
@ -215,14 +231,13 @@ public class SplashActivity extends BaseActivity { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void click() { |
|
|
|
public void click() { |
|
|
|
Log.d(TAG, "广告被点击"); |
|
|
|
Log.d(TAG, "广告被点击"); |
|
|
|
AdUtils.adRecord("splash","adClick"); |
|
|
|
AdUtils.adRecord("splash", "adClick"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 展示出错时可读取 msg 中的错误信息
|
|
|
|
// 展示出错时可读取 msg 中的错误信息
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void error(String msg) { |
|
|
|
public void error(String msg) { |
|
|
|
WAIT_INTERVAL = 1500; |
|
|
|
WAIT_INTERVAL = 1500; |
|
|
|
if (!App.isDestroy(SplashActivity.this)) |
|
|
|
|
|
|
|
startNormal(); |
|
|
|
startNormal(); |
|
|
|
Log.e(TAG, msg); |
|
|
|
Log.e(TAG, msg); |
|
|
|
//ToastUtils.showError(msg);
|
|
|
|
//ToastUtils.showError(msg);
|
|
|
@ -232,15 +247,14 @@ public class SplashActivity extends BaseActivity { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void finishCountdown() { |
|
|
|
public void finishCountdown() { |
|
|
|
Log.d(TAG, "倒计时结束或用户主动点击跳过按钮"); |
|
|
|
Log.d(TAG, "倒计时结束或用户主动点击跳过按钮"); |
|
|
|
AdUtils.adRecord("splash","adFinishCount"); |
|
|
|
WAIT_INTERVAL = 0; |
|
|
|
if (!App.isDestroy(SplashActivity.this)) |
|
|
|
AdUtils.adRecord("splash", "adFinishCount"); |
|
|
|
startNormal(); |
|
|
|
startNormal(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
WAIT_INTERVAL = 1500; |
|
|
|
WAIT_INTERVAL = 1500; |
|
|
|
if (!App.isDestroy(SplashActivity.this)) |
|
|
|
|
|
|
|
startNormal(); |
|
|
|
startNormal(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|