Commit 9b0e4e95 authored by mengcuiguang2's avatar mengcuiguang2

代码优化,删除无用资源

parent 663594f8
......@@ -13,8 +13,8 @@ android {
applicationId "com.mints.goodmoney"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 36
versionName "1.3.6"
versionCode 37
versionName "1.3.7"
flavorDimensions "default"
// dex突破65535的限制
......@@ -225,9 +225,9 @@ dependencies {
// 数美
implementation files('libs/smantifraud.aar')
// 猎豹游戏
implementation(name: 'cmgame-sdk-tt3500-2.0.9_v20210423', ext: 'aar')
implementation(name: 'x5fit-2.0.7', ext: 'aar')
implementation(name: 'gdtfit-2.0.9', ext: 'aar')
// implementation(name: 'cmgame-sdk-tt3500-2.0.9_v20210423', ext: 'aar')
// implementation(name: 'x5fit-2.0.7', ext: 'aar')
// implementation(name: 'gdtfit-2.0.9', ext: 'aar')
// 鱼丸盒子
implementation(name: 'xzzq_ywsdk_1.1.0', ext: 'aar')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0"
......
......@@ -168,9 +168,6 @@
<activity
android:name=".ui.activitys.GuideActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.LiebaoGameActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.DrawcashActivity"
android:screenOrientation="portrait" />
......
......@@ -13,7 +13,6 @@ import androidx.multidex.MultiDexApplication;
import com.hjq.toast.ToastUtils;
import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.manager.KsManager;
import com.mints.goodmoney.manager.LiebaoManager;
import com.mints.goodmoney.manager.MhManager;
import com.mints.goodmoney.manager.MiitHelper;
import com.mints.goodmoney.manager.OwManager;
......@@ -144,9 +143,6 @@ public class MintsApplication extends MultiDexApplication {
//小满
XmManager.INSTANCE.initXm(this);
// 猎豹游戏初始化
LiebaoManager.getInstance().initCmGameSdk();
// 瑞狮新闻
RsNewsManager.INSTANCE.init(this);
......
package com.mints.goodmoney.manager;
import android.content.Context;
import com.cmcm.cmgame.CmGameSdk;
import com.cmcm.cmgame.gamedata.CmGameAppInfo;
import com.mints.goodmoney.BuildConfig;
import com.mints.goodmoney.MintsApplication;
import com.mints.goodmoney.utils.CmGameImageLoader;
/**
* 描述:猎豹游戏
* 作者:孟崔广
* 时间:2020/10/10 11:29
* 邮箱:mengcga@163.com
*/
public class LiebaoManager {
/**
* APP_ID
*/
public static final String APP_ID = "haozhuanqian";
/**
* APP_HOST
*/
public static final String APP_HOST = "https://haozhuanqian-xyx-big-svc.beike.cn";
private static LiebaoManager _inst;
private Context context;
public static LiebaoManager getInstance() {
if (_inst != null) {
return _inst;
} else {
_inst = new LiebaoManager();
return _inst;
}
}
private LiebaoManager() {
init();
}
private void init() {
context = MintsApplication.getContext();
}
/**
* 游戏SDK初始化
*/
public void initCmGameSdk() {
// final String adAppId = TtCsjAdManager.TT_AD_APPID; // 穿山甲appid
// TTAdSdk.init(context,
// new TTAdConfig.Builder()
// .appId(adAppId)
// .useTextureView(false) //使用TextureView控件播放视频,默认为SurfaceView,当有SurfaceView冲突的场景,可以使用TextureView
// .appName(TtCsjAdManager.TT_AD_NAME)
// .titleBarTheme(TTAdConstant.TITLE_BAR_THEME_DARK)
// .allowShowNotify(true) //是否允许sdk展示通知栏提示
// .allowShowPageWhenScreenLock(true) //是否在锁屏场景支持展示广告落地页
// .debug(BuildConfig.DEBUG) //测试阶段打开,可以通过日志排查问题,上线时去除该调用
// .directDownloadNetworkType(TTAdConstant.NETWORK_STATE_WIFI, TTAdConstant.NETWORK_STATE_3G) //允许直接下载的网络状态集合
// .supportMultiProcess(false) //是否支持多进程,true支持
// .build(), new TTAdSdk.InitCallback() {
// @Override
// public void success() {
//
// }
//
// @Override
// public void fail(int i, String s) {
//
// }
// });
CmGameAppInfo cmGameAppInfo = new CmGameAppInfo();
cmGameAppInfo.setAppId(APP_ID); // GameSdkID,向我方申请
cmGameAppInfo.setAppHost(APP_HOST); // 游戏host地址,向我方申请
// 设置游戏的广告id
CmGameAppInfo.TTInfo ttInfo = new CmGameAppInfo.TTInfo();
// 游戏内广告有如下6种;
ttInfo.setGameLoad_EXADId(TtCsjAdManager.TT_AD_INSERT_LOADING_ID_LIEBAO); // 游戏加载时,插屏广告1:1,模板渲染
ttInfo.setRewardVideoId(TtCsjAdManager.TT_AD_VEDIO_GAME); // 激励视频
ttInfo.setFullVideoId(TtCsjAdManager.TT_AD_ALLVEDIO_ID_LIEBAO); // 全屏视频,插屏场景下展示
// ttInfo.setExpressInteractionId(TtCsjAdManager.TT_AD_INSERT_ID_LIEBAO); // 插屏广告,插屏场景下展示,模板渲染,2:3
// ttInfo.setExpressBannerId("901121159"); // Banner广告,模板渲染,尺寸:600*150,会导致游戏卡慢,暂时不用
ttInfo.setGameEndExpressFeedAdId(TtCsjAdManager.TT_AD_NATIVEEXPRESS_ID_LIEBAO_LISTEXIT); // 游戏退出弹框,信息流广告,模板渲染
// 游戏列表页面有如下2种:
ttInfo.setGameListExpressFeedId(TtCsjAdManager.TT_AD_NATIVEEXPRESS_ID_LIEBAO_LISTEXIT); // 游戏列表,信息流广告,模板渲染
// ttInfo.setGamelistExpressInteractionId("901121536"); // 模板渲染1:1,不能用于游戏tab页的入口
cmGameAppInfo.setTtInfo(ttInfo);
// 需要支持广点通广告时,才需下面代码
// 【设置广点通广告id】
CmGameAppInfo.GDTAdInfo gdtAdInfo = new CmGameAppInfo.GDTAdInfo();
gdtAdInfo.setAppId(YlhAdManager.YLH_AD_APPID); // 广点通的APPID
// 游戏内广告场景;
gdtAdInfo.setRewardVideoId(YlhAdManager.INSTANCE.getYLH_AD_VEDIO_GAME_POSTID()); // 激励视频
gdtAdInfo.setGameLoadInterId(YlhAdManager.INSTANCE.getYLH_AD_INTERSTITIALAD_LIEBAO());//游戏加载中的插屏
// gdtAdInfo.setBannerId(YlhAdManager.YLH_AD_BANNER_LIEBAO); // banner广告
gdtAdInfo.setPlayGameInterId(YlhAdManager.INSTANCE.getYLH_AD_INTERSTITIALAD_LIEBAO());//游戏进行中关卡插屏
cmGameAppInfo.setGdtAdInfo(gdtAdInfo);
//
// // 【设置广点通和穿山甲广告占比】
// // 概率设置规则,如下:
// // 0: 全部使用穿山甲广告
// // 100: 全部采用广点通广告
// // 40:穿山甲广告命中概率是60%,广点通是40%,如果一方没广告,则用另一方补量。
cmGameAppInfo.setRewardAdProbability(40); // 默认值为0,全部采用穿山甲激励视频广告
//
//
// // 戏关卡间插屏广告概率设置建议,代码默认值为20
// // 1)80%流量给穿山甲,20%给优量汇,原因:穿山甲全屏视频广告收益更高,优量汇收益低但体验 好
// // 2)概率云端控制,媒体自行下发2种广告源占比
cmGameAppInfo.setExpressInterAdProbability(60);
// 功能默认开启,可使用如下方法来关闭
// cmGameAppInfo.setShowLogin(false);
// 退出弹窗确认窗口,但不需要游戏推荐内容,该场景使用于网赚场景,因为需要退出后立即给用户奖励。
cmGameAppInfo.setQuitGameConfirmRecommand(false);
// 游戏退出确认弹窗,增加自定义文案,颜色也可以根据自己需要调整
cmGameAppInfo.setQuitGameConfirmTip("<font color=\"#ef0d12\">主人,下次可在“个人中心”找到我哦~</font>");
CmGameSdk.initCmGameSdk((MintsApplication) this.context, cmGameAppInfo, new CmGameImageLoader(), BuildConfig.DEBUG);
}
/**
* 获取最新游戏信息和生成游戏游客账号
* <p>
* 如下方法,用于获取最新游戏信息和生成游戏游客账号,生成游客账号后,才能成功进入游戏。
* 调用时机:自定义游戏界面或者调用单独游戏,需要进入游戏前,调用此方法。
* 使用sdk提供的默认游戏列表,是不需要调用此方法,内部已经封装调用。
* 此方法多次调用,不影响,但不能在后台进程调用。
*/
public void initCmGameAccount() {
CmGameSdk.initCmGameAccount();
}
/**
* 登录账号后,APP需要传入保存的loginInfo信息
*
* @param userInfo
*/
public void restoreCmGameAccount(String userInfo) {
CmGameSdk.restoreCmGameAccount(userInfo);
}
/**
* 用户退出账号时,APP调用清除游戏账号信息的接口,清除游戏本地游戏数据
*/
public void clearCmGameAccount() {
CmGameSdk.clearCmGameAccount();
}
/**
* 调起指定游戏
*
* @param gameId
*/
public void startH5Game(String gameId) {
CmGameSdk.startH5Game(gameId);
}
}
package com.mints.goodmoney.ui.activitys
import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat
import com.cmcm.cmgame.*
import com.google.gson.JsonParser
import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.mvp.presenters.GamePresenter
import com.mints.goodmoney.mvp.views.GameView
import com.mints.goodmoney.ui.activitys.base.BaseActivity
import com.mints.goodmoney.utils.SpanUtils
import com.mints.library.utils.json.JsonUtil
import kotlinx.android.synthetic.main.activity_liebao_game.*
import kotlinx.android.synthetic.main.header_layout.*
import java.util.*
/**
* 描述:猎豹游戏
* 作者:孟崔广
* 时间:2020/10/12 10:09
*/
class LiebaoGameActivity : BaseActivity(),
View.OnClickListener,
GameView,
IAppCallback,
IGamePlayTimeCallback,
IGameAdCallback,
IGameExitInfoCallback {
val AIP_GAME_URL = "api/gametime/add" //退出游戏
val STASTICIS_GAME_URL = "stasticis/game/add" //点击游戏
private val gamePresenter by lazy { GamePresenter() }
private var gameName = ""
private var gameID = ""
override fun getContentViewLayoutID() = R.layout.activity_liebao_game
override fun isApplyKitKatTranslucency() = false
override fun initViewsAndEvents() {
tv_title.text = "游戏推荐"
iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
gamePresenter.attachView(this)
initListener()
}
override fun onResume() {
super.onResume()
gamePresenter.getGameInfo()
}
override fun onDestroy() {
super.onDestroy()
CmGameSdk.removeGameClickCallback()
CmGameSdk.setMoveView(null)
CmGameSdk.removeGamePlayTimeCallback()
CmGameSdk.removeGameAdCallback()
CmGameSdk.removeGameExitInfoCallback()
gamePresenter.detachView()
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.iv_left_icon -> finish()
}
}
private fun initListener() {
iv_left_icon.setOnClickListener(this)
gvGameLiebao.inflate(this)
// 默认游戏中心页面,点击游戏试,触发回调
CmGameSdk.setGameClickCallback(this)
// 点击游戏右上角或物理返回键,退出游戏时触发回调,并返回游戏时长
CmGameSdk.setGamePlayTimeCallback(this)
// 所有广告类型的展示和点击事件回调,仅供参考,数据以广告后台为准
CmGameSdk.setGameAdCallback(this)
// 返回游戏数据(json格式),如:每玩一关,返回关卡数,分数,如钓钓乐,返回水深,绳子长度,不同游戏不一样
// 该功能使用场景:媒体利用游戏数据,和app的功能结合做运营活动,比如:某每天前50名,得到某些奖励
CmGameSdk.setGameExitInfoCallback(this)
}
override fun gameInfo(sumTime: Int, sumCoin: Int, gameTime: Int) {
if (!isFinishing) {
tvGameHint.visibility = View.VISIBLE
if (gameTime >= sumTime) {
tvGameHint.text = "今日游戏任务已完成"
} else {
tvGameHint.text = SpanUtils()
.append("畅玩").append("${sumTime / 60}").setForegroundColor(ContextCompat.getColor(mContext, R.color.color_FF9837)).append("分钟, ")
.append("奖励").append("$sumCoin").setForegroundColor(ContextCompat.getColor(mContext, R.color.color_cb4a39)).append("金币, ")
.append("已玩").append("${gameTime / 60}").setForegroundColor(ContextCompat.getColor(mContext, R.color.color_FF9837)).append("分钟")
.create()
}
}
}
override fun gameAddSuc(eventType: String?, data: Any?) {
when (eventType) {
Constant.EVENT_TYPE_TIME -> if (data != null) {
val json = JsonUtil.toJson(data)
val jsonObject = JsonParser().parse(json).asJsonObject
val gameCoin = jsonObject["gameCoin"].asInt
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, gameCoin)
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_GAME)
readyGo(AwardActivity::class.java, bundle)
}
Constant.EVENT_TYPE_GAMEINFO -> {
}
Constant.EVENT_TYPE_CLICK -> {
}
}
}
/**
* 默认游戏中心页面,点击游戏试,触发回调 finish
*
* @param gameName
* @param gameID
*/
override fun gameClickCallback(gameName: String, gameID: String) {
this.gameName = gameName
this.gameID = gameID
val eventTypeClick: String = Constant.EVENT_TYPE_CLICK
val vo = HashMap<String, Any>()
vo["gameName"] = gameID
vo["gameId"] = gameID
vo["gameSource"] = "liebao"
vo["carrierType"] = Constant.CARRIER_GAME
vo["eventType"] = eventTypeClick
vo["num"] = 1
vo["pkg"] = Constant.MINTS_PKG_NAME
gamePresenter.gameAdd(STASTICIS_GAME_URL, eventTypeClick, vo)
}
/**
* @param playTimeInSeconds 玩游戏时长,单位为秒 finish
*
*
* 点击游戏右上角或物理返回键,退出游戏时触发回调,并返回游戏时长
*/
override fun gamePlayTimeCallback(gameId: String?, playTimeInSeconds: Int) {
val eventTypeTime: String = Constant.EVENT_TYPE_TIME
if (playTimeInSeconds < 3) {
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, 0)
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_GAME)
readyGo(AwardActivity::class.java, bundle)
} else {
val vo = HashMap<String, Any>()
vo["gameName"] = gameID
vo["gameId"] = gameID
vo["gameSource"] = "liebao"
vo["carrierType"] = Constant.CARRIER_GAME
vo["eventType"] = eventTypeTime
vo["playtimeinseconds"] = playTimeInSeconds
vo["pkg"] = Constant.MINTS_PKG_NAME
gamePresenter.gameAdd(AIP_GAME_URL, eventTypeTime, vo)
}
}
/**
* 广告曝光/点击回调 finish
*
* @param gameId 游戏Id
* @param adType 广告类型:1:激励视频广告;2:Banner广告;3:原生Banner广告;4:全屏视频广告;
* 5:原生插屏广告;6:开屏大卡广告;7:模板Banner广告;8:模板插屏广告;9:游戏列表信息流广告
* 10:游戏列表模板插屏广告;11:游戏加载模板插屏广告;12:游戏列表信息流模板渲染广告;
* 13:游戏退出推荐弹框信息流自渲染广告;14:游戏退出推荐弹框信息流模板渲染广告
* @param adAction 广告操作:1:曝光;2:点击;3:关闭;4:跳过
* @param adChannel 广告源:穿山甲,优量汇
*/
override fun onGameAdAction(gameId: String?, adType: Int, adAction: Int, adChannel: String) {
if (adAction != 1) {
val vo = HashMap<String, Any>()
vo["gameName"] = gameName
vo["gameId"] = gameID
vo["gameSource"] = "liebao"
vo["carrierType"] = Constant.CARRIER_GAME
var eventTypeView = "VIEW"
when (adAction) {
1 -> eventTypeView = "VIEW"
2 -> eventTypeView = "CLICK"
3 -> eventTypeView = "CLOSE"
4 -> eventTypeView = "JUMP"
}
vo["adType"] = adType
vo["adsource"] = adChannel
vo["eventType"] = eventTypeView
vo["pkg"] = Constant.MINTS_PKG_NAME
gamePresenter.gameAdd(STASTICIS_GAME_URL, Constant.EVENT_TYPE_ADCLICK, vo)
}
}
/**
* 返回游戏数据(json格式),如:每玩一关,返回关卡数,分数,如钓钓乐,返回水深,绳子长度,不同游戏不一样 finish
* 该功能使用场景:媒体利用游戏数据,和app的功能结合做运营活动,比如:某每天前50名,得到某些奖励
*/
override fun gameExitInfoCallback(gameExitInfo: String) {
// val vo = HashMap<String, Any>()
// vo["gameName"] = gameName
// vo["gameId"] = gameID
// vo["carrierType"] = Constant.CARRIER_GAME
// vo["gameExitInfo"] = gameExitInfo
// vo["pkg"] = Constant.MINTS_PKG_NAME
// gamePresenter.gameAdd(AIP_GAME_URL, Constant.EVENT_TYPE_GAMEINFO, vo)
}
}
......@@ -53,7 +53,7 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
override fun getContentViewLayoutID() = R.layout.activity_main
override fun initViewsAndEvents() {
showShortVedioLayout()
// showShortVedioLayout()
if (moneyFragment == null) {
......@@ -93,7 +93,7 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
tab_rl_one.setOnClickListener(this)
tab_rl_three.setOnClickListener(this)
tab_rl_two.setOnClickListener(this)
// tab_rl_two.setOnClickListener(this)
tab_rl_four.setOnClickListener(this)
tab_rl_five.setOnClickListener(this)
}
......@@ -141,7 +141,7 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
override fun onClick(view: View) {
when (view.id) {
R.id.tab_rl_one -> clickTab1Layout()
R.id.tab_rl_two -> clickTab2Layout()
// R.id.tab_rl_two -> clickTab2Layout()
R.id.tab_rl_four -> clickTab4Layout()
R.id.tab_rl_three -> clickTab3Layout()
R.id.tab_rl_five -> clickTab5Layout()
......@@ -160,10 +160,10 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
tab_iv_one.isSelected = true
tab_tv_one.isSelected = true
tab_iv_two.isSelected = false
tab_tv_two.isSelected = false
// tab_iv_three.isSelected = false
// tab_tv_three.isSelected = false
// tab_iv_two.isSelected = false
// tab_tv_two.isSelected = false
tab_iv_three.isSelected = false
tab_tv_three.isSelected = false
tab_iv_four.isSelected = false
tab_tv_four.isSelected = false
tab_iv_five.isSelected = false
......@@ -199,21 +199,21 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
* 点击第二个tab
*/
fun clickTab2Layout() {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_TWO
if (channelFragment == null) {
channelFragment = HorizonChannelFragment()
}
addOrShowFragment(supportFragmentManager, channelFragment!!, Constant.FRAGMENT_TAG_TWO)
tab_iv_one.isSelected = false
tab_tv_one.isSelected = false
tab_iv_two.isSelected = true
tab_tv_two.isSelected = true
// tab_iv_three.isSelected = false
// tab_tv_three.isSelected = false
tab_iv_four.isSelected = false
tab_tv_four.isSelected = false
tab_iv_five.isSelected = false
tab_tv_five.isSelected = false
// AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_TWO
// if (channelFragment == null) {
// channelFragment = HorizonChannelFragment()
// }
// addOrShowFragment(supportFragmentManager, channelFragment!!, Constant.FRAGMENT_TAG_TWO)
// tab_iv_one.isSelected = false
// tab_tv_one.isSelected = false
// tab_iv_two.isSelected = true
// tab_tv_two.isSelected = true
//// tab_iv_three.isSelected = false
//// tab_tv_three.isSelected = false
// tab_iv_four.isSelected = false
// tab_tv_four.isSelected = false
// tab_iv_five.isSelected = false
// tab_tv_five.isSelected = false
}
......@@ -254,8 +254,10 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
}
tab_iv_one.isSelected = false
tab_tv_one.isSelected = false
tab_iv_two.isSelected = false
tab_tv_two.isSelected = false
// tab_iv_two.isSelected = false
// tab_tv_two.isSelected = false
tab_iv_three.isSelected = false
tab_tv_three.isSelected = false
tab_iv_four.isSelected = true
tab_tv_four.isSelected = true
tab_iv_five.isSelected = false
......@@ -273,10 +275,10 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
addOrShowFragment(supportFragmentManager, turnTableFragment!!, Constant.FRAGMENT_TAG_THREE)
tab_iv_one.isSelected = false
tab_tv_one.isSelected = false
tab_iv_two.isSelected = false
tab_tv_two.isSelected = false
// tab_iv_three.isSelected = true
// tab_tv_three.isSelected = true
// tab_iv_two.isSelected = false
// tab_tv_two.isSelected = false
tab_iv_three.isSelected = true
tab_tv_three.isSelected = true
tab_iv_four.isSelected = false
tab_tv_four.isSelected = false
tab_iv_five.isSelected = false
......@@ -294,10 +296,10 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
addOrShowFragment(supportFragmentManager, myFragment!!, Constant.FRAGMENT_TAG_FIVE)
tab_iv_one.isSelected = false
tab_tv_one.isSelected = false
tab_iv_two.isSelected = false
tab_tv_two.isSelected = false
// tab_iv_three.isSelected = false
// tab_tv_three.isSelected = false
// tab_iv_two.isSelected = false
// tab_tv_two.isSelected = false
tab_iv_three.isSelected = false
tab_tv_three.isSelected = false
tab_iv_four.isSelected = false
tab_tv_four.isSelected = false
tab_iv_five.isSelected = true
......
package com.mints.goodmoney.ui.fragment
import android.os.Bundle
import android.view.View
import com.cmcm.cmgame.CmGameSdk
import com.cmcm.cmgame.IAppCallback
import com.cmcm.cmgame.IGameAdCallback
import com.cmcm.cmgame.IGamePlayTimeCallback
import com.google.gson.JsonParser
import com.mints.goodmoney.R
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.mvp.presenters.GamePresenter
import com.mints.goodmoney.mvp.views.GameView
import com.mints.goodmoney.ui.activitys.AwardActivity
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.SpanUtils
import com.mints.library.utils.json.JsonUtil
import kotlinx.android.synthetic.main.activity_liebao_game.*
import java.util.*
/**
* 描述:猎豹
* 作者:孟崔广
* 时间:2020/11/25 17:30
*/
class LiebaoGameFragment : LazyLoadBaseFragment(), GameView,
IAppCallback,
IGamePlayTimeCallback,
IGameAdCallback{
val AIP_GAME_URL = "api/gametime/add" //退出游戏
val STASTICIS_GAME_URL = "stasticis/game/add" //点击游戏
private val gamePresenter by lazy { GamePresenter() }
private var gameName = ""
private var gameID = ""
override fun getContentViewLayoutID() = R.layout.fragment_liebao_game
override fun initViewsAndEvents() {
}
override fun onFragmentFirstVisible() {
gamePresenter.attachView(this)
initListener()
}
override fun onFragmentResume() {
super.onFragmentResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
gvGameLiebao.inflate(activity)
LogUtil.d("LiebaoGameFragment","onFragmentResume")
gamePresenter.getGameInfo()
}
}
override fun onDestroy() {
super.onDestroy()
LogUtil.d("LiebaoGameFragment","LiebaoGameFragment")
CmGameSdk.removeGameClickCallback()
CmGameSdk.setMoveView(null)
CmGameSdk.removeGamePlayTimeCallback()
CmGameSdk.removeGameAdCallback()
gamePresenter.detachView()
}
private fun initListener() {
// 默认游戏中心页面,点击游戏试,触发回调
CmGameSdk.setGameClickCallback(this)
// 点击游戏右上角或物理返回键,退出游戏时触发回调,并返回游戏时长
CmGameSdk.setGamePlayTimeCallback(this)
// 所有广告类型的展示和点击事件回调,仅供参考,数据以广告后台为准
CmGameSdk.setGameAdCallback(this)
}
override fun gameInfo(sumTime: Int, sumCoin: Int, gameTime: Int) {
tvGameHint.visibility = View.VISIBLE
if (gameTime >= sumTime) {
tvGameHint.setText("今日游戏任务已完成")
} else {
tvGameHint.setText(
SpanUtils()
.append("畅玩").append("${sumTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟, ")
.append("奖励").append("${sumCoin}").setForegroundColor(mContext.resources.getColor(R.color.red)).append("金币, ")
.append("已玩").append("${gameTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟")
.create())
}
}
override fun gameAddSuc(eventType: String?, data: Any?) {
when (eventType) {
Constant.EVENT_TYPE_TIME -> if (data != null) {
val json = JsonUtil.toJson(data)
val jsonObject = JsonParser().parse(json).asJsonObject
val gameCoin = jsonObject["gameCoin"].asInt
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, gameCoin)
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_GAME)
readyGo(AwardActivity::class.java, bundle)
}
Constant.EVENT_TYPE_GAMEINFO -> {
}
Constant.EVENT_TYPE_CLICK -> {
}
}
}
/**
* 默认游戏中心页面,点击游戏试,触发回调 finish
*
* @param gameName
* @param gameID
*/
override fun gameClickCallback(gameName: String, gameID: String) {
this.gameName = gameName
this.gameID = gameID
val eventTypeClick: String = Constant.EVENT_TYPE_CLICK
val vo = HashMap<String, Any>()
vo["gameName"] = gameID
vo["gameId"] = gameID
vo["gameSource"] = "liebao"
vo["carrierType"] = Constant.CARRIER_GAME
vo["eventType"] = eventTypeClick
vo["num"] = 1
vo["pkg"] = Constant.MINTS_PKG_NAME
gamePresenter.gameAdd(STASTICIS_GAME_URL, eventTypeClick, vo)
}
/**
* @param playTimeInSeconds 玩游戏时长,单位为秒 finish
*
*
* 点击游戏右上角或物理返回键,退出游戏时触发回调,并返回游戏时长
*/
override fun gamePlayTimeCallback(gameId: String?, playTimeInSeconds: Int) {
val eventTypeTime: String = Constant.EVENT_TYPE_TIME
if (playTimeInSeconds < 3) {
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, 0)
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_GAME)
readyGo(AwardActivity::class.java, bundle)
} else {
val vo = HashMap<String, Any>()
vo["gameName"] = gameID
vo["gameId"] = gameID
vo["gameSource"] = "liebao"
vo["carrierType"] = Constant.CARRIER_GAME
vo["eventType"] = eventTypeTime
vo["playtimeinseconds"] = playTimeInSeconds
vo["pkg"] = Constant.MINTS_PKG_NAME
gamePresenter.gameAdd(AIP_GAME_URL, eventTypeTime, vo)
}
}
/**
* 广告曝光/点击回调 finish
*
* @param gameId 游戏Id
* @param adType 广告类型:1:激励视频广告;2:Banner广告;3:原生Banner广告;4:全屏视频广告;
* 5:原生插屏广告;6:开屏大卡广告;7:模板Banner广告;8:模板插屏广告;9:游戏列表信息流广告
* 10:游戏列表模板插屏广告;11:游戏加载模板插屏广告;12:游戏列表信息流模板渲染广告;
* 13:游戏退出推荐弹框信息流自渲染广告;14:游戏退出推荐弹框信息流模板渲染广告
* @param adAction 广告操作:1:曝光;2:点击;3:关闭;4:跳过
* @param adChannel 广告源:穿山甲,优量汇
*/
override fun onGameAdAction(gameId: String?, adType: Int, adAction: Int, adChannel: String) {
if (adAction != 1) {
val vo = HashMap<String, Any>()
vo["gameName"] = gameName
vo["gameId"] = gameID
vo["gameSource"] = "liebao"
vo["carrierType"] = Constant.CARRIER_GAME
var eventTypeView = "VIEW"
when (adAction) {
1 -> eventTypeView = "VIEW"
2 -> eventTypeView = "CLICK"
3 -> eventTypeView = "CLOSE"
4 -> eventTypeView = "JUMP"
}
vo["adType"] = adType
vo["adsource"] = adChannel
vo["eventType"] = eventTypeView
vo["pkg"] = Constant.MINTS_PKG_NAME
gamePresenter.gameAdd(STASTICIS_GAME_URL, Constant.EVENT_TYPE_ADCLICK, vo)
}
}
}
\ No newline at end of file
......@@ -445,11 +445,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
)
}
Constant.HOT_ACTIVITY_LIEBAO -> {
readyGo(LiebaoGameActivity::class.java)
homePresenter.activeGuidanceTips(
Constant.STATUS_CODE_TWO,
flhost.activeKey
)
}
Constant.HOT_ACTIVITY_MORNINGCLOCK -> {
ExpressManager.loadExpress()
......@@ -657,20 +652,20 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
private fun initListener() {
val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
params.setMargins(0, 0, 0, BubbleUtils.dp2px(270))
cdvvYilanTime.layoutParams = params
val paramsRedBox = FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT
)
paramsRedBox.setMargins(0, BubbleUtils.dp2px(40), 0, 0)
paramsRedBox.gravity = Gravity.END
rl_fragment_main_redbox.layoutParams = paramsRedBox
// val params = LinearLayout.LayoutParams(
// LinearLayout.LayoutParams.WRAP_CONTENT,
// LinearLayout.LayoutParams.WRAP_CONTENT
// )
// params.setMargins(0, 0, 0, BubbleUtils.dp2px(270))
// cdvvYilanTime.layoutParams = params
//
// val paramsRedBox = FrameLayout.LayoutParams(
// FrameLayout.LayoutParams.WRAP_CONTENT,
// FrameLayout.LayoutParams.WRAP_CONTENT
// )
// paramsRedBox.setMargins(0, BubbleUtils.dp2px(40), 0, 0)
// paramsRedBox.gravity = Gravity.END
// rl_fragment_main_redbox.layoutParams = paramsRedBox
cdvvYilanTime.setOnClickListener(this)
rl_fragment_main_redbox.setOnClickListener(this)
rl_fragment_main_redbox.isClickable = false
......
......@@ -31,7 +31,6 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
// private var newsFragment: Fragment? = null
private var xmlyGameFragment: Fragment? = null
private var liebaoGameFragment: Fragment? = null
private var kuYinyueFragment: Fragment? = null
private var curPosition = 0//当前标签选中的下标
......@@ -46,8 +45,6 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
if (AppConfig.showAdFlag) {
if (curPosition == 0) {
mainFragment?.onHiddenChanged(hidden)
} else if (curPosition == 4) {
liebaoGameFragment?.onHiddenChanged(hidden)
}
}
......@@ -73,21 +70,18 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
currentFragment = mainFragment
}
xtFragmentMoney.setxTabDisplayNum(5)
xtFragmentMoney.setxTabDisplayNum(4)
val newTab1 = xtFragmentMoney.newTab()
newTab1.text = "视频"
val newTab3 = xtFragmentMoney.newTab()
newTab3.text = "书城"
val newTab4 = xtFragmentMoney.newTab()
newTab4.text = "听书"
val newTab5 = xtFragmentMoney.newTab()
newTab5.text = "游戏"
val newTab6 = xtFragmentMoney.newTab()
newTab6.text = "来电秀"
xtFragmentMoney.addTab(newTab1)
xtFragmentMoney.addTab(newTab3)
xtFragmentMoney.addTab(newTab4)
xtFragmentMoney.addTab(newTab5)
xtFragmentMoney.addTab(newTab6)
xtFragmentMoney.addOnTabSelectedListener(this)
......@@ -191,12 +185,6 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
addOrShowFragment(childFragmentManager, xmlyGameFragment!!, FRAGMENT_TAG_XMLY)
}
3 -> {
if (liebaoGameFragment == null) {
liebaoGameFragment = LiebaoGameFragment()
}
addOrShowFragment(childFragmentManager, liebaoGameFragment!!, FRAGMENT_TAG_GAME)
}
4 -> {
if (kuYinyueFragment == null) {
kuYinyueFragment = KuYinYueFragment()
}
......
......@@ -846,7 +846,6 @@ class MyFragment : BaseFragment(),
if (taskBean.otherConfig != null) {
when (taskBean.otherConfig.status) {
0, 2 -> {
readyGo(LiebaoGameActivity::class.java)
}
1 -> {
val bundle = Bundle()
......@@ -1129,7 +1128,6 @@ class MyFragment : BaseFragment(),
readyGo(EraseActivity::class.java)
}
Constant.HOT_ACTIVITY_LIEBAO -> {
readyGo(LiebaoGameActivity::class.java)
}
Constant.HOT_ACTIVITY_MORNINGCLOCK -> {
ExpressManager.loadExpress()
......
package com.mints.goodmoney.utils;
import android.content.Context;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.cmcm.cmgame.IImageLoader;
/**
* Created by lingyunxiao on 2019-03-04
*
* 这个类是 sdk 将 ImageLoader 的外置的接口实现。
* 因为 sdk 使用的 Glide 版本较老,为了避免与接入方使用不同版本导致的冲突,所以将这个功能延迟到 sdk 外面来提供。
* 如果不存在冲突问题,使用这个默认的实现即可。
*/
public class CmGameImageLoader implements IImageLoader {
@Override
public void loadImage(Context context, String imageUrl, ImageView imageView, int defRsid) {
// Glide.with(context)
// .load(imageUrl)
// .placeholder(defRsid)
// .error(defRsid)
// .diskCacheStrategy(DiskCacheStrategy.SOURCE)
// .into(new GlideDrawableImageViewTarget(imageView));
// 建议加上placeHolder方法,否则新安装启动会出现闪现的情况,新版本没有placeHolder的可以这么写
RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(defRsid);
Glide.with(context).load(imageUrl).apply(requestOptions).into(imageView);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<include layout="@layout/header_layout" />
<TextView
android:id="@+id/tvGameHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_E6E6E6"
android:drawableLeft="@mipmap/ic_voice"
android:drawablePadding="10pt"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="5dp"
android:paddingBottom="10dp"
android:textSize="14sp"
android:visibility="gone" />
<com.mints.goodmoney.ui.widgets.ElasticScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fadingEdge="none"
android:orientation="vertical"
android:overScrollMode="never">
<!--接入时需要拷贝如下的布局,包括GameView外层的LinearLayout-start -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.cmcm.cmgame.GameView
android:id="@+id/gvGameLiebao"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
app:cmgame_category_title_text_color="#FF222222"
app:cmgame_category_title_text_size="15sp" />
</RelativeLayout>
</LinearLayout>
</com.mints.goodmoney.ui.widgets.ElasticScrollView>
</LinearLayout>
......@@ -50,6 +50,7 @@
</LinearLayout>
<LinearLayout
android:visibility="gone"
android:id="@+id/tab_rl_two"
android:layout_width="0dp"
android:layout_height="match_parent"
......@@ -75,28 +76,25 @@
<LinearLayout
android:id="@+id/tab_rl_three"
android:layout_width="0dp"
android:layout_height="75dp"
android:layout_gravity="bottom"
android:layout_weight="1.0">
android:layout_height="match_parent"
android:layout_weight="1.0"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="70dp"
android:src="@mipmap/tab_pan_btn_big" />
<!-- <ImageView-->
<!-- android:id="@+id/tab_iv_pan"-->
<!-- android:layout_width="25dp"-->
<!-- android:layout_height="25dp"-->
<!-- android:src="@drawable/tab_pan_btn" />-->
<!-- <TextView-->
<!-- android:id="@+id/tab_tv_pan"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/bottom_tab_pan"-->
<!-- android:textColor="@drawable/item_txt_sel"-->
<!-- android:textSize="11sp" />-->
android:id="@+id/tab_iv_three"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/tab_pan_btn" />
<TextView
android:id="@+id/tab_tv_three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bottom_tab_pan"
android:textColor="@drawable/item_txt_sel"
android:textSize="11sp" />
</LinearLayout>
<LinearLayout
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<TextView
android:id="@+id/tvGameHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_E6E6E6"
android:drawableLeft="@mipmap/ic_voice"
android:drawablePadding="10pt"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="5dp"
android:paddingBottom="10dp"
android:textSize="14sp"
android:visibility="gone" />
<com.mints.goodmoney.ui.widgets.ElasticScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fadingEdge="none"
android:orientation="vertical"
android:overScrollMode="never">
<!--接入时需要拷贝如下的布局,包括GameView外层的LinearLayout-start -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.cmcm.cmgame.GameView
android:id="@+id/gvGameLiebao"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
app:cmgame_category_title_text_color="#FF222222"
app:cmgame_category_title_text_size="15sp" />
</RelativeLayout>
</LinearLayout>
</com.mints.goodmoney.ui.widgets.ElasticScrollView>
</LinearLayout>
......@@ -4,7 +4,7 @@
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="end"
android:layout_marginTop="100dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="10dp"
android:background="@mipmap/ic_main_redbox">
......@@ -13,11 +13,11 @@
android:layout_width="wrap_content"
android:layout_height="12dp"
android:layout_gravity="center|bottom"
android:paddingStart="2dp"
android:paddingEnd="2dp"
android:layout_marginBottom="8dp"
android:background="@drawable/shape_redbox_red"
android:gravity="center"
android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text="--:--"
android:textColor="@color/color_F28335"
android:textSize="8sp" />
......
......@@ -4,6 +4,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginBottom="400dp"
android:layout_marginEnd="4dp">
<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