Commit a0b51d39 authored by jyx's avatar jyx

代码优化

parent 14d42a9b
......@@ -348,7 +348,7 @@ public class VedioAdingManager {
// 优量汇
if (ylhVedioAdManager == null) {
if (activity == null) {
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerError(Constant.YLH_VEDIO_AD);
}
return;
......@@ -359,7 +359,7 @@ public class VedioAdingManager {
ylhVedioAdManager.setYlhVedioAdListener(new YlhVedioAdManager.YlhVedioAdListener() {
@Override
public void ylhVedioAdFail() {
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerFail(Constant.YLH_VEDIO_AD);
}
}
......@@ -367,7 +367,7 @@ public class VedioAdingManager {
@Override
public void ylhVedioAdSuccess() {
AppConfig.ylhAdCount--;
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerSuccess(Constant.YLH_VEDIO_AD);
}
}
......@@ -382,7 +382,7 @@ public class VedioAdingManager {
// 穿山甲激励视频
if (csjVedioAdManager == null) {
if (activity == null) {
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerError(Constant.CSJ_VEDIO_AD);
}
return;
......@@ -394,7 +394,7 @@ public class VedioAdingManager {
csjVedioAdManager.setCsjVedioAdListener(new CsjVedioAdManager.CsjVedioAdListener() {
@Override
public void csjVedioAdFail() {
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerFail(Constant.CSJ_VEDIO_AD);
}
}
......@@ -402,7 +402,7 @@ public class VedioAdingManager {
@Override
public void csjVedioAdSuccess() {
AppConfig.csjVedioAdCount--;
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerSuccess(Constant.CSJ_VEDIO_AD);
}
}
......@@ -417,7 +417,7 @@ public class VedioAdingManager {
// 闪电盒子激励视频
if (wnVedioAdManager == null) {
if (activity == null) {
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerError(Constant.SDHZ_VEDIO_AD);
}
return;
......@@ -428,14 +428,14 @@ public class VedioAdingManager {
@Override
public void wnVedioAdSuccess() {
AppConfig.wnVedioAdCount--;
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerSuccess(Constant.SDHZ_VEDIO_AD);
}
}
@Override
public void wnVedioAdFail() {
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerFail(Constant.SDHZ_VEDIO_AD);
}
}
......@@ -450,7 +450,7 @@ public class VedioAdingManager {
// 枫岚广告激励视频
if (mhVedioAdManager == null) {
if (activity == null) {
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerError(Constant.FL_VEDIO_AD);
}
return;
......@@ -461,14 +461,14 @@ public class VedioAdingManager {
@Override
public void mhVedioAdSuccess() {
AppConfig.flVedioAdCount--;
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerSuccess(Constant.FL_VEDIO_AD);
}
}
@Override
public void mhVedioAdFail() {
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerFail(Constant.FL_VEDIO_AD);
}
}
......@@ -483,7 +483,7 @@ public class VedioAdingManager {
}
} catch (Exception e) {
e.printStackTrace();
if (vedioAdingListener != null) {
if (vedioAdingListener != null && !isHighWeight) {
vedioAdingListener.vedioAdingListenerError(bean.getCarrierType());
}
}
......
package com.mints.goodmoney.manager
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.mvp.model.EventMessage
import com.mints.goodmoney.utils.RxBus
import com.mints.goodmoney.utils.AppUtil
/**
......@@ -12,24 +9,28 @@ import com.mints.goodmoney.utils.AppUtil
object AppTryPlayManager {
// 第一次打开时间
private var openTime = 0L
// private var openTime = 0L
private var currentPkg = ""
fun toTryPlay(pkg: String) {
if (currentPkg != pkg) {
openTime = AppUtil.getAppUseTime(MintsApplication.getContext(), pkg)
// openTime = AppUtil.getAppUseTime(MintsApplication.getContext(), pkg)
AppUtil.openThirdApp(MintsApplication.getContext(), pkg)
val eventMessage = EventMessage(Constant.IS_HIGH_TASK, pkg)
RxBus.getDefault().postSticky(eventMessage)
// val eventMessage = EventMessage(Constant.IS_HIGH_TASK, pkg)
// RxBus.getDefault().postSticky(eventMessage)
currentPkg = pkg
}
}
fun getTryPlayIsOK(pkg: String): Boolean {
val currentUseTime = AppUtil.getAppUseTime(MintsApplication.getContext(), pkg)
openTime = 0L
currentPkg = ""
return currentUseTime - openTime >= 20
// val currentUseTime = AppUtil.getAppUseTime(MintsApplication.getContext(), pkg)
// openTime = 0L
// currentPkg = ""
// LogUtil.d("currentUseTime ->" + currentUseTime + "-- openTime ->" + openTime)
// return currentUseTime - openTime >= 100
val timePkgUsed = AppUtil.getTimePkgUsed(MintsApplication.getContext(), pkg)
return timePkgUsed >= 30
}
}
\ No newline at end of file
......@@ -260,11 +260,14 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
Constant.CARRIER_HIGH_ACTIVITY -> {
if (curCoin > 0) {
tvAwardContent.setText("试玩奖励${curCoin}金币")
}
tvAwardNext.setText("领取金币")
val vo = HashMap<String, Any>()
vo["carrierType"] = carrierType
awardPresenter.reportAddCoinMsg(vo)
} else {
tvAwardContent.setText("很遗憾,试玩不足30秒")
tvAwardNext.setText("我知道了")
}
}
Constant.CARRIER_SIGNIN_HOMEPAGE_CARD -> {
tvAwardContent.text = "奖励金币已发放"
......
......@@ -137,20 +137,21 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
// 刷新喜马拉雅信息流
TTPreLoadExpressXmlyManager.getInstance().loadTtFrameLayout()
if (AppConfig.isHighTask) {
disposable = RxBus.getDefault().tObservableStick(EventMessage::class.java).subscribe {
if (it.message == Constant.IS_HIGH_TASK) {
if (AppTryPlayManager.getTryPlayIsOK(it.content as String)) {
if (AppConfig.isHighTask && mCurrentPkg != null) {
if (AppTryPlayManager.getTryPlayIsOK(mCurrentPkg!!)) {
myPresenter.setHighTaskType("1")
} else {
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, 0)
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_HIGH_ACTIVITY)
readyGo(AwardActivity::class.java, bundle)
myPresenter.setHighTaskType("0")
}
}
AppConfig.isHighTask = false
}
}
}
}
override fun onDestroyView() {
item_clock_signview.onDestory()
......@@ -467,9 +468,11 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
}
3 -> {
if (mCurrentPkg == null) {
showToast("网络出小差儿了~")
myPresenter.setHighTaskType("0")
myPresenter.getAutoUserHallBaseMsg()
} else {
AppConfig.isHighTask = true
AppTryPlayManager.toTryPlay(mCurrentPkg!!)
}
}
......@@ -1059,7 +1062,6 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
R.id.dialog_btn_right -> {
cdaa!!.dismiss()
AppConfig.isHighTask = true
vedioAdingManager.setIsHighWeight(true)
awardVedio(taskBean.otherConfig.coin, Constant.CARRIER_HIGH_ACTIVITY)
......
package com.mints.goodmoney.utils
import android.app.Service
import android.app.usage.UsageStats
import android.app.usage.UsageStatsManager
import android.content.Context
import android.content.Intent
......@@ -8,6 +9,7 @@ import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.os.Build
import android.provider.Settings
import com.fly.scenemodule.util.StringUtilMy
import com.mints.goodmoney.MintsApplication
......@@ -110,4 +112,19 @@ object AppUtil {
return packageInfo != null
}
fun getTimePkgUsed(paramContext: Context, paramString: String): Int {
if (StringUtilMy.stringAvalable(paramString) && checkPackInfo(paramContext, paramString) && Build.VERSION.SDK_INT >= 21) {
val usageStatsManager = paramContext.getSystemService("usagestats") as UsageStatsManager
var l = System.currentTimeMillis()
val list = usageStatsManager.queryUsageStats(4, l - 6 * 60 * 1000L, l)
if (list != null && list.size > 0) for (i in list.indices) {
val str = (list[i] as UsageStats).packageName
(list[i] as UsageStats).lastTimeUsed
l = (list[i] as UsageStats).totalTimeInForeground
if (paramString == str) return l.toInt() / 1000
}
}
return -1
}
}
\ No newline at end of file
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