Commit 5780ffd9 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 9c361906
...@@ -15,8 +15,8 @@ android { ...@@ -15,8 +15,8 @@ android {
applicationId "com.mints.goodmoney" applicationId "com.mints.goodmoney"
minSdkVersion rootProject.ext.androidMinSdkVersion minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 33 versionCode 34
versionName "1.3.3" versionName "1.3.4"
flavorDimensions "default" flavorDimensions "default"
// dex突破65535的限制 // dex突破65535的限制
......
package com.mints.goodmoney.manager package com.mints.goodmoney.manager
import com.mints.goodmoney.mvp.model.AdcodeBean import com.mints.goodmoney.mvp.model.AdcodeBean
import com.mints.goodmoney.mvp.model.UserMsgBean
/** /**
* 渠道管理 * 渠道管理
...@@ -16,5 +15,6 @@ object ChannelManager { ...@@ -16,5 +15,6 @@ object ChannelManager {
fun updataCodeIdForRegisterChannel(idBean: AdcodeBean?) { fun updataCodeIdForRegisterChannel(idBean: AdcodeBean?) {
TtCsjAdManager.updataIdByChannel(idBean) TtCsjAdManager.updataIdByChannel(idBean)
YlhAdManager.updataIdByChannel(idBean) YlhAdManager.updataIdByChannel(idBean)
CsjGroMoreManager.updataIdByChannel(idBean)
} }
} }
\ No newline at end of file
package com.mints.goodmoney.manager package com.mints.goodmoney.manager
import android.text.TextUtils
import com.mints.goodmoney.MintsApplication import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.mvp.model.AdcodeBean
object CsjGroMoreManager { object CsjGroMoreManager {
const val AD_UNIT_EXPRESS_ID = "946167770" var AD_UNIT_EXPRESS_ID = "946167770"
const val AD_UNIT_SPLASH_ID = "887459392" var AD_UNIT_SPLASH_ID = "887459392"
const val AD_UNIT_VIDEO_ID = "946018378" var AD_UNIT_VIDEO_ID = "946018378"
fun init(application: MintsApplication) { fun init(application: MintsApplication) {
TTGroMoreAdManagerHolder.init(application) TTGroMoreAdManagerHolder.init(application)
} }
/**
* 更新代码位
*/
fun updataIdByChannel(idBean: AdcodeBean?) {
// 渠道对象不为空
if (idBean != null) {
if (!TextUtils.isEmpty(idBean.groExpress)) {
AD_UNIT_EXPRESS_ID = idBean.groExpress
}
if (!TextUtils.isEmpty(idBean.groSplash)) {
AD_UNIT_SPLASH_ID = idBean.groSplash
}
if (!TextUtils.isEmpty(idBean.groVideo)) {
AD_UNIT_VIDEO_ID = idBean.groVideo
}
}
}
} }
\ No newline at end of file
...@@ -14,15 +14,12 @@ public class AdcodeBean implements Serializable { ...@@ -14,15 +14,12 @@ public class AdcodeBean implements Serializable {
private String ylhv1;//开屏 private String ylhv1;//开屏
private String ylhv2;//激励 private String ylhv2;//激励
private String shareylhv1;
private String shareylhv2;
private String shareylhv3;
private String sharecsjv1;
private String sharecsjv2;
private String sharecsjv3;
private String key; private String key;
private String groExpress;
private String groSplash;
private String groVideo;
public String getCsjv1() { public String getCsjv1() {
return csjv1; return csjv1;
...@@ -48,28 +45,16 @@ public class AdcodeBean implements Serializable { ...@@ -48,28 +45,16 @@ public class AdcodeBean implements Serializable {
return ylhv2; return ylhv2;
} }
public String getShareylhv1() { public String getGroExpress() {
return shareylhv1; return groExpress;
}
public String getShareylhv2() {
return shareylhv2;
}
public String getShareylhv3() {
return shareylhv3;
}
public String getSharecsjv1() {
return sharecsjv1;
} }
public String getSharecsjv2() { public String getGroSplash() {
return sharecsjv2; return groSplash;
} }
public String getSharecsjv3() { public String getGroVideo() {
return sharecsjv3; return groVideo;
} }
public String getKey() { public String getKey() {
......
...@@ -97,7 +97,7 @@ public class SplashGroMoreActivity extends BaseActivity { ...@@ -97,7 +97,7 @@ public class SplashGroMoreActivity extends BaseActivity {
//穿山甲兜底 //穿山甲兜底
// ttNetworkRequestInfo = new PangleNetworkRequestInfo(TtCsjAdManager.TT_AD_APPID, "887483103"); // ttNetworkRequestInfo = new PangleNetworkRequestInfo(TtCsjAdManager.TT_AD_APPID, "887483103");
//gdt兜底 //gdt兜底
ttNetworkRequestInfo = new GdtNetworkRequestInfo(YlhAdManager.YLH_AD_APPID, "2001697222975737"); // ttNetworkRequestInfo = new GdtNetworkRequestInfo(YlhAdManager.YLH_AD_APPID, "2001697222975737");
//ks兜底 //ks兜底
// ttNetworkRequestInfo = new KsNetworkRequestInfo("90009", "4000000042"); // ttNetworkRequestInfo = new KsNetworkRequestInfo("90009", "4000000042");
//百度兜底 //百度兜底
...@@ -105,7 +105,8 @@ public class SplashGroMoreActivity extends BaseActivity { ...@@ -105,7 +105,8 @@ public class SplashGroMoreActivity extends BaseActivity {
//step4:请求广告,调用开屏广告异步请求接口,对请求回调的广告作渲染处理 //step4:请求广告,调用开屏广告异步请求接口,对请求回调的广告作渲染处理
mTTSplashAd.loadAd(adSlot, ttNetworkRequestInfo, new TTSplashAdLoadCallback() { // mTTSplashAd.loadAd(adSlot, ttNetworkRequestInfo, new TTSplashAdLoadCallback() {
mTTSplashAd.loadAd(adSlot, new TTSplashAdLoadCallback() {
@Override @Override
public void onSplashAdLoadFail(AdError adError) { public void onSplashAdLoadFail(AdError adError) {
LogUtil.d(TAG, adError.message); LogUtil.d(TAG, adError.message);
...@@ -125,14 +126,12 @@ public class SplashGroMoreActivity extends BaseActivity { ...@@ -125,14 +126,12 @@ public class SplashGroMoreActivity extends BaseActivity {
// 获取本次waterfall加载中,加载失败的adn错误信息。 // 获取本次waterfall加载中,加载失败的adn错误信息。
if (mTTSplashAd != null) { HashMap<String, Object> vo = new HashMap<>();
HashMap<String, Object> vo = new HashMap<>(); vo.put("adcode", mTTSplashAd.getAdNetworkRitId());
vo.put("adcode",mTTSplashAd.getAdNetworkRitId()); vo.put("ecpm", mTTSplashAd.getPreEcpm());
vo.put("ecpm",mTTSplashAd.getPreEcpm()); vo.put("adSource", mTTSplashAd.getAdNetworkPlatformId());
vo.put("adSource",mTTSplashAd.getAdNetworkPlatformId()); vo.put("adType", Constant.GRO_MORE_ADTYPE0);
vo.put("adType",Constant.GRO_MORE_ADTYPE0); TrackManager.getInstance().cmtGroMoreInfo(vo);
TrackManager.getInstance().cmtGroMoreInfo(vo);
}
} }
Log.e(TAG, "load splash ad success "); Log.e(TAG, "load splash ad success ");
} }
......
package com.mints.goodmoney.ui.fragment
import android.Manifest
import android.os.Bundle
import android.text.TextUtils
import android.webkit.WebChromeClient
import com.component.dly.xzzq_ywsdk.YwSDK_WebActivity
import com.github.lzyzsd.jsbridge.CallBackFunction
import com.github.lzyzsd.jsbridge.DefaultHandler
import com.mints.goodmoney.BuildConfig
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.MokuManager
import com.mints.goodmoney.manager.UserManager
import com.mints.goodmoney.manager.YwhzManager
import com.mints.goodmoney.mvp.model.PanActionInfo
import com.mints.goodmoney.mvp.model.TurntableBean
import com.mints.goodmoney.mvp.presenters.PanPresenter
import com.mints.goodmoney.mvp.views.PanView
import com.mints.goodmoney.ui.activitys.*
import com.mints.goodmoney.ui.fragment.base.BaseFragment
import com.mints.library.utils.json.JsonUtil
import com.tbruyelle.rxpermissions.RxPermissions
import kotlinx.android.synthetic.main.fragment_main_pan.*
import net.grandcentrix.tray.AppPreferences
/**
* 描述:大转盘
* 作者:孟崔广
* 时间:2020/9/20 17:30
*/
class PanFragment : BaseFragment(), PanView {
private val panPresenter by lazy { PanPresenter() }
private val userManager by lazy { UserManager.getInstance() }
private val carrierType = Constant.CARRIER_CHALLENGE_TURN
private val ps by lazy { AppPreferences(context) }
override fun getContentViewLayoutID() = R.layout.fragment_main_pan
override fun initViewsAndEvents() {
panPresenter.attachView(this)
if (!TextUtils.isEmpty(userManager.userID)) {
// 登录成功的用户初始化鱼丸盒子
// if (userManager.userIsLogin()) {
// YwhzManager.init(baseApplication)
// }
if (!TextUtils.isEmpty(MintsApplication.OAID)) {
MokuManager.initOaid(MintsApplication.OAID)
}
}
}
override fun onHiddenChanged(hidden: Boolean) {
if (hidden) { // 不在最前端界面显示
onPause()
} else { // 重新显示到最前端中
onResume()
}
super.onHiddenChanged(hidden)
}
override fun onResume() {
super.onResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_THREE) {
if (TextUtils.isEmpty(userManager?.userID)) {
// 游客登录
panPresenter.userLogin()
} else {
loadTurnUrl()
}
}
}
override fun onDestroy() {
super.onDestroy()
panPresenter.detachView()
}
override fun loginSuc() {
loadTurnUrl()
}
/**
* 加载转盘url
*/
private fun loadTurnUrl() {
getTurnUrl()
// blTurntableWebview.setOnTouchListener { _, event -> event.action == MotionEvent.ACTION_MOVE }
blTurntableWebview.setDefaultHandler(DefaultHandler())
blTurntableWebview.webChromeClient = WebChromeClient()
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// blTurntableWebview.setOnScrollChangeListener(
// object : View.OnScrollChangeListener {
// override fun onScrollChange(v: View?, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) {
// blTurntableWebview.scrollTo(0,scrollY)
// }
// })
// }
blTurntableWebview.setOnLongClickListener { true }
//注册监听方法当js中调用callHandler方法时会调用此方法(handlerName必须和js中相同)
blTurntableWebview.registerHandler("getTurnResult") { data, _ ->
val turntableBean: TurntableBean = JsonUtil.parseJson(data, TurntableBean::class.java)
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, turntableBean.coin)
bundle.putString(Constant.MAIN_CARRIER_TYPE, carrierType)
bundle.putString(Constant.MAIN_EXTRA_ID, turntableBean.key)
readyGo(AwardActivity::class.java, bundle)
androidCallJsReferse()
}
blTurntableWebview.registerHandler("actionPageForType") { data, _ ->
actionPageForType(data)
}
blTurntableWebview.setDefaultHandler(object : DefaultHandler() {
override fun handler(data: String, function: CallBackFunction) {
showToast(data)
}
})
}
private fun actionPageForType(data: String?) {
if (TextUtils.isEmpty(data)) return
val panActionInfo: PanActionInfo = JsonUtil.parseJson(data, PanActionInfo::class.java)
//0-微转,1-珊瑚下载,2-分红,3-鱼丸盒子,4-每日任务
when (panActionInfo.actionType) {
0 -> {
if (!userManager.userIsLogin()) {
readyGo(WxLoginActivity::class.java)
return
}
shareArticle(panActionInfo.coin)
}
1 -> {
if (!userManager.userIsLogin()) {
readyGo(WxLoginActivity::class.java)
return
}
readyGo(TaskCpdActivity::class.java)
}
2 -> {
if (!userManager.userIsLogin()) {
readyGo(WxLoginActivity::class.java)
return
}
val bundle = Bundle()
bundle.putInt(Constant.WRAPPER_TYPE, Constant.WRAPPER_TYPE_FRIENDS)
readyGo(WrapperActivity::class.java, bundle)
}
3 -> {
// if (!userManager.userIsLogin()) {
// readyGo(WxLoginActivity::class.java)
// return
// }
//
// try {
// activity?.let { YwSDK_WebActivity.open(it) }
// } catch (e: Exception) {
// e.printStackTrace()
// showToast("请重新退出账号登录")
// }
gotoMoku()
}
4 -> {
val activity: MainActivity? = activity as MainActivity?
activity?.let {
it.turnDayTask()
}
}
}
}
/**
* 获取转盘url
*/
private fun getTurnUrl() {
val tokenID = userManager.tokenID
val url: String = BuildConfig.MainIp + "turn/turnWithInner.html?carrierType=" + carrierType + "&token=" + tokenID
blTurntableWebview.loadUrl(url)
}
/**
* 奖励成功刷新js界面
*/
private fun androidCallJsReferse() {
// 调用js中的方法(必须和js中的handlerName想同)
blTurntableWebview.callHandler("refreshTurnTable", "") {
}
}
/**
* 分享文章
*/
private fun shareArticle(coin: Int) {
val bundle = Bundle()
bundle.putInt(Constant.WRAPPER_TYPE, Constant.WRAPPER_TYPE_WZ)
readyGo(WrapperActivity::class.java, bundle)
}
private fun gotoMoku() {
RxPermissions(requireActivity())
.request(Manifest.permission.READ_PHONE_STATE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe { granted: Boolean ->
if (granted) {
MokuManager.gotoMoku(requireContext())
if (ps.getBoolean(Constant.MOKU_FLAG_GUIDE, true)) {
readyGo(MokuGuideActivity::class.java)
ps.put(Constant.MOKU_FLAG_GUIDE, false)
}
} else {
showMissingPermissionDialog("设备,存储")
}
}
}
}
\ No newline at end of file
...@@ -123,7 +123,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick ...@@ -123,7 +123,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
turnTableView.setRotateListener(null)
turnTablePresenter.detachView() turnTablePresenter.detachView()
} }
...@@ -170,8 +169,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick ...@@ -170,8 +169,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick
return return
} }
LogUtil.d("initTurnView", "initTurnView")
turnTableData = data turnTableData = data
if (data.configs.size == 0) { if (data.configs.size == 0) {
...@@ -236,11 +233,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick ...@@ -236,11 +233,6 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick
override fun rotating(valueAnimator: ValueAnimator) {} override fun rotating(valueAnimator: ValueAnimator) {}
override fun rotateBefore(goImg: ImageView) { override fun rotateBefore(goImg: ImageView) {
if (!NetUtils.isNetworkConnected(context)) {
showToast("网络异常,请检测网络")
return
}
if (data.surplus <= 0) { if (data.surplus <= 0) {
showToast("抽奖次数已用完") showToast("抽奖次数已用完")
return return
......
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