Commit 36db09d7 authored by mengcuiguang's avatar mengcuiguang

优化高额任务

parent 712b7968
......@@ -82,11 +82,7 @@ object DownloadApkManager {
override fun onError(error: Error) {
downloadProgressDialog?.dismiss()
try {
CacheUtil.clearAllCache(context)
} catch (e: Exception) {
e.printStackTrace()
}
CacheUtil.clearAllCache(context)
}
})
}
......
......@@ -110,11 +110,7 @@ class KylVedioActivity : BaseActivity(), View.OnClickListener, KylVedioView {
}
//删除缓存文件
try {
CacheUtil.clearAllCache(context)
} catch (e: Exception) {
e.printStackTrace()
}
CacheUtil.clearAllCache(context)
kylVedioPresenter.detachView()
}
......
......@@ -271,13 +271,8 @@ class SettingsActivity : BaseActivity(), View.OnClickListener, OnLoginListener,
}
R.id.dialog_btn_right -> {
try {
CacheUtil.clearAllCache(context)
item_cleanCache.findViewById<TextView>(R.id.tv_right).text = "0KB"
} catch (e: Exception) {
e.printStackTrace()
} finally {
}
CacheUtil.clearAllCache(context)
item_cleanCache.findViewById<TextView>(R.id.tv_right).text = "0KB"
}
}
}
......
......@@ -11,6 +11,7 @@ import android.webkit.WebViewClient
import com.mints.goodmoney.R
import com.mints.goodmoney.manager.DownloadApkManager
import com.mints.goodmoney.ui.activitys.base.BaseActivity
import com.mints.goodmoney.utils.CacheUtil
import kotlinx.android.synthetic.main.activity_web.*
/**
......@@ -99,6 +100,9 @@ class WebActivity : BaseActivity(), View.OnClickListener {
override fun onDestroy() {
super.onDestroy()
CacheUtil.clearAllCache(context)
if (browser_layout != null) {
browser_layout.destroyDrawingCache()
browser_layout.clearWebView()
......
......@@ -94,7 +94,6 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
// 高额任务
private var mCurrentPkg: String? = null
private var mCarrierType: String? = null
private var cdaa: CustomDialogAsApple? = null
......@@ -130,6 +129,7 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_MY) {
if (!TextUtils.isEmpty(userManager.userID)) {
myPresenter.getAutoUserHallBaseMsg()
refreshHighTask()
} else {
// 游客登录
myPresenter.userLogin()
......@@ -141,20 +141,25 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
// 刷新喜马拉雅信息流
TTPreLoadExpressXmlyManager.getInstance().loadTtFrameLayout()
}
}
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)
/**
* 刷新高额任务
*/
private fun refreshHighTask() {
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
myPresenter.setHighTaskType("0")
}
AppConfig.isHighTask = false
}
}
......@@ -461,7 +466,7 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
}
when (taskBean.otherConfig.status) {
0 -> {
0 -> {// 0-去下载 1-去领取 3-去试玩
if (AppUtil.isOpenUsageStats()) {
highVideoTint(taskBean)
} else {
......@@ -920,6 +925,12 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
private fun videoAdingSuccess(adType: String) {
if (activity != null && !activity!!.isFinishing) {
// 高额任务
if (TextUtils.equals(carrierType, Constant.CARRIER_HIGH_ACTIVITY)) {
return
}
// 签到
val bundle = Bundle()
if (TextUtils.equals(carrierType, Constant.CARRIER_SIGNIN_HOMEPAGE_CARD)) {
bundle.putInt(Constant.MAIN_CUR_COIN, curSignCoin * 2)
......@@ -928,11 +939,7 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
return
}
if (mCarrierType != null && mCarrierType == Constant.CARRIER_HIGH_ACTIVITY) {
mCarrierType = null
return
}
// 每日福利视频
userConfig?.let {
for (autoListBean in it.autoList) {
if (autoListBean.baseConfig.taskId == MainMyAdapter.APP_VEDIO) {
......@@ -1133,7 +1140,7 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
R.id.dialog_btn_right -> {
cdaa!!.dismiss()
mCarrierType = Constant.CARRIER_HIGH_ACTIVITY
carrierType = Constant.CARRIER_HIGH_ACTIVITY
vedioAdingManager.setIsHighWeight(true)
awardVedio(taskBean.otherConfig.coin, Constant.CARRIER_HIGH_ACTIVITY)
......@@ -1194,13 +1201,16 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
private val mReceiverBroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
if (intent == null) return
try {
val pkg = intent.getStringExtra("pkg")
mCurrentPkg = pkg
myPresenter.setHighTaskType("3")
} catch (e: Exception) {
e.printStackTrace()
// 非高额任务不监听下载安装
if (TextUtils.equals(carrierType, Constant.CARRIER_HIGH_ACTIVITY)) {
try {
val pkg = intent.getStringExtra("pkg")
mCurrentPkg = pkg
myPresenter.setHighTaskType("3")
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}
......
......@@ -27,9 +27,13 @@ public class CacheUtil {
* @param context
*/
public static void clearAllCache(Context context) {
deleteDir(context.getCacheDir());
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
deleteDir(context.getExternalCacheDir());
try {
deleteDir(context.getCacheDir());
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
deleteDir(context.getExternalCacheDir());
}
} catch (Exception e) {
e.printStackTrace();
}
}
......
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