Commit 39cd7e51 authored by jyx's avatar jyx

代码优化

parent 1ea088ee
...@@ -37,6 +37,15 @@ public class TzTaskBean { ...@@ -37,6 +37,15 @@ public class TzTaskBean {
this.downLoadPkgName = downLoadPkgName; this.downLoadPkgName = downLoadPkgName;
} }
public TzTaskBean(String icon, String title,int coin, int state, String currentPkgName,String aid) {
this.icon = icon;
this.title = title;
this.coin = coin;
this.state = state;
this.currentPkgName = currentPkgName;
this.aid = aid;
}
public String getDownLoadPkgName() { public String getDownLoadPkgName() {
return downLoadPkgName; return downLoadPkgName;
} }
......
...@@ -59,6 +59,8 @@ class TaskCpdActivity : BaseActivity(), View.OnClickListener { ...@@ -59,6 +59,8 @@ class TaskCpdActivity : BaseActivity(), View.OnClickListener {
tabs.add("试玩") tabs.add("试玩")
fragments.add(TaskCpdFragment()) fragments.add(TaskCpdFragment())
AppConfig.useAppCpdModelShow = true
if (AppConfig.useAppCpdModelShow) { if (AppConfig.useAppCpdModelShow) {
tabs.add("点击") tabs.add("点击")
fragments.add(TaskCpdHistoryFragment()) fragments.add(TaskCpdHistoryFragment())
......
...@@ -35,14 +35,14 @@ import com.tz.sdk.coral.ad.CoralAD ...@@ -35,14 +35,14 @@ import com.tz.sdk.coral.ad.CoralAD
import com.tz.sdk.coral.callback.h5.DownloadProcess import com.tz.sdk.coral.callback.h5.DownloadProcess
import kotlinx.android.synthetic.main.activity_task.* import kotlinx.android.synthetic.main.activity_task.*
private val TAG = TaskCpdFragment::class.java.simpleName
class TaskCpdFragment : BaseFragment(), TaskView, class TaskCpdFragment : BaseFragment(), TaskView,
OnRefreshListener, OnRefreshListener,
CoralDownload.OnAdLoadListener, CoralDownload.OnAdLoadListener,
OnItemChildClickListener, OnItemChildClickListener,
DownloadApkManager.OnMyDownloadListener { DownloadApkManager.OnMyDownloadListener {
private val TAG = TaskCpdFragment::class.java.simpleName
private val taskPresenter by lazy { TaskPresenter() } private val taskPresenter by lazy { TaskPresenter() }
private var mTaskAdapter: TaskAdapter? = null private var mTaskAdapter: TaskAdapter? = null
...@@ -168,7 +168,7 @@ class TaskCpdFragment : BaseFragment(), TaskView, ...@@ -168,7 +168,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
LogUtil.d(TAG, "syd getCpdModelSuc") LogUtil.d(TAG, "syd getCpdModelSuc")
for (material in dataBean.materials) { for (material in dataBean.materials) {
val tzTaskBean = TzTaskBean(material.icons, material.title, material.description, false, mCoin, 0, material.app_apk_name) val tzTaskBean = TzTaskBean(material.icons, material.description, material.title, false, mCoin, 0, material.app_apk_name)
tzTaskBean.app_url = material.app_url tzTaskBean.app_url = material.app_url
tzTaskBean.trackerBean = material.tracker tzTaskBean.trackerBean = material.tracker
mFakeTaskList.add(tzTaskBean) mFakeTaskList.add(tzTaskBean)
...@@ -176,8 +176,7 @@ class TaskCpdFragment : BaseFragment(), TaskView, ...@@ -176,8 +176,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
// 圣于地广告 循环完成后去重 // 圣于地广告 循环完成后去重
if (cpdLoadCountTime++ >= cpdMax - 1) { if (cpdLoadCountTime++ >= cpdMax - 1) {
notifyDataAndShowAd() getCpdRepeatPkg()
// getCpdRepeatPkg()
} }
} }
...@@ -220,7 +219,7 @@ class TaskCpdFragment : BaseFragment(), TaskView, ...@@ -220,7 +219,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
if (!mFakeTaskList[i].isShCpd && !mFakeTaskList[j].isShCpd) { if (!mFakeTaskList[i].isShCpd && !mFakeTaskList[j].isShCpd) {
// 数据重复 // 数据重复
if (i != j && mFakeTaskList[i].currentPkgName == mFakeTaskList[j].currentPkgName) { if (i != j && mFakeTaskList[i].downLoadPkgName == mFakeTaskList[j].downLoadPkgName) {
flag = false flag = false
break break
} }
...@@ -229,7 +228,7 @@ class TaskCpdFragment : BaseFragment(), TaskView, ...@@ -229,7 +228,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
if (flag) { if (flag) {
// 添加未安装app // 添加未安装app
if (!DeviceInfo.instance.isLoadingPkg(mFakeTaskList[i].currentPkgName)) { if (!DeviceInfo.instance.isLoadingPkg(mFakeTaskList[i].downLoadPkgName)) {
cpdLoadCountTime-- cpdLoadCountTime--
newPkgData.add(mFakeTaskList[i]) newPkgData.add(mFakeTaskList[i])
} }
...@@ -244,17 +243,19 @@ class TaskCpdFragment : BaseFragment(), TaskView, ...@@ -244,17 +243,19 @@ class TaskCpdFragment : BaseFragment(), TaskView,
mFakeTaskList.clear() mFakeTaskList.clear()
mFakeTaskList.addAll(t) mFakeTaskList.addAll(t)
// 重新获取数据
if (cpdLoadCountTime in 1..cpdMax) {
isTwiceGetCpd = true
for (i in 0 until cpdLoadCountTime) {
loadCPDData()
}
cpdLoadCountTime = cpdMax - cpdLoadCountTime
} else {
notifyDataAndShowAd() notifyDataAndShowAd()
}
// 重新获取数据
// if (cpdLoadCountTime in 1..cpdMax) {
// isTwiceGetCpd = true
//
// for (i in 0 until cpdLoadCountTime) {
// loadCPDData()
// }
// cpdLoadCountTime = cpdMax - cpdLoadCountTime
// } else {
// notifyDataAndShowAd()
// }
} }
}) })
...@@ -492,7 +493,7 @@ class TaskCpdFragment : BaseFragment(), TaskView, ...@@ -492,7 +493,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
if (mFakeTaskList[position].isShCpd) { if (mFakeTaskList[position].isShCpd) {
// 上报后台珊瑚安装完成 // 上报后台珊瑚安装完成
TrackManager.getInstance().saveInstallAppRecord(pkg, mFakeTaskList[position].title, mFakeTaskList[position].icon) TrackManager.getInstance().saveInstallAppRecord(pkg, mFakeTaskList[position].description, mFakeTaskList[position].icon)
// 上报珊瑚安装完成 // 上报珊瑚安装完成
mDownloadProcess?.reportInstallSuccess(false) mDownloadProcess?.reportInstallSuccess(false)
...@@ -542,14 +543,8 @@ class TaskCpdFragment : BaseFragment(), TaskView, ...@@ -542,14 +543,8 @@ class TaskCpdFragment : BaseFragment(), TaskView,
} else { } else {
val trackerBean = mFakeTaskList[position].trackerBean val trackerBean = mFakeTaskList[position].trackerBean
if (trackerBean != null) { if (trackerBean != null) {
// 上报CPD激活完成
LogUtil.d("CPD -> install_start")
taskPresenter.cmtImp(trackerBean.install_start[0])
LogUtil.d("CPD -> install_finish")
taskPresenter.cmtImp(trackerBean.install_finish[0])
// 上报CPD激活完成
LogUtil.d("CPD -> activation") LogUtil.d("CPD -> activation")
taskPresenter.cmtImp(trackerBean.activation[0]) taskPresenter.cmtImp(trackerBean.activation[0])
} }
......
...@@ -5,6 +5,7 @@ import android.view.View ...@@ -5,6 +5,7 @@ import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.mints.goodmoney.R import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.common.DeviceInfo
import com.mints.goodmoney.manager.AppTryPlayManager import com.mints.goodmoney.manager.AppTryPlayManager
import com.mints.goodmoney.mvp.model.TaskCpdBean import com.mints.goodmoney.mvp.model.TaskCpdBean
import com.mints.goodmoney.mvp.model.TzTaskBean import com.mints.goodmoney.mvp.model.TzTaskBean
...@@ -15,6 +16,8 @@ import com.mints.goodmoney.ui.adapter.TaskCpdHistoryAdapter ...@@ -15,6 +16,8 @@ import com.mints.goodmoney.ui.adapter.TaskCpdHistoryAdapter
import com.mints.goodmoney.ui.adapter.listener.OnItemChildClickListener import com.mints.goodmoney.ui.adapter.listener.OnItemChildClickListener
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import com.mints.goodmoney.utils.* import com.mints.goodmoney.utils.*
import com.mints.goodmoney.utils.rxutil.CommonRxTask
import com.mints.goodmoney.utils.rxutil.RxjavaUtil
import com.scwang.smartrefresh.layout.api.RefreshLayout import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import kotlinx.android.synthetic.main.activity_task.* import kotlinx.android.synthetic.main.activity_task.*
...@@ -206,13 +209,40 @@ class TaskCpdHistoryFragment : LazyLoadBaseFragment(), TaskCpdHistoryView, ...@@ -206,13 +209,40 @@ class TaskCpdHistoryFragment : LazyLoadBaseFragment(), TaskCpdHistoryView,
mFakeTaskList.clear() mFakeTaskList.clear()
needUseTime = taskCpdBean.needSeconds needUseTime = taskCpdBean.needSeconds
for (bean in taskCpdBean.list) { for (bean in taskCpdBean.list) {
val tzTaskBean = TzTaskBean(bean.icon, bean.name, "", false, bean.coin, 1, bean.pkg) mFakeTaskList.add(TzTaskBean(bean.icon, bean.name, bean.coin, 1, bean.pkg, bean.aid))
tzTaskBean.aid = bean.aid
mFakeTaskList.add(tzTaskBean)
} }
// 去除已经安装过的APP
getCpdRepeatPkg()
}
/**
* 遍历去重APP包名
*/
private fun getCpdRepeatPkg() {
RxjavaUtil.executeRxTask<MutableList<TzTaskBean>>(object : CommonRxTask<MutableList<TzTaskBean>>() {
override fun doInIOThread() {
val newPkgData = mutableListOf<TzTaskBean>()
for (i in 0 until mFakeTaskList.size) {
// 添加安装过的app
if (DeviceInfo.instance.isLoadingPkg(mFakeTaskList[i].currentPkgName)) {
newPkgData.add(mFakeTaskList[i])
}
}
t = newPkgData
}
override fun doInUIThread() {
mFakeTaskList.clear()
mFakeTaskList.addAll(t)
notifyDataAndShowAd() notifyDataAndShowAd()
} }
})
}
override fun getCpdUseAppModelMsgFail() { override fun getCpdUseAppModelMsgFail() {
notifyDataAndShowAd() notifyDataAndShowAd()
......
...@@ -12,7 +12,7 @@ import com.mints.library.utils.GlideUtils ...@@ -12,7 +12,7 @@ import com.mints.library.utils.GlideUtils
/** /**
* 提示弹框 * 提示弹框
*/ */
class TaskCpdDialog(context: Context, private val listener: DialogListener) : class TaskCpdDialog(context: Context, listener: DialogListener) :
Dialog(context, R.style.dialog) { Dialog(context, R.style.dialog) {
private val lp: WindowManager.LayoutParams private val lp: WindowManager.LayoutParams
private val tvTitle: TextView private val tvTitle: TextView
......
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