Commit 412fa20a authored by maxiaoliang's avatar maxiaoliang

1

parent 57632ec3
......@@ -4,6 +4,7 @@ import android.content.Intent
import android.graphics.Color
import android.graphics.Typeface
import android.os.Build
import android.util.Log
import androidx.activity.OnBackPressedCallback
import androidx.annotation.RequiresApi
import androidx.fragment.app.Fragment
......@@ -15,7 +16,6 @@ import com.test.easy.easycleanerjunk.databinding.ActivityMainBinding
import com.test.easy.easycleanerjunk.fragment.HomeFragment
import com.test.easy.easycleanerjunk.fragment.ToolsFragment
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.EventUtils
import com.test.easy.easycleanerjunk.utils.BarUtils
import com.test.easy.easycleanerjunk.utils.SPUtils
......@@ -46,8 +46,7 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() {
@RequiresApi(Build.VERSION_CODES.O)
override fun initView() {
ConfigHelper.isfirstInstall++
ConfigHelper.enterHomeTimes++
// ConfigHelper.enterHomeTimes++
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
......@@ -86,23 +85,41 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() {
PopExitWindow.show(this@NewMainActivity)
}
})
if(ConfigHelper.isfirstInstall==1){
if (ConfigHelper.enterHomeTimes.toInt() == 2|| ConfigHelper.enterHomeTimes.toInt() == 3) {
//第二次进入首页
val s = SPUtils.getInstance().getInt("dayoutcomeHomePage", 0)
if (s == 1) {
startActivity(Intent(this, BackRelsutAt::class.java))
}
}
}else{
if (ConfigHelper.enterHomeTimes.toInt() == 1|| ConfigHelper.enterHomeTimes.toInt() == 2) {
//第二次进入首页
val s = SPUtils.getInstance().getInt("dayoutcomeHomePage", 0)
if (s == 1) {
startActivity(Intent(this, BackRelsutAt::class.java))
}
}
}
Log.e("MXL", "initView: " + "第一天安装")
// Log.e("MXL", "initView: " + ConfigHelper.enterHomeTimes)
// if(!ConfigHelper.isfirstInstall){
// if ((ConfigHelper.enterHomeTimes % 1000).toInt() == 2 || (ConfigHelper.enterHomeTimes % 1000).toInt() == 3) {
// //第二次进入首页
// val s = SPUtils.getInstance().getInt("dayoutcomeHomePage", 0)
// if (s == 1) {
// startActivity(Intent(this, BackRelsutAt::class.java))
// }
// }
// }else{
// if ((ConfigHelper.enterHomeTimes % 1000).toInt() == 1 || (ConfigHelper.enterHomeTimes % 1000).toInt() == 2) {
// val s = SPUtils.getInstance().getInt("dayoutcomeHomePage", 0)
// if (s == 1) {
// startActivity(Intent(this, BackRelsutAt::class.java))
// }
// }
// }
// if ((ConfigHelper.isfirstInstall % 1000).toInt() ==1) {
//
// } else {
// Log.e("MXL", "initView: " + "第二天安装")
// Log.e("MXL", "initView: "+ConfigHelper.enterHomeTimes )
// Log.e("MXL", "initView: "+ConfigHelper.enterHomeTimes % 1000 )
//
// if ((ConfigHelper.enterHomeTimes % 1000).toInt() == 1 || (ConfigHelper.enterHomeTimes % 1000).toInt() == 2) {
// //第二次进入首页
// val s = SPUtils.getInstance().getInt("dayoutcomeHomePage", 0)
// if (s == 1) {
// startActivity(Intent(this, BackRelsutAt::class.java))
// }
// }
// }
}
......@@ -144,14 +161,15 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() {
if (isPause) {
val s = SPUtils.getInstance().getInt("outcomeReturnCount", 0)
if (s == 1) {
val localCount = SPUtils.getInstance().getInt("localCount", 0)
SPUtils.getInstance().put("localCount", localCount + 1)
val n = SPUtils.getInstance().getInt("outcomeReturnHomeCount", 0)
if (n > 0) {
if (localCount % n == 0) {
startActivity(Intent(this, BackRelsutAt::class.java))
}
}
// val localCount = SPUtils.getInstance().getInt("localCount", 0)
// SPUtils.getInstance().put("localCount", localCount + 1)
// val n = SPUtils.getInstance().getInt("outcomeReturnHomeCount", 0)
// if (n > 0) {
// if (localCount % n == 0) {
// startActivity(Intent(this, BackRelsutAt::class.java))
// }
// }
}
}
......
......@@ -22,5 +22,6 @@ class ConfigBean() {
var outcomeReturnCount: Int = 0//每次从结果页面关闭到首页时
var outcomeReturnHomeCount: Int = 0//返回主页弹几次
var dayoutcomeHomePage: Int = 0 //第二次打开到首页开关
var maxShowNotificationCount: Int = 0
}
......@@ -18,6 +18,7 @@ import com.test.easy.easycleanerjunk.R;
import com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity;
import com.test.easy.easycleanerjunk.bean.NotificationBean;
import com.test.easy.easycleanerjunk.helps.EventUtils;
import com.test.easy.easycleanerjunk.helps.ads.AdDisplayUtils;
import com.test.easy.easycleanerjunk.utils.SPUtils;
import java.util.Random;
......@@ -81,19 +82,19 @@ public class NotificationUtil {
private static HandlerThread handlerThread;
private static Handler handler;
private fun incrementNotification() {
val key = "showNotificationCount_" + AdDisplayUtils.getInstance().getCurrentDate()
var s = AppPreferences.getInstance().getInt(key, 0)
s++
AppPreferences.getInstance().put(key, s)
private static void incrementNotification() {
String key = "showNotificationCount_" + AdDisplayUtils.getInstance().getCurrentDate();
int s = SPUtils.getInstance().getInt(key, 0);
s++;
SPUtils.getInstance().put(key, s);
}
public static void sendNotification(Context context) {
val currentNum = AppPreferences.getInstance().getInt("showNotificationCount_" + AdDisplayUtils.getInstance().getCurrentDate(), 0)
val maxNum = AppPreferences.getInstance().getString("maxShowNotificationCount", "156").toIntOrNull()?:156
int currentNum = SPUtils.getInstance().getInt("showNotificationCount_" + AdDisplayUtils.getInstance().getCurrentDate(), 0);
int maxNum = Integer.parseInt(SPUtils.getInstance().getString("maxShowNotificationCount", "156"));
if (currentNum >= maxNum) {
LogEx.logDebug("glc","currentNum >= maxNum")
return
// LogEx.logDebug("glc","currentNum >= maxNum");
return;
}
int actionId = getNextNotificationId();
......@@ -112,7 +113,7 @@ public class NotificationUtil {
}
sendNotification(context, actionId);
incrementNotification()
incrementNotification();
int open = SPUtils.getInstance().getInt("open", 0);
if (open == 1) {
......
......@@ -3,7 +3,6 @@ package com.test.easy.easycleanerjunk.helps
import com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity
import com.test.easy.easycleanerjunk.utils.SPUtils
import java.util.Calendar
object ConfigHelper {
......@@ -90,30 +89,32 @@ object ConfigHelper {
SPUtils.getInstance().put("fcmNotification", value, true)
}
//进入主页的次数
var enterHomeTimes = 0L
get() {
val last = Calendar.getInstance().apply {
timeInMillis = SPUtils.getInstance().getLong("enterHomeTimes", field)
}
return Calendar.getInstance().run {
if (get(Calendar.DAY_OF_YEAR) == last[Calendar.DAY_OF_YEAR]) {
last
} else {
set(Calendar.MILLISECOND, 0)
this
}
}.timeInMillis
}
set(value) {
field = value
SPUtils.getInstance().put("enterHomeTimes", value)
}
var isfirstInstall = 0
get() {
return SPUtils.getInstance().getInt("isfirstInstall", field)
}
set(value) {
field = value
SPUtils.getInstance().put("isfirstInstall", value)
}
// var enterHomeTimes = 0L
// get() {
// val last = Calendar.getInstance().apply {
// timeInMillis = SPUtils.getInstance().getLong("enterHomeTimes", field)
// }
// return Calendar.getInstance().run {
// if (get(Calendar.DAY_OF_YEAR) == last[Calendar.DAY_OF_YEAR]) {
// last
// } else {
// set(Calendar.MILLISECOND, 0)
// this
// }
// }.timeInMillis
// }
// set(value) {
// field = value
// SPUtils.getInstance().put("enterHomeTimes", value)
// }
// var isfirstInstall = false
// get() {
// return SPUtils.getInstance().getBoolean("isfirstInstall", field)
// }
// set(value) {
// field = value
// SPUtils.getInstance().put("isfirstInstall", value, true)
// }
}
\ No newline at end of file
......@@ -112,7 +112,7 @@ public class AdDisplayUtils {
saveAdClickCount();
}
private String getCurrentDate() {
public String getCurrentDate() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
Date currentDate = Calendar.getInstance().getTime();
return dateFormat.format(currentDate);
......
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