Commit 38c37a5a authored by mengcuiguang's avatar mengcuiguang

优化首页微转来电秀标记切换,cpd界面优化

parent 23cfb489
......@@ -209,9 +209,6 @@
<activity
android:name=".ui.activitys.XmlyPlayActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.TaskActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.TaskCpdActivity"
android:screenOrientation="portrait" />
......
......@@ -208,9 +208,9 @@ public final class CoralDownload {
@Override
public boolean onAppDownloaded(@Nullable CoralAD ad, @Nullable String downloadUrl, @Nullable String localFile) {
LogUtil.d("onAppDownloaded");
if (mOnAdLoadListener != null) {
mOnAdLoadListener.onSDKDownloaded();
}
// if (mOnAdLoadListener != null) {
// mOnAdLoadListener.onSDKDownloaded();
// }
return false;
}
......@@ -228,9 +228,9 @@ public final class CoralDownload {
public boolean onAppInstalled(@Nullable CoralAD ad, @Nullable String downloadUrl, @Nullable String localFile) {
LogUtil.d("onAppInstalled");
if (mOnAdLoadListener != null) {
mOnAdLoadListener.onSDKInstalled();
}
// if (mOnAdLoadListener != null) {
// mOnAdLoadListener.onSDKInstalled();
// }
return false;
}
......@@ -270,9 +270,9 @@ public final class CoralDownload {
void onSDKDownloadStart();
void onSDKDownloaded();
void onSDKInstalled();
// void onSDKDownloaded();
//
// void onSDKInstalled();
void onGetDownloadProcess(DownloadProcess downloadProcess);
}
......
package com.mints.goodmoney.manager
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.common.DeviceInfo
import com.mints.goodmoney.net.CpdService
import com.mints.goodmoney.utils.MD5
......@@ -37,7 +38,7 @@ object CpdManager {
val application = JSONObject()
val equipment = JSONObject()
try {
application.put("app_pkg_name", "com.mints.goodmoney")
application.put("app_pkg_name", Constant.MINTS_PKG_NAME)
application.put("app_ver_code", deviceInfo.versionCode)
application.put("app_ver_name", deviceInfo.versionName)
// 设备类型 4-手机
......
......@@ -36,7 +36,6 @@ class KylVideoActivity : BaseActivity(), View.OnClickListener, KylVideoView {
const val VIDEO_ID = "video_id"
}
//https://vring.kuyin123.com/friend/94aa83142f7f5c98?videoId=1251065712248619008
private val WEB_VEDIO_URL = "https://vring.kuyin123.com/friend/94aa83142f7f5c98?videoId="
private lateinit var videoUrl: String
......@@ -215,9 +214,6 @@ class KylVideoActivity : BaseActivity(), View.OnClickListener, KylVideoView {
showToast("视频处理中,请稍候")
return
}
// DetailActivity.startSelf(this@KylVideoActivity, vedioPathName)
// finish()
readyGo()
}
......
......@@ -42,6 +42,8 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
private var currentFragment: Fragment? = null
private var isMainShowWz: Boolean = false// 是否显示来电秀,防止线程不一样
override fun getContentViewLayoutID() = R.layout.activity_main
override fun initViewsAndEvents() {
......@@ -65,9 +67,11 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
if (AppConfig.isMainShowWz) {
tab_iv_four.setImageResource(R.drawable.tab_wz_share_btn)
tab_tv_four.text = "新闻分享"
isMainShowWz = true
} else {
tab_iv_four.setImageResource(R.drawable.tab_bell_btn)
tab_tv_four.text = "来电秀"
isMainShowWz = false
}
tab_iv_one.isSelected = true
......@@ -207,7 +211,7 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
fun clickTab4Layout() {
// 是否显示微转
if (AppConfig.isMainShowWz) {
if (isMainShowWz) {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_FOUR
if (wzFragment == null) {
wzFragment = WzFragment()
......
package com.mints.goodmoney.ui.activitys
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.download.CoralDownload
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.common.DeviceInfo
import com.mints.goodmoney.manager.AppTryPlayManager
import com.mints.goodmoney.manager.DownloadApkManager
import com.mints.goodmoney.manager.TrackManager
import com.mints.goodmoney.mvp.model.CpdModelBean
import com.mints.goodmoney.mvp.model.TzTaskBean
import com.mints.goodmoney.mvp.presenters.TaskPresenter
import com.mints.goodmoney.mvp.views.TaskView
import com.mints.goodmoney.service.AppInstallService
import com.mints.goodmoney.ui.activitys.base.BaseActivity
import com.mints.goodmoney.ui.adapter.TaskAdapter
import com.mints.goodmoney.ui.adapter.listener.OnItemChildClickListener
import com.mints.goodmoney.ui.widgets.CustomDialogAsApple
import com.mints.goodmoney.ui.widgets.DialogListener
import com.mints.goodmoney.ui.widgets.TaskCpdDialog
import com.mints.goodmoney.ui.widgets.TaskDialog
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.listener.OnRefreshListener
import com.tz.sdk.coral.ad.CoralAD
import com.tz.sdk.coral.callback.h5.DownloadProcess
import kotlinx.android.synthetic.main.activity_task.*
import kotlinx.android.synthetic.main.header_layout.*
/**
*
* 描述:试玩任务
*/
class TaskActivity : BaseActivity(), TaskView,
OnRefreshListener,
CoralDownload.OnAdLoadListener,
OnItemChildClickListener,
View.OnClickListener,
DownloadApkManager.OnMyDownloadListener {
private val taskPresenter by lazy { TaskPresenter() }
private var mTaskAdapter: TaskAdapter? = null
private val mFakeTaskList: MutableList<TzTaskBean> = arrayListOf()
// 任务弹框
private var taskDialog: TaskDialog? = null
private var taskCpdDialog: TaskCpdDialog? = null
private lateinit var cdaa: CustomDialogAsApple
// 天卓下载广告请求
private var mCoralDownload: CoralDownload? = null
private var mDownloadProcess: DownloadProcess? = null
// APP下载回调广播
private var mReceiverBroadcastReceiver: BroadcastReceiver? = null
// 试完时间不足弹窗
private var tryTimeOut = false
// 第二次拉取重复不拉取
private var isTwiceGetCpd = false
private val outNetIp by lazy { SPUtil.getInstance().getString(Constant.OUT_NET_IP) }
companion object {
const val TASK_COIN = "task_coin"
const val TASK_USE_MAX = "task_use_max"
const val TASK_USE_COMPLETE = "task_use_complete"
}
private var mCoin = 0
private var needUseTime = -1
private var shMax = 3 //珊瑚 广告最大填充数
private var cpdMax = 3 //CPD 广告最大填充数
private var shLoadCountTime = 0 // 珊瑚 加载广告次数
private var cpdLoadCountTime = 0 // CPD 加载广告次数
override fun getBundleExtras(extras: Bundle) {
super.getBundleExtras(extras)
mCoin = extras.getInt(TASK_COIN)
}
override fun getContentViewLayoutID() = R.layout.activity_task
override fun initViewsAndEvents() {
taskPresenter.attachView(this)
tv_title.text = "下载试玩任务"
iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
mCoralDownload = CoralDownload().setOnAdLoadListener(this)
CacheUtil.clearAllCache(context)
initView()
initListener()
loadData()
}
private fun loadCPDData() {
taskPresenter.getCpdDetail(outNetIp)
}
private fun initView() {
val gridLayoutManager = GridLayoutManager(this, 3)
recy_task.layoutManager = gridLayoutManager
recy_task.addItemDecoration(SpacesItemDecoration(3, SpacesItemDecoration.px2dp(10f)))
mTaskAdapter = TaskAdapter(mFakeTaskList, this)
recy_task.adapter = mTaskAdapter
recy_task.setItemViewCacheSize(20)
mTaskAdapter?.setOnItemChildClickListener(this)
iv_left_icon.setOnClickListener(this)
}
private fun initListener() {
srl_task.setOnRefreshListener(this)
}
override fun onResume() {
super.onResume()
DownloadApkManager.tryOnceInstallApk()
try {
if (needUseTime != -1) {
refreshDemoTask()
}
} catch (e: Exception) {
LogUtil.e(e.printStackTrace())
}
}
override fun isApplyKitKatTranslucency() = false
override fun getShCpdTimeSuc(time: Int, coin: Int, CPD: Int, CPD_SYD: Int) {
needUseTime = time
shMax = CPD
cpdMax = CPD_SYD
if ((shMax + cpdMax) <= 0) {
hideLoading()
showToast("今日任务已完成,请明日再试")
finish()
return
}
isTwiceGetCpd = false
shLoadCountTime = 0
cpdLoadCountTime = 0
mFakeTaskList.clear()
if (shMax > 0 && (cpdMax > 0 || cpdMax == 0)) {
for (i in 0 until shMax) {
mCoralDownload?.pull()
}
} else if (cpdMax > 0) {
for (i in 0 until cpdMax) {
loadCPDData()
}
}
}
override fun getCpdModelSuc(dataBean: CpdModelBean.DataBean) {
for (material in dataBean.materials) {
val tzTaskBean = TzTaskBean(material.icons, material.title, material.description, false, mCoin, 0, material.app_apk_name)
tzTaskBean.app_url = material.app_url
tzTaskBean.trackerBean = material.tracker
mFakeTaskList.add(tzTaskBean)
}
// 多拉取的CPD广告
if (cpdLoadCountTime++ >= cpdMax - 1) {
getCpdRepeatPkg()
}
}
/**
* 遍历去重APP包名
*/
private fun getCpdRepeatPkg() {
if (isTwiceGetCpd) {
if (cpdLoadCountTime >= cpdMax) {
notifyDataAndShowAd()
}
return
}
cpdLoadCountTime = cpdMax
RxjavaUtil.executeRxTask<MutableList<TzTaskBean>>(object : CommonRxTask<MutableList<TzTaskBean>>() {
override fun doInIOThread() {
val newPkgData = mutableListOf<TzTaskBean>()
for (i in 0 until mFakeTaskList.size) {
if (mFakeTaskList[i].isShCpd) {
newPkgData.add(mFakeTaskList[i])
} else {
var flag = true
for (j in 0 until mFakeTaskList.size) {
if (!mFakeTaskList[i].isShCpd && !mFakeTaskList[j].isShCpd) {
// 数据重复
if (i != j && mFakeTaskList[i].downLoadPkgName == mFakeTaskList[j].downLoadPkgName) {
flag = false
break
}
}
}
if (flag) {
// 是否已经安装此app
if (!DeviceInfo.instance.isLoadingPkg(mFakeTaskList[i].downLoadPkgName)) {
cpdLoadCountTime--
newPkgData.add(mFakeTaskList[i])
}
}
}
}
t = newPkgData
}
override fun doInUIThread() {
mFakeTaskList.clear()
mFakeTaskList.addAll(t)
// 重新获取数据
if (cpdLoadCountTime in 1..cpdMax) {
isTwiceGetCpd = true
for (i in 0 until cpdLoadCountTime) {
loadCPDData()
}
cpdLoadCountTime = cpdMax - cpdLoadCountTime
return
} else {
notifyDataAndShowAd()
}
}
})
}
private fun notifyDataAndShowAd() {
hideLoading()
srl_task.finishRefresh()
mTaskAdapter?.notifyDataSetChanged()
if (mFakeTaskList.size == 0) {
iv_empty.visibility = View.VISIBLE
return
} else {
iv_empty.visibility = View.GONE
}
for (tzTaskBean in mFakeTaskList) {
if (!tzTaskBean.isShCpd) {
val trackerBean = tzTaskBean.trackerBean
if (trackerBean != null) {
LogUtil.d(TAG_LOG, "CPD -> show")
// 上报CPD显示
taskPresenter.cmtImp(trackerBean.show[0])
}
}
}
}
override fun getCpdModelFail() {
if (cpdLoadCountTime++ >= cpdMax - 1) {
notifyDataAndShowAd()
}
}
override fun onRefresh(refreshLayout: RefreshLayout) {
loadData()
}
override fun onLoadSuccess(dataList: MutableList<CoralAD>?) {
dataList?.let {
for (coralAD in it) {
val tzTaskBean = TzTaskBean(coralAD.icon, coralAD.title, coralAD.description, true, mCoin, 0, null)
tzTaskBean.coralAd = coralAD
mFakeTaskList.add(tzTaskBean)
}
}
// 多拉取的广告
if (shLoadCountTime++ >= shMax - 1) {
if (cpdMax == 0) {
notifyDataAndShowAd()
return
}
for (i in 0 until cpdMax) {
loadCPDData()
}
}
}
override fun onLoadFail() {
// 次数刷新完 且未拿到数据 提示
if (shLoadCountTime++ >= shMax - 1) {
if (cpdMax == 0) {
notifyDataAndShowAd()
return
}
for (i in 0 until cpdMax) {
loadCPDData()
}
}
}
override fun onSDKDownloadStart() {
taskDialog?.dismiss()
registerBroad()
}
override fun onSDKDownloaded() {
// SDK上报下载完成
// mDownloadProcess?.reportDownloadSuccess(localFilePath, false)
}
override fun onSDKInstalled() {
// SDK上报安装完成
// mDownloadProcess?.reportInstallSuccess(false)
}
override fun onGetDownloadProcess(downloadProcess: DownloadProcess?) {
// 点击之后回调下载数据
mDownloadProcess = downloadProcess
// 跳转去下载
val downloadUrl = downloadProcess!!.downloadUrl
val packageName = downloadProcess.packageName
DownloadApkManager.setOnMyDownloadListener(this)
DownloadApkManager.downloadApk(this, downloadUrl, packageName)
}
override fun onDestroy() {
mCoralDownload?.destroy()
mDownloadProcess = null
DownloadApkManager.destroy()
if (mReceiverBroadcastReceiver != null) {
mContext.stopService(Intent(context, AppInstallService::class.java))
mContext.unregisterReceiver(mReceiverBroadcastReceiver)
}
taskPresenter.detachView()
super.onDestroy()
}
override fun onBackPressed() {
// super.onBackPressed()
backDialog()
}
override fun onItemChildClick(view: View?, position: Int) {
when (mFakeTaskList[position].state) {
// 0 立即下载, 1 去试玩, 2 领取奖励 3 已领取 4 继续试玩
0 -> {
tryTimeOut = false
if (AppUtil.isOpenUsageStats()) {
clickDialog(position)
} else {
AppTryPlayManager.openAppUsageStats(this)
}
}
1 -> {
mTaskAdapter?.let {
val currentPkgName = mFakeTaskList[it.getPosition()].currentPkgName
if (currentPkgName == null) {
showToast("任务异常,请重试~")
mFakeTaskList[it.getPosition()].state = 0
it.notifyItemChanged(it.getPosition())
} else {
if (AppUtil.checkPackInfo(mContext, currentPkgName)) {
AppTryPlayManager.toTryPlay(currentPkgName)
} else {
showToast("未找到当前APP、可能被卸载,请重试~")
// 重置当前列表状态
mFakeTaskList[it.getPosition()].state = 0
it.notifyItemChanged(it.getPosition())
}
}
}
}
2 -> {
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, mCoin)
mTaskAdapter?.let {
if (mFakeTaskList[it.getPosition()].isShCpd) {
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_CPD)
} else {
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_CPD_SYD)
}
}
readyGo(AwardActivity::class.java, bundle)
finish()
}
3 -> {
showToast("当前任务已完成,试试其他任务吧!")
}
4 -> {
mTaskAdapter?.let {
val currentPkgName = mFakeTaskList[it.getPosition()].currentPkgName
if (currentPkgName == null) {
showToast("任务异常,请重试~")
mFakeTaskList[it.getPosition()].state = 0
it.notifyItemChanged(it.getPosition())
} else {
if (AppUtil.checkPackInfo(mContext, currentPkgName)) {
AppTryPlayManager.toTryPlay(currentPkgName)
} else {
showToast("未找到当前APP、可能被卸载,请重试~")
// 重置当前列表状态
mFakeTaskList[it.getPosition()].state = 0
it.notifyItemChanged(it.getPosition())
}
}
}
}
}
}
private fun clickDialog(position: Int) {
if (needUseTime == -1) return
if (mFakeTaskList[position].isShCpd) {
taskDialog = TaskDialog(this)
taskDialog?.show()
taskDialog?.setData(mFakeTaskList[position].coralAd, needUseTime, mCoin)
} else {
taskCpdDialog = TaskCpdDialog(this, object : DialogListener() {
override fun onClick(v: View?) {
val trackerBean = mFakeTaskList[position].trackerBean
if (trackerBean != null) {
LogUtil.d(TAG_LOG, "CPD -> clikc")
// 上报CPD点击
taskPresenter.cmtImp(trackerBean.clikc[0])
}
// 圣于地开始下载
DownloadApkManager.setOnMyDownloadListener(this@TaskActivity)
DownloadApkManager.downloadApk(this@TaskActivity, mFakeTaskList[position].app_url, mFakeTaskList[position].downLoadPkgName)
}
})
taskCpdDialog?.setData(mFakeTaskList[position].title, mFakeTaskList[position].description, mFakeTaskList[position].icon, needUseTime, mCoin)
taskCpdDialog?.show()
}
}
/**
* 注册试玩任务监听
*/
private fun registerBroad() {
if (mReceiverBroadcastReceiver != null) return
mContext.startService(Intent(context, AppInstallService::class.java))
mReceiverBroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
if (intent == null) return
try {
taskDialog?.dismiss()
taskCpdDialog?.dismiss()
val pkg = intent.getStringExtra("pkg")
if (mTaskAdapter == null) return
val position = mTaskAdapter!!.getPosition()
mFakeTaskList[position].currentPkgName = pkg
mFakeTaskList[position].state = 1
mTaskAdapter!!.notifyItemChanged(position)
if (mFakeTaskList[position].isShCpd) {
// 上报珊瑚安装完成
mDownloadProcess?.reportInstallSuccess(false)
// 上报安装过的APP
val coralAd = mFakeTaskList[position].coralAd
TrackManager.getInstance().saveInstallAppRecord(coralAd.packageName, coralAd.title, coralAd.icon)
} else {
val trackerBean = mFakeTaskList[position].trackerBean
if (trackerBean != null) {
// 上报CPD开始安装
LogUtil.d(TAG_LOG, "CPD -> install_start")
taskPresenter.cmtImp(trackerBean.install_start[0])
// 上报CPD安装完成
LogUtil.d(TAG_LOG, "CPD -> install_finish")
taskPresenter.cmtImp(trackerBean.install_finish[0])
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
val intentFilter = IntentFilter()
intentFilter.addAction(AppInstallService.APP_INSTALL_ACTION)
mContext.registerReceiver(this.mReceiverBroadcastReceiver, intentFilter)
}
/**
* 刷新高额任务
*/
private fun refreshDemoTask() {
mTaskAdapter?.let {
val position = it.getPosition()
if (mFakeTaskList.size == 0 || mFakeTaskList[position].state == 3) return
val currentPkgName = mFakeTaskList[position].currentPkgName
if (currentPkgName != null) {
// 时间为0
if (needUseTime == 0) {
mFakeTaskList[position].state = 2
it.notifyItemChanged(position)
if (mFakeTaskList[position].isShCpd) {
// 上报珊瑚激活完成
mDownloadProcess?.reportAppActivated()
} else {
val trackerBean = mFakeTaskList[position].trackerBean
if (trackerBean != null) {
// 上报CPD激活完成
LogUtil.d(TAG_LOG, "CPD -> install_start")
taskPresenter.cmtImp(trackerBean.install_start[0])
LogUtil.d(TAG_LOG, "CPD -> install_finish")
taskPresenter.cmtImp(trackerBean.install_finish[0])
LogUtil.d(TAG_LOG, "CPD -> activation")
taskPresenter.cmtImp(trackerBean.activation[0])
}
}
return
}
if (AppTryPlayManager.getTryPlayIsOK(currentPkgName, needUseTime)) {
// 完成试玩任务
mFakeTaskList[position].state = 2
it.notifyItemChanged(position)
if (mFakeTaskList[position].isShCpd) {
// 上报珊瑚激活完成
mDownloadProcess?.reportAppActivated()
} else {
val trackerBean = mFakeTaskList[position].trackerBean
if (trackerBean != null) {
// 上报CPD激活完成
LogUtil.d(TAG_LOG, "CPD -> activation")
taskPresenter.cmtImp(trackerBean.activation[0])
}
}
} else {
if (AppTryPlayManager.getTryPlayIsOK(currentPkgName, 5)) {
// 试玩时间不足
if (tryTimeOut) {
return
}
tryTimeOut = true
mFakeTaskList[position].state = 4
it.notifyItemChanged(it.getPosition())
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, 0)
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_CPD)
readyGo(AwardActivity::class.java, bundle)
} else {
// 试玩时间不足5秒
mFakeTaskList[position].state = 1
it.notifyItemChanged(it.getPosition())
}
}
}
}
}
private fun loadData() {
taskPresenter.getShCpdTime()
}
private fun backDialog() {
cdaa = CustomDialogAsApple(context, object : DialogListener() {
override fun onClick(v: View) {
if (cdaa.isShowing) {
cdaa.dismiss()
}
when (v.id) {
R.id.dialog_btn_right -> {
finish()
}
}
}
})
cdaa.setTitle("提示")
cdaa.setContent("退出当前页面将会重置当前任务状态")
cdaa.setLeft("取消")
cdaa.setRight("确定")
cdaa.show()
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.iv_left_icon -> {
backDialog()
}
}
}
/**
* 开始下载
*/
override fun onDownloadStart() {
taskDialog?.dismiss()
taskCpdDialog?.dismiss()
val position = mTaskAdapter!!.getPosition()
if (mFakeTaskList[position].isShCpd) {
// 上报珊瑚开始下载
mDownloadProcess?.reportDownloadStart(false)
} else {
LogUtil.d(TAG_LOG, "CPD -> onDownloadStart")
val trackerBean = mFakeTaskList[position].trackerBean
if (trackerBean != null) {
// 上报CPD下载开始
taskPresenter.cmtImp(trackerBean.download_start[0])
}
}
registerBroad()
}
/**
* 下载成功
*/
override fun onDownloadSuccess(path: String) {
val position = mTaskAdapter!!.getPosition()
if (mFakeTaskList[position].isShCpd) {
// 上报珊瑚下载成功
mDownloadProcess?.reportDownloadSuccess(path, false)
} else {
LogUtil.d(TAG_LOG, "CPD -> onDownloadSuccess")
val trackerBean = mFakeTaskList[position].trackerBean
if (trackerBean != null) {
// 上报CPD下载成功
taskPresenter.cmtImp(trackerBean.download_finish[0])
}
}
}
}
\ No newline at end of file
......@@ -95,4 +95,5 @@ class TaskCpdActivity : BaseActivity(), View.OnClickListener {
cdaa.setRight("确定")
cdaa.show()
}
}
......@@ -41,6 +41,8 @@ class TaskCpdFragment : BaseFragment(), TaskView,
OnItemChildClickListener,
DownloadApkManager.OnMyDownloadListener {
private val TAG = TaskCpdFragment::class.java.simpleName
private val taskPresenter by lazy { TaskPresenter() }
private var mTaskAdapter: TaskAdapter? = null
......@@ -60,13 +62,13 @@ class TaskCpdFragment : BaseFragment(), TaskView,
// 试完时间不足弹窗
private var tryTimeOut = false
// 第二次拉取重复不拉取
// 圣于地第二次拉取重复不拉取
private var isTwiceGetCpd = false
private val outNetIp by lazy { SPUtil.getInstance().getString(Constant.OUT_NET_IP) }
private var mCoin = 0
private var needUseTime = -1
private var needUseTime = -1// 应用试玩时间
private var shMax = 3 //珊瑚 广告最大填充数
private var cpdMax = 3 //CPD 广告最大填充数
......@@ -88,6 +90,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
}
private fun loadCPDData() {
LogUtil.d(TAG,"syd loadCPDData")
taskPresenter.getCpdDetail(outNetIp)
}
......@@ -139,18 +142,16 @@ class TaskCpdFragment : BaseFragment(), TaskView,
if ((shMax + cpdMax) <= 0) {
hideLoading()
showToast("今日任务已完成,请明日再试")
// finish()
return
}
isTwiceGetCpd = false
shLoadCountTime = 0
cpdLoadCountTime = 0
mFakeTaskList.clear()
if (shMax > 0 && (cpdMax > 0 || cpdMax == 0)) {
if (shMax > 0) {
// 先加载珊瑚广告,珊瑚回调判断圣于地
for (i in 0 until shMax) {
mCoralDownload?.pull()
}
......@@ -158,10 +159,14 @@ class TaskCpdFragment : BaseFragment(), TaskView,
for (i in 0 until cpdMax) {
loadCPDData()
}
} else {
notifyDataAndShowAd()
}
}
override fun getCpdModelSuc(dataBean: CpdModelBean.DataBean) {
LogUtil.d(TAG,"syd getCpdModelSuc")
for (material in dataBean.materials) {
val tzTaskBean = TzTaskBean(material.icons, material.title, material.description, false, mCoin, 0, material.app_apk_name)
tzTaskBean.app_url = material.app_url
......@@ -169,13 +174,17 @@ class TaskCpdFragment : BaseFragment(), TaskView,
mFakeTaskList.add(tzTaskBean)
}
// 多拉取的CPD广告
// 圣于地广告 循环完成后去重
if (cpdLoadCountTime++ >= cpdMax - 1) {
getCpdRepeatPkg()
notifyDataAndShowAd()
// getCpdRepeatPkg()
}
}
override fun getCpdModelFail() {
LogUtil.d(TAG,"syd getCpdModelFail")
if (cpdLoadCountTime++ >= cpdMax - 1) {
notifyDataAndShowAd()
}
......@@ -190,9 +199,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
*/
private fun getCpdRepeatPkg() {
if (isTwiceGetCpd) {
if (cpdLoadCountTime >= cpdMax) {
notifyDataAndShowAd()
}
return
}
......@@ -221,7 +228,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
}
if (flag) {
// 是否已经安装此app
// 添加未安装app
if (!DeviceInfo.instance.isLoadingPkg(mFakeTaskList[i].currentPkgName)) {
cpdLoadCountTime--
newPkgData.add(mFakeTaskList[i])
......@@ -244,15 +251,12 @@ class TaskCpdFragment : BaseFragment(), TaskView,
for (i in 0 until cpdLoadCountTime) {
loadCPDData()
}
cpdLoadCountTime = cpdMax - cpdLoadCountTime
return
} else {
notifyDataAndShowAd()
}
}
})
}
......@@ -268,6 +272,13 @@ class TaskCpdFragment : BaseFragment(), TaskView,
iv_empty.visibility = View.GONE
}
uploadSydImp()
}
/**
* 上报圣于地展示
*/
private fun uploadSydImp() {
for (tzTaskBean in mFakeTaskList) {
if (!tzTaskBean.isShCpd) {
......@@ -283,6 +294,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
}
override fun onLoadSuccess(dataList: MutableList<CoralAD>?) {
LogUtil.d(TAG,"shanhu onLoadSuccess times")
dataList?.let {
for (coralAD in it) {
val tzTaskBean = TzTaskBean(coralAD.icon, coralAD.title, coralAD.description, true, mCoin, 0, null)
......@@ -291,8 +303,9 @@ class TaskCpdFragment : BaseFragment(), TaskView,
}
}
// 多拉取的广告
// 珊瑚循环完成后 调用圣于地广告
if (shLoadCountTime++ >= shMax - 1) {
LogUtil.d(TAG,"shanhu onLoadSuccess")
if (cpdMax == 0) {
notifyDataAndShowAd()
return
......@@ -325,16 +338,6 @@ class TaskCpdFragment : BaseFragment(), TaskView,
registerBroad()
}
override fun onSDKDownloaded() {
// SDK上报下载完成
// mDownloadProcess?.reportDownloadSuccess(localFilePath, false)
}
override fun onSDKInstalled() {
// SDK上报安装完成
// mDownloadProcess?.reportInstallSuccess(false)
}
override fun onGetDownloadProcess(downloadProcess: DownloadProcess?) {
// 点击之后回调下载数据
mDownloadProcess = downloadProcess
......@@ -356,7 +359,6 @@ class TaskCpdFragment : BaseFragment(), TaskView,
}
taskPresenter.detachView()
super.onDestroy()
}
......@@ -404,7 +406,7 @@ class TaskCpdFragment : BaseFragment(), TaskView,
}
readyGo(AwardActivity::class.java, bundle)
// finish()
activity?.finish()
}
3 -> {
showToast("当前任务已完成,试试其他任务吧!")
......
......@@ -50,6 +50,7 @@
android:layout_height="wrap_content"
android:drawableTop="@mipmap/ic_friends"
android:text="平台分红"
android:textStyle="bold"
android:layout_centerVertical="true"
android:textColor="@color/white"
android:textSize="14sp" />
......
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