Commit 6f5a8fbb authored by mengcuiguang's avatar mengcuiguang

代码优化

parent b29a856a
......@@ -92,4 +92,10 @@ public class TrackManager {
trackPresenter.addCarrierTypeTime(second);
}
}
public void getCommonHallBaseMsg() {
if (trackPresenter != null) {
trackPresenter.getCommonHallBaseMsg();
}
}
}
package com.mints.goodmoney.mvp.model;
import java.io.Serializable;
public class CommonParamBean implements Serializable {
private boolean showSomeodular = true;
public boolean isShowSomeodular() {
return showSomeodular;
}
}
......@@ -115,6 +115,7 @@ public class DrawcashBean implements Serializable {
private int vedio;
private double money;
private boolean canCashOut;
private String remark;
public void setCanCashOut(boolean canCashOut) {
this.canCashOut = canCashOut;
......@@ -132,5 +133,8 @@ public class DrawcashBean implements Serializable {
return canCashOut;
}
public String getRemark() {
return remark;
}
}
}
package com.mints.goodmoney.mvp.presenters
import com.google.gson.JsonObject
import com.mints.goodmoney.manager.AppHttpManager
import com.mints.goodmoney.mvp.model.BaseResponse
import com.mints.goodmoney.mvp.views.TaskView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
class TaskPresenter : BasePresenter<TaskView>() {
fun getShCpdTime() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getShCpdTime(),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
override fun onCompleted() {
}
override fun onError(e: Throwable) {
}
override fun onNext(baseResponse: BaseResponse<JsonObject>) {
if (isLinkView) return
val code = baseResponse.getStatus()
val message = baseResponse.getMessage()
val data = baseResponse.data
when (code) {
200 ->{
if (data != null) {
view.getShCpdTimeSuc(data.get("needSeconds").asInt)
}
}
else -> view.showToast(message)
}
}
})
}
}
\ No newline at end of file
package com.mints.goodmoney.mvp.presenters;
import com.mints.goodmoney.common.AppConfig;
import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.manager.AppHttpManager;
import com.mints.goodmoney.mvp.model.BaseResponse;
import com.mints.goodmoney.mvp.model.CommonParamBean;
import com.mints.goodmoney.mvp.model.UserTaskMsgBean;
import com.mints.library.net.neterror.BaseSubscriber;
import com.mints.library.net.neterror.Throwable;
......@@ -151,4 +154,33 @@ public class TrackPresenter extends BaseTrackPresenter {
});
}
public void getCommonHallBaseMsg() {
HashMap<String, Object> vo = new HashMap<>();
vo.put("param", "param");
AppHttpManager.getInstance(loanApplication)
.call(loanService.getCommonHallBaseMsg(vo),
new BaseSubscriber<BaseResponse<CommonParamBean>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(BaseResponse<CommonParamBean> baseResponse) {
try {
if (baseResponse.getStatus() == 200) {
CommonParamBean data = baseResponse.getData();
AppConfig.showAdFlag = data.isShowSomeodular();
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
package com.mints.goodmoney.mvp.views
interface TaskView : BaseView {
fun getShCpdTimeSuc(time:Int)
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import com.mints.goodmoney.BuildConfig;
import com.mints.goodmoney.mvp.model.AccountMsgBean;
import com.mints.goodmoney.mvp.model.BannerBean;
import com.mints.goodmoney.mvp.model.BaseResponse;
import com.mints.goodmoney.mvp.model.CommonParamBean;
import com.mints.goodmoney.mvp.model.DrawcashBean;
import com.mints.goodmoney.mvp.model.DrawcashRecordBean;
import com.mints.goodmoney.mvp.model.FriendHallMsgBean;
......@@ -526,6 +527,22 @@ public interface LoanService {
@POST("api/innerApp")
Observable<BaseResponse<JsonObject>> innerApp();
/**
* 获取珊瑚cpd试玩时间
*
* @return
*/
@POST("api/getCPDBaseMsg")
Observable<BaseResponse<JsonObject>> getShCpdTime();
/**
* 获取用户配置信息
*
* @return
*/
@POST("common/commonMainMsg")
Observable<BaseResponse<CommonParamBean>> getCommonHallBaseMsg(@Body Map<String, Object> vo);
/**
* 默认http工厂
*/
......
......@@ -43,6 +43,8 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
override fun initViewsAndEvents() {
ZhangyueManager.onCreateIreader(baseApplication)
showShortVedioLayout()
if (moneyFragment == null) {
moneyFragment = MoneyFragment()
}
......
......@@ -12,6 +12,7 @@ import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.common.DeviceInfo
import com.mints.goodmoney.manager.TrackManager
import com.mints.goodmoney.manager.UserManager
import com.mints.goodmoney.manager.YlhAdManager
import com.mints.goodmoney.ui.activitys.base.BaseActivity
......@@ -63,6 +64,8 @@ class SplashYlhActivity : BaseActivity(), SplashADListener {
finish()
return
}
TrackManager.getInstance().getCommonHallBaseMsg()
// 校验APP签名
checkAppSign()
}
......
......@@ -13,6 +13,9 @@ import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.AppTryPlayManager
import com.mints.goodmoney.manager.DownloadApkManager
import com.mints.goodmoney.mvp.model.TzTaskBean
import com.mints.goodmoney.mvp.presenters.TaskPresenter
import com.mints.goodmoney.mvp.presenters.WalkPresenter
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
......@@ -37,13 +40,14 @@ import kotlinx.android.synthetic.main.header_layout.*
*
* 描述:试玩任务
*/
class TaskActivity : BaseActivity(),
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 mTaskList: MutableList<CoralAD> = arrayListOf()
......@@ -66,13 +70,12 @@ class TaskActivity : BaseActivity(),
companion object {
const val TASK_COIN = "task_coin"
const val TASK_USE_TIME = "task_use_time"
const val TASK_USE_MAX = "task_use_max"
const val TASK_USE_COMPLETE = "task_use_complete"
}
private var mCoin = 0
private var needUseTime = 0
private var needUseTime = -1
private var max = 3 //广告最大填充数
private var complete = 0//本地判断:领取金币,完成数+1
private var loadCountTime = 0 // 加载广告次数
......@@ -80,7 +83,6 @@ class TaskActivity : BaseActivity(),
override fun getBundleExtras(extras: Bundle) {
super.getBundleExtras(extras)
mCoin = extras.getInt(TASK_COIN)
needUseTime = extras.getInt(TASK_USE_TIME)
max = extras.getInt(TASK_USE_MAX, 3)
complete = extras.getInt(TASK_USE_COMPLETE, 0)
}
......@@ -88,6 +90,8 @@ class TaskActivity : BaseActivity(),
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)
......@@ -123,7 +127,9 @@ class TaskActivity : BaseActivity(),
DownloadApkManager.tryOnceInstallApk()
try {
refreshDemoTask()
if (needUseTime != -1) {
refreshDemoTask()
}
} catch (e: Exception) {
LogUtil.e(e.printStackTrace())
}
......@@ -131,6 +137,25 @@ class TaskActivity : BaseActivity(),
override fun isApplyKitKatTranslucency() = false
override fun getShCpdTimeSuc(time: Int) {
needUseTime = time
if (complete >= max) {
showToast("今日任务已完成,请明日再试")
finish()
return
}
showLoading("加载中...")
mFakeTaskList.clear()
mTaskList.clear()
for (i in 0 until max - complete) {
loadCountTime = i
mCoralDownload?.pull()
}
}
override fun onRefresh(refreshLayout: RefreshLayout) {
loadData()
}
......@@ -200,6 +225,8 @@ class TaskActivity : BaseActivity(),
mContext.unregisterReceiver(mReceiverBroadcastReceiver)
}
taskPresenter.detachView()
super.onDestroy()
}
......@@ -284,6 +311,8 @@ class TaskActivity : BaseActivity(),
}
private fun clickDialog(position: Int) {
if (needUseTime == -1) return
taskDialog = TaskDialog(this)
taskDialog?.setData(mTaskList[position], needUseTime, mCoin)
taskDialog?.show()
......@@ -336,6 +365,18 @@ class TaskActivity : BaseActivity(),
val currentPkgName = mFakeTaskList[position].currentPkgName
if (currentPkgName != null) {
// 时间为0
if (needUseTime == 0) {
mFakeTaskList[position].state = 2
it.notifyItemChanged(position)
// 上报激活完成
mDownloadProcess?.reportAppActivated()
return
}
if (AppTryPlayManager.getTryPlayIsOK(currentPkgName, needUseTime)) {
// 完成试玩任务
mFakeTaskList[position].state = 2
......@@ -368,20 +409,7 @@ class TaskActivity : BaseActivity(),
}
private fun loadData() {
if (complete >= max) {
showToast("今日任务已完成,请明日再试")
finish()
return
}
showLoading("加载中...")
mFakeTaskList.clear()
mTaskList.clear()
for (i in 0 until max - complete) {
loadCountTime = i
mCoralDownload?.pull()
}
taskPresenter.getShCpdTime()
}
private fun backDialog() {
......@@ -430,4 +458,6 @@ class TaskActivity : BaseActivity(),
// 上报下载成功
mDownloadProcess?.reportDownloadSuccess(path, false)
}
}
\ No newline at end of file
......@@ -56,9 +56,7 @@ class DrawcashAdapter(val priceList: MutableList<DrawcashBean.CashOutMoneyArrBea
} else {
holder.tvDrawItemCash.text = "${priceBean.money}元"
}
if (priceBean.money == 0.3) {
holder.tvDrawItemHint.text = remark
}
holder.tvDrawItemHint.text = priceBean.remark
holder.tvDrawItemGold.text = "约${String.format("%.0f", priceBean.money * 10000)}金币"
holder.llDrawItem.setOnClickListener {
......
......@@ -224,12 +224,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
ChannelManager.updataCodeIdForRegisterChannel(data.adcode)
// 隐藏 短视频、首页视频、书城
val activity: MainActivity? = activity as MainActivity?
activity?.let {
it.showShortVedioLayout()
}
// 新人福利 放到个人中心展示 防止首页红包转动异常
// 设置视频权重
......
......@@ -464,7 +464,6 @@ class MyFragment : BaseFragment(),
val bundle = Bundle()
bundle.putInt(TaskActivity.TASK_COIN, taskBean.otherConfig.coin)
bundle.putInt(TaskActivity.TASK_USE_TIME, taskBean.otherConfig.needSeconds)
bundle.putInt(TaskActivity.TASK_USE_MAX, taskBean.otherConfig.max)
bundle.putInt(TaskActivity.TASK_USE_COMPLETE, taskBean.otherConfig.complete)
readyGo(TaskActivity::class.java, bundle)
......@@ -911,7 +910,6 @@ class MyFragment : BaseFragment(),
if (listBean.baseConfig.taskId == MainMyAdapter.TO_SHARE_NEWS) {
val bundle = Bundle()
bundle.putInt(TaskActivity.TASK_COIN, listBean.otherConfig.coin)
bundle.putInt(TaskActivity.TASK_USE_TIME, listBean.otherConfig.needSeconds)
bundle.putInt(TaskActivity.TASK_USE_MAX, listBean.otherConfig.max)
bundle.putInt(TaskActivity.TASK_USE_COMPLETE, listBean.otherConfig.complete)
readyGo(TaskActivity::class.java, bundle)
......
......@@ -144,7 +144,6 @@ class PanFragment : BaseFragment(), PanView {
val bundle = Bundle()
bundle.putInt(TaskActivity.TASK_COIN, panActionInfo.coin)
bundle.putInt(TaskActivity.TASK_USE_TIME, panActionInfo.time)
bundle.putInt(TaskActivity.TASK_USE_MAX, panActionInfo.max)
bundle.putInt(TaskActivity.TASK_USE_COMPLETE, panActionInfo.complete)
readyGo(TaskActivity::class.java, bundle)
......
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