Commit 6d92ac4a authored by maxiaoliang's avatar maxiaoliang

添加碎片红包弹窗,修改其他页面ui

parent 2c6d6a1d
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -200,7 +200,18 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback { ...@@ -200,7 +200,18 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback {
// JumpUtils.h5Jump("打卡提现", Constant.Param.PunchRecord, false, act) // JumpUtils.h5Jump("打卡提现", Constant.Param.PunchRecord, false, act)
JumpUtils.jumpClockInWithdrawActivity() JumpUtils.jumpClockInWithdrawActivity()
} }
/**
* 拼图红包
*/
fun onPuzzleClick() {
Log.d("wxw", "拼图红包")
MainLooper.get()?.post(Runnable {
if (Utils.isFastClick2()) {
//CashExchangeDialog.showCashExchage(this, this)
PuzzleDialog.showPuzzleDialog(this)
}
})
}
/** /**
* 兑换现金 * 兑换现金
*/ */
......
package com.ym.piggybank.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.ym.ddcy.R
import com.ym.game.module.PuzzleEntity
import com.ym.modulecommon.AppliContext
import com.ym.modulecommon.base.BaseRecyclerAdapter
import com.ym.task.module.listener.OnRecycleItemClickListener
class PuzzleBottomAdapter : BaseRecyclerAdapter<PuzzleEntity.PuzzleData, RecyclerView.ViewHolder> {
var listner: OnRecycleItemClickListener<PuzzleEntity.PuzzleData>?
constructor(listner: OnRecycleItemClickListener<PuzzleEntity.PuzzleData>?) {
this.listner = listner
}
override fun getItemId(position: Int): Long {
return position?.toLong()
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, p1: Int) {
if (holder is ViewHolder) {
val entity = mList[p1]
if (entity != null) {
holder.tvnum?.text = entity?.number.toString()
when (entity.index) {
1 -> {
if (entity.number > 0) {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_one_light)
} else {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_one_gray)
}
}
2 -> {
if (entity.number > 0) {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_two_light)
} else {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_two_gray)
}
}
3 -> {
if (entity.number > 0) {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_three_light)
} else {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_three_gray)
}
}
4 -> {
if (entity.number > 0) {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_four_light)
} else {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_four_gray)
}
}
5 -> {
if (entity.number > 0) {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_five_light)
} else {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_five_gray)
}
}
6 -> {
if (entity.number > 0) {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_six_light)
} else {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_six_gray)
}
}
7 -> {
if (entity.number > 0) {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_seven_light)
} else {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_seven_gray)
}
}
8 -> {
if (entity.number > 0) {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_eight_light)
} else {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_eight_gray)
}
}
9 -> {
if (entity.number > 0) {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_nine_light)
} else {
holder.tvbg.setBackgroundResource(R.drawable.icon_bottom_nine_gray)
}
}
}
// holder.tvallnum.text = entity?.number.toString()
}
}
}
override fun getItemCount(): Int {
return mList.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return ViewHolder(
LayoutInflater.from(AppliContext.get())
.inflate(R.layout.layout_item_bottom_pizzle, parent, false)
)
}
inner class ViewHolder : RecyclerView.ViewHolder {
val tvbg: TextView
val tvnum: TextView
constructor(itemView: View) : super(itemView) {
tvbg = itemView.findViewById(R.id.id_tv_bottom_bg)
tvnum = itemView.findViewById(R.id.id_tv_number)
tvbg.setOnClickListener {
val pos = adapterPosition
if (pos >= 0 && pos < mList.size) {
listner?.onItemClick(it, pos, mList[pos])
// val entity = mList[pos]
// if (entity.number > 0) {
//
// } else {
// Utils.showToast(AppliContext.get(), "看视频")
// }
}
}
}
}
}
package com.ym.piggybank.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.ym.ddcy.R
import com.ym.game.module.PuzzleEntity
import com.ym.modulecommon.AppliContext
import com.ym.modulecommon.base.BaseRecyclerAdapter
class PuzzleTopAdapter:
BaseRecyclerAdapter<PuzzleEntity.PuzzleData, RecyclerView.ViewHolder>() {
override fun getItemId(position: Int): Long {
return position?.toLong()
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, p1: Int) {
if (holder is ViewHolder) {
val entity = mList[p1]
if (entity != null) {
when(entity.index){
1->{
if(entity.number>0){
holder.tvnum.setBackgroundResource(R.drawable.icon_img_one_light)
}else{
holder.tvnum.setBackgroundResource(R.drawable.icon_img_one_gray)
}
}
2->{
if(entity.number>0){
holder.tvnum.setBackgroundResource(R.drawable.icon_img_two_light)
}else{
holder.tvnum.setBackgroundResource(R.drawable.icon_img_two_gray)
}
}
3->{
if(entity.number>0){
holder.tvnum.setBackgroundResource(R.drawable.icon_img_three_light)
}else{
holder.tvnum.setBackgroundResource(R.drawable.icon_img_three_gray)
}
}
4->{
if(entity.number>0){
holder.tvnum.setBackgroundResource(R.drawable.icon_img_four_light)
}else{
holder.tvnum.setBackgroundResource(R.drawable.icon_img_four_gray)
}
}
5->{
if(entity.number>0){
holder.tvnum.setBackgroundResource(R.drawable.icon_img_five_light)
}else{
holder.tvnum.setBackgroundResource(R.drawable.icon_img_five_gray)
}
}
6->{
if(entity.number>0){
holder.tvnum.setBackgroundResource(R.drawable.icon_img_six_light)
}else{
holder.tvnum.setBackgroundResource(R.drawable.icon_img_six_gray)
}
}
7->{
if(entity.number>0){
holder.tvnum.setBackgroundResource(R.drawable.icon_img_seven_light)
}else{
holder.tvnum.setBackgroundResource(R.drawable.icon_img_seven_gray)
}
}
8->{
if(entity.number>0){
holder.tvnum.setBackgroundResource(R.drawable.icon_img_eight_light)
}else{
holder.tvnum.setBackgroundResource(R.drawable.icon_img_eight_gray)
}
}
9->{
if(entity.number>0){
holder.tvnum.setBackgroundResource(R.drawable.icon_img_nine_light)
}else{
holder.tvnum.setBackgroundResource(R.drawable.icon_img_nine_gray)
}
}
}
}
}
}
override fun getItemCount(): Int {
return mList.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return ViewHolder(
LayoutInflater.from(AppliContext.get())
.inflate(R.layout.layout_item_top_pizzle, parent, false)
)
}
inner class ViewHolder : RecyclerView.ViewHolder {
val tvnum: TextView
constructor(itemView: View) : super(itemView) {
tvnum = itemView.findViewById(R.id.id_tv_item)
}
}
}
package com.ym.game.application; package com.ym.game.application;
import android.app.Activity
import android.app.ActivityManager
import android.app.Application
import android.content.Context import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Bundle
import android.os.Process import android.os.Process
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
...@@ -14,13 +19,36 @@ import com.umeng.commonsdk.UMConfigure ...@@ -14,13 +19,36 @@ import com.umeng.commonsdk.UMConfigure
import com.umeng.socialize.PlatformConfig import com.umeng.socialize.PlatformConfig
import com.ym.admodule.config.AdManager import com.ym.admodule.config.AdManager
import com.ym.library.Constant import com.ym.library.Constant
import com.ym.modulecommon.AppliContext
import com.ym.modulecommon.base.SplashResumeActivity
import com.ym.modulecommon.net.NetConfig import com.ym.modulecommon.net.NetConfig
import java.io.BufferedReader import java.io.BufferedReader
import java.io.FileReader import java.io.FileReader
import java.io.IOException import java.io.IOException
class BaseApplication : MultiDexApplication() { class BaseApplication : MultiDexApplication() {
// 正常状态
val STATE_NORMAL = 0
// 从后台回到前台
val STATE_BACK_TO_FRONT = 1
// 从前台进入后台
val STATE_FRONT_TO_BACK = 2
// APP状态
private var sAppState = STATE_NORMAL
// 标记程序是否已进入后台(依据onStop回调)
private var flag = false
// 标记程序是否已进入后台(依据onTrimMemory回调)
private var background = false
// 从前台进入后台的时间
private var frontToBackTime: Long = 0
// 从后台返回前台的时间
private var backToFrontTime: Long = 0
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
NetConfig.setBase_Url(NetConfig.Environment.DEV)// TODO 上线之后提成成 NetConfig.Environment.PRODUCT NetConfig.setBase_Url(NetConfig.Environment.DEV)// TODO 上线之后提成成 NetConfig.Environment.PRODUCT
...@@ -54,13 +82,86 @@ class BaseApplication : MultiDexApplication() { ...@@ -54,13 +82,86 @@ class BaseApplication : MultiDexApplication() {
//小满 //小满
AdSdk.setDebug(isDebug)//打开日志 AdSdk.setDebug(isDebug)//打开日志
AdSdk.init(this, "ddcy-az-hdgj_vbskkc", "D545402QovC2W5g8")//初始化 需要在Applicaiton 中 AdSdk.init(this, "ddcy-az-hdgj_vbskkc", "D545402QovC2W5g8")//初始化 需要在Applicaiton 中
registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
} }
override fun attachBaseContext(base: Context?) { override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base) super.attachBaseContext(base)
MultiDex.install(base) MultiDex.install(base)
} }
/**
* 当前Activity个数
*/
private var activityCount = 0
var activityLifecycleCallbacks: Application.ActivityLifecycleCallbacks =
object : Application.ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
override fun onActivityStarted(activity: Activity) {
if (background || flag) {
background = false
flag = false
sAppState = STATE_BACK_TO_FRONT
backToFrontTime = System.currentTimeMillis()
if(canShowAd()){
var intent = Intent()
intent.setClass(applicationContext,SplashResumeActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
AppliContext.get().startActivity(intent)
}
} else {
sAppState = STATE_NORMAL
}
if (activityCount === 0) {//从后台进入前台
var intent = Intent()
intent.setClass(applicationContext, SplashResumeActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
AppliContext.get().startActivity(intent)
}
activityCount++
}
override fun onActivityResumed(activity: Activity) {}
override fun onActivityPaused(activity: Activity) {}
override fun onActivityStopped(activity: Activity) {
if (!isCurAppTop(activity)) {
// 从前台进入后台
sAppState = STATE_FRONT_TO_BACK;
frontToBackTime = System.currentTimeMillis();
flag = true;
} else {
// 否则是正常状态
sAppState = STATE_NORMAL;
}
}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
override fun onActivityDestroyed(activity: Activity) {}
}
fun canShowAd(): Boolean {
return sAppState === STATE_BACK_TO_FRONT &&
backToFrontTime - frontToBackTime > 10000
}
fun isCurAppTop(context: Context?): Boolean {
if (context == null) {
return false
}
val curPackageName = context.packageName
val am: ActivityManager =
context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val list: List<ActivityManager.RunningTaskInfo> = am.getRunningTasks(1)
if (list != null && list.size > 0) {
val info: ActivityManager.RunningTaskInfo = list[0]
val topPackageName: String = info?.topActivity?.packageName!!
val basePackageName: String = info.baseActivity?.packageName!!
if (topPackageName == curPackageName && basePackageName == curPackageName) {
return true
}
}
return false
}
/** /**
* 获取进程号对应的进程名 * 获取进程号对应的进程名
* *
......
package com.ym.game.contract
import com.ym.game.module.PuzzleEntity
class PuzzleContract {
interface View {
//fun PuzzDataResult(mdata: PuzzleEntity)
fun PutPuzzDataResult(mdata: PuzzleEntity)
fun cardsFlyUp(result: PuzzleEntity,index: Int)
fun getPuzzlelookAd(diffCardsNum:Int)
}
interface Presenter {
fun getPuzzleData()
fun putPuzzleData(index: Int)//下面列表有的话调这个
fun noputPuzzleData(index: Int)//下面列表没有的话调这个
fun onecleanPuzzle()
fun automatic()//一键拼图
fun openBox()
}
}
\ No newline at end of file
package com.ym.game.module
class PuzzleEntity {
var isWin:Int=0
var winCoin:Int=0
var diffCardsNum:Int=0
var totalCards:Int=0
var advert:Int=0
var lockCardList: List<PuzzleData>? = null
var storeCardList: List<PuzzleData>? = null
class PuzzleData {
var index:Int=0
var number:Int=0
}
}
\ No newline at end of file
package com.ym.game.presenter
import android.app.Activity
import android.util.Log
import android.view.View
import com.ym.game.contract.PuzzleContract
import com.ym.library.net.BaseObserver
import com.ym.library.net.RxSchedulers
class PuzzlePresenter : PuzzleContract.Presenter {
var mView: PuzzleContract.View
constructor(mView: PuzzleContract.View) {
this.mView = mView
}
// 获取卡片列表
override fun getPuzzleData() {
// AppClient.appApi.getCollectCard().compose(RxSchedulers.observableIO2Main()).subscribe(object : BaseObserver<PuzzleEntity?>() {
// override fun onSuccess(result: PuzzleEntity?) {
// if (result != null) {
// mView?.PutPuzzDataResult(result)
// }
// }
//
// override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {}
// })
}
//已有宝箱卡片拼图
override fun putPuzzleData(index:Int) {
// AppClient.appApi.getCollectCardPut(index).compose(RxSchedulers.observableIO2Main()).subscribe(object : BaseObserver<PuzzleEntity?>() {
// override fun onSuccess(result: PuzzleEntity?) {
// if (result != null) {
// mView.cardsFlyUp(result,index)
//
// }
// }
//
// override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {}
// })
}
//看广告单个图片获取或者拼图
override fun noputPuzzleData(index: Int) {
// AppClient.appApi.getCollectCardPutorAdd(index).compose(RxSchedulers.observableIO2Main()).subscribe(object : BaseObserver<PuzzleEntity?>() {
// override fun onSuccess(result: PuzzleEntity?) {
// if (result != null) {
// mView?.PutPuzzDataResult(result)
// }
// }
//
// override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {}
// })
}
//看广告一键拼图
override fun onecleanPuzzle() {
// AppClient.appApi.getCollectCardAdv().compose(RxSchedulers.observableIO2Main()).subscribe(object : BaseObserver<PuzzleEntity?>() {
// override fun onSuccess(result: PuzzleEntity?) {
// if (result != null) {
// mView?.PutPuzzDataResult(result)
//
// }
// }
//
// override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {}
// })
}
//一键拼图
override fun automatic() {
// AppClient.appApi.getCollectCardAutoMatic().compose(RxSchedulers.observableIO2Main()).subscribe(object : BaseObserver<PuzzleEntity?>() {
// override fun onSuccess(result: PuzzleEntity?) {
// if (result != null) {
// mView?.PutPuzzDataResult(result)
// Log.e("MXL",""+result.isWin)
// if(result.advert==1){
// //去看广告
// mView?.getPuzzlelookAd(result.diffCardsNum)
// }
//
// }
// }
//
// override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {}
// })
}
//开宝箱
override fun openBox() {
// AppClient.appApi.openCard().compose(RxSchedulers.observableIO2Main()).subscribe(object : BaseObserver<PuzzleEntity?>() {
// override fun onSuccess(result: PuzzleEntity?) {
// if (result != null) {
// mView?.PutPuzzDataResult(result)
//
// }
// }
//
// override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {}
// })
}
}
\ No newline at end of file
...@@ -427,6 +427,7 @@ object MainDialog { ...@@ -427,6 +427,7 @@ object MainDialog {
imgtitle.setImageResource(R.mipmap.img_wenxin_trip) imgtitle.setImageResource(R.mipmap.img_wenxin_trip)
imggoon.setImageResource(R.mipmap.img_go_zhongcai) imggoon.setImageResource(R.mipmap.img_go_zhongcai)
} }
} }
tvcashcontent.text = reason tvcashcontent.text = reason
...@@ -448,6 +449,48 @@ object MainDialog { ...@@ -448,6 +449,48 @@ object MainDialog {
mDialog.show() mDialog.show()
} }
fun showActivityDesc(activity: Activity) {
if (activity == null) return
val mDialog = Dialog(activity, R.style.UpdateVersionCompatDialogTheme)
val mDialogView =showBottomDialog(
R.layout.dialog_activity_desc,
activity,
mDialog,
0,
Gravity.CENTER
)
mDialogView.findViewById<ImageView>(R.id.id_img_dialog_activity_desc).setOnClickListener {
mDialog.dismiss()
}
mDialog?.setCanceledOnTouchOutside(false)
mDialog?.setCancelable(false)
mDialog?.show()
}
fun showDialoggetPuzzle(activity: Activity?,diffCardsNum:Int ,onClickListener: View.OnClickListener){
if (activity == null) return
val mDialog = Dialog(activity, R.style.UpdateVersionCompatDialogTheme)
val mDialogView =showBottomDialog(
R.layout.dialog_get_puzzle,
activity,
mDialog,
0,
Gravity.CENTER
)
mDialogView.findViewById<TextView>(R.id.id_tv_num_puzzle)?.text = "${diffCardsNum}"
mDialogView.findViewById<ImageView>(R.id.id_img_close_get_puzzle).setOnClickListener {
mDialog.dismiss()
}
mDialogView.findViewById<ImageView>(R.id.id_img_canle).setOnClickListener {
mDialog.dismiss()
}
mDialogView.findViewById<ImageView>(R.id.id_img_sure).setOnClickListener {
mDialog.dismiss()
onClickListener.onClick(it)
}
mDialog?.setCanceledOnTouchOutside(false)
mDialog?.setCancelable(false)
mDialog?.show()
}
/** /**
* 添加点击缩放效果 * 添加点击缩放效果
......
package com.ym.game.view
import android.animation.Animator
import android.animation.ValueAnimator
import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.graphics.Path
import android.graphics.PathMeasure
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.view.animation.Animation
import android.view.animation.LinearInterpolator
import android.view.animation.ScaleAnimation
import android.view.animation.TranslateAnimation
import android.widget.ImageView
import android.widget.RelativeLayout
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.airbnb.lottie.LottieAnimationView
import com.ym.ddcy.R
import com.ym.game.contract.PuzzleContract
import com.ym.game.module.PuzzleEntity
import com.ym.game.presenter.PuzzlePresenter
import com.ym.game.utils.CenterDialog
import com.ym.library.rxbus.RxBusUtil
import com.ym.library.utils.Utils
import com.ym.modulecommon.AppliContext
import com.ym.piggybank.adapter.PuzzleBottomAdapter
import com.ym.piggybank.adapter.PuzzleTopAdapter
import com.ym.task.module.listener.OnRecycleItemClickListener
object PuzzleDialog : PuzzleContract.View, OnRecycleItemClickListener<PuzzleEntity.PuzzleData> {
private var context: Context? = null
private var mDialog: Dialog? = null
private var mPresenter: PuzzlePresenter? = null
private var topAdapter: PuzzleTopAdapter? = null
private var bottomAdapter: PuzzleBottomAdapter? = null
private var ta: TranslateAnimation? = null
var rl: RelativeLayout? = null
var rlredbg: RelativeLayout? = null
var rltop: RecyclerView? = null
var rlbottom: RecyclerView? = null
var mPathMeasure: PathMeasure? = null
val mCurrentPosition = FloatArray(2)
var lottieView: LottieAnimationView? = null
var anim_mask_layout: ViewGroup? = null
//展示拼图窗口
fun showPuzzleDialog(context: Context?) {
if (context == null) {
return
}
this.context = context
// EventUtils.onEvent("show_puzzle", "拼图展示")
mPresenter = PuzzlePresenter(this)
mPresenter?.getPuzzleData()
RxBusUtil.getDefault().register(this)
mDialog = Dialog(context, R.style.UpdateVersionCompatDialogTheme75)
val mDialogView =
CenterDialog.showBottomDialog(
R.layout.dialog_layout_puzzle,
context,
mDialog!!,
0,
Gravity.CENTER
)
rl = mDialog?.findViewById<RelativeLayout>(R.id.id_rl_parent)
rlredbg = mDialog?.findViewById<RelativeLayout>(R.id.id_rl_red_bg)
lottieView = mDialogView.findViewById<LottieAnimationView>(R.id.lottie_view)
rltop = mDialog?.findViewById<RecyclerView>(R.id.id_rl_top)
rlbottom = mDialog?.findViewById<RecyclerView>(R.id.id_rl_bottom)
rltop?.layoutManager = GridLayoutManager(context, 3)
rlbottom?.layoutManager = GridLayoutManager(context, 5)
topAdapter = PuzzleTopAdapter()
bottomAdapter = PuzzleBottomAdapter(this)
rltop?.adapter = topAdapter
rlbottom?.adapter = bottomAdapter
mDialogView?.findViewById<ImageView>(R.id.iv_dialog_close).setOnClickListener {
mDialog?.dismiss()
// mListener.onCloseViewSuccess(true);
// RxBusUtil.getDefault().unregister(this)
}
mDialogView?.findViewById<ImageView>(R.id.id_img_one_click_puzzle).setOnClickListener {
// mListener.onCloseViewSuccess(true);
mPresenter?.automatic()
RxBusUtil.getDefault().unregister(this)
}
mDialogView?.findViewById<ImageView>(R.id.id_img_desc).setOnClickListener {
MainDialog.showActivityDesc(context as Activity)
}
mDialog?.setOnCancelListener {
RxBusUtil.getDefault().unregister(this)
}
mDialog?.setCanceledOnTouchOutside(false)
mDialog?.setCancelable(false)
mDialog?.show()
}
// override fun PuzzDataResult(mdata: PuzzleEntity) {
// topAdapter?.clear()
// topAdapter?.appendToList(mdata?.lockCardList)
// topAdapter?.notifyDataSetChanged()
// bottomAdapter?.clear()
// bottomAdapter?.appendToList(mdata?.storeCardList)
// bottomAdapter?.notifyDataSetChanged()
// mPresenter?.openBox()
// }
override fun PutPuzzDataResult(mdata: PuzzleEntity) {
topAdapter?.clear()
topAdapter?.appendToList(mdata?.lockCardList)
topAdapter?.notifyDataSetChanged()
bottomAdapter?.clear()
bottomAdapter?.appendToList(mdata?.storeCardList)
bottomAdapter?.notifyDataSetChanged()
if (mdata.isWin == 1) {
mPresenter?.openBox()
rlredbg?.setBackgroundResource(R.color.black)
//先执行动画,再弹这个窗
lottieView?.visibility = View.VISIBLE
lottieView?.imageAssetsFolder = "puzzle/images/"
lottieView?.setAnimation("puzzle/data.json")
lottieView?.setRepeatCount(1)
lottieView?.playAnimation()
lottieView?.addAnimatorUpdateListener(ValueAnimator.AnimatorUpdateListener { valueAnimator -> // 判断动画加载结束
if (valueAnimator.animatedFraction == 1f) {
lottieView?.visibility = View.GONE
rlredbg?.setBackgroundResource(R.color.transparent)
lottieView?.removeAllUpdateListeners()
MainDialog.showgetWaterDrop(context as Activity
, 4, "", mdata.winCoin, null)
}
})
}
}
//卡片向上飞
override fun cardsFlyUp(result: PuzzleEntity, index: Int) {
val iv = ImageView(context)
//获取图片资源
when (index) {
1 -> {
iv.setImageResource(R.drawable.icon_bottom_one_gray)
}
2 -> {
iv.setImageResource(R.drawable.icon_bottom_two_gray)
}
3 -> {
iv.setImageResource(R.drawable.icon_bottom_three_gray)
}
4 -> {
iv.setImageResource(R.drawable.icon_bottom_four_gray)
}
5 -> {
iv.setImageResource(R.drawable.icon_bottom_five_gray)
}
6 -> {
iv.setImageResource(R.drawable.icon_bottom_six_gray)
}
7 -> {
iv.setImageResource(R.drawable.icon_bottom_seven_gray)
}
8 -> {
iv.setImageResource(R.drawable.icon_bottom_eight_gray)
}
9 -> {
iv.setImageResource(R.drawable.icon_bottom_nine_gray)
}
}
val params =
RelativeLayout.LayoutParams(100, 100)
rl!!.addView(iv, params)
val parentLocation = IntArray(2)
rl!!.getLocationOnScreen(parentLocation)
val startLocation = IntArray(2)
rlbottom?.findViewHolderForAdapterPosition(index - 1)?.itemView?.getLocationOnScreen(
startLocation
)
//得到最后落的位置的坐标(用于计算动画结束后的坐标)
val endLoc = IntArray(2)
rltop?.findViewHolderForAdapterPosition(index - 1)?.itemView?.getLocationOnScreen(endLoc)
Log.e("终点坐标", "" + endLoc[0] + "x" + endLoc[1] + "y")
Log.e("终点坐标", "" + startLocation[0] + "x" + startLocation[1] + "y")
Log.e("终点坐标", "" + parentLocation[0] + "x" + parentLocation[1] + "y")
// 正式开始计算动画开始/结束的坐标
//起始点:起始点-父布局起始点+该图片的宽
// var x=rlbottom?.findViewHolderForAdapterPosition(index-1)?.itemView?.x
val startX = startLocation[0] - parentLocation[0] + iv!!.width.toFloat()
val startY = startLocation[1] - parentLocation[1] + iv!!.height.toFloat()
//params.setMargins(100,100,100,100)
//终点坐标:起始点-父布局起始点
val toX = (endLoc[0] - parentLocation[0]).toFloat()
val toY = (endLoc[1] - parentLocation[1]).toFloat()
Log.e("坐标", "" + startX + "x" + startY + "y")
Log.e("坐标", "" + toX + "x" + toY + "y")
// 计算中间动画的插值坐标(贝塞尔曲线)(其实就是用贝塞尔曲线来完成起终点的过程)
//开始绘制贝塞尔曲线
val path = Path()
//移动到起始点(贝塞尔曲线的起点)
path.moveTo(startX, startY)
//使用二次萨贝尔曲线:注意第一个起始坐标越大,贝塞尔曲线的横向距离就会越大,一般按照下面的式子取即可
// path.quadTo((startX + toX) / 2, startY, toX, toY)
path.quadTo(startX, startY, toX, toY)
//mPathMeasure用来计算贝塞尔曲线的曲线长度和贝塞尔曲线中间插值的坐标,
// 如果是true,path会形成一个闭环
mPathMeasure = PathMeasure(path, false)
//属性动画实现(从0到贝塞尔曲线的长度之间进行插值计算,获取中间过程的距离值)
val valueAnimator =
ValueAnimator.ofFloat(0f, mPathMeasure!!.length)
valueAnimator.duration = 300
// 匀速线性插值器
valueAnimator.interpolator = LinearInterpolator()
valueAnimator.addUpdateListener { animation -> // 当插值计算进行时,获取中间的每个值,
// 这里这个值是中间过程中的曲线长度(下面根据这个值来得出中间点的坐标值)
val value = animation.animatedValue as Float
// 获取当前点坐标封装到mCurrentPosition
// boolean getPosTan(float distance, float[] pos, float[] tan) :
// 传入一个距离distance(0<=distance<=getLength()),然后会计算当前距
// 离的坐标点和切线,pos会自动填充上坐标,这个方法很重要。
mPathMeasure!!.getPosTan(
value,
mCurrentPosition,
null
) //mCurrentPosition此时就是中间距离点的坐标值
// 移动的图片(动画图片)的坐标设置为该中间点的坐标
iv.translationX = mCurrentPosition[0]
iv.translationY = mCurrentPosition[1]
}
// 开始执行动画
// iv.startAnimation(scaleAnimation)
valueAnimator.start()
// 动画结束后的处理
valueAnimator.addListener(object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator) {}
//当动画结束后:
override fun onAnimationEnd(animation: Animator) {
rl!!.removeView(iv)
PutPuzzDataResult(result)
}
override fun onAnimationCancel(animation: Animator) {}
override fun onAnimationRepeat(animation: Animator) {}
})
}
override fun getPuzzlelookAd(diffCardsNum: Int) {
if (diffCardsNum != 0) {
MainDialog.showDialoggetPuzzle(
context as Activity,
diffCardsNum,
View.OnClickListener {
Utils.showToast(AppliContext.get(), "看广告")
mPresenter?.onecleanPuzzle()
})
}
}
private val scaleAnimation by lazy {
ScaleAnimation(
1f,
2f,
1f,
2f,
Animation.RELATIVE_TO_SELF,
0.5f,
Animation.RELATIVE_TO_SELF,
0.5f
).apply {
duration = 300
fillAfter = true
}
}
override fun onItemClick(view: View, position: Int, data: PuzzleEntity.PuzzleData) {
// Utils.showToast(AppliContext.get(), "点击" + position)
if (data.number == 0) {
Utils.showToast(AppliContext.get(), "看广告")
mPresenter?.noputPuzzleData(data.index)
} else {
mPresenter?.putPuzzleData(data.index)
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/id_img_dialog_activity_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/icon_activity_desc" />
</RelativeLayout>
<?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:gravity="center"
android:orientation="vertical">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="290dp"
android:background="@drawable/icon_dialog_bg">
<ImageView
android:id="@+id/id_img_close_get_puzzle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/icon_close_dialog" />
<TextView
android:id="@+id/id_tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:includeFontPadding="false"
android:text="碎片红包"
android:textColor="#A26A3B"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/id_tv_title"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:background="@drawable/icon_white_bg"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="还差"
android:textColor="#A26A3B"
android:textSize="14sp" />
<TextView
android:id="@+id/id_tv_num_puzzle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="6"
android:textColor="#F72929"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="个碎片就可以完成拼图了"
android:textColor="#A26A3B"
android:textSize="14sp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="看一次视频即可获得一个碎片哦!"
android:textColor="#ffa26a3b"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="24dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:id="@+id/id_img_canle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_canle" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:id="@+id/id_img_sure"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_sure" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
...@@ -37,24 +37,33 @@ ...@@ -37,24 +37,33 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@mipmap/icon_exchage_cash_bg" /> android:src="@mipmap/icon_exchage_cash_bg" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/iv_dialog_close"
android:layout_marginTop="-5dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/iv_dialog_close"
android:orientation="vertical"> android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rl_cash_exchage"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20" android:layout_marginTop="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:src="@mipmap/icon_cash_desc" /> android:src="@mipmap/icon_cash_desc"
android:visibility="gone"/>
<ImageView <ImageView
android:id="@+id/id_mg_cash_recode" android:id="@+id/id_mg_cash_recode"
...@@ -64,13 +73,8 @@ ...@@ -64,13 +73,8 @@
android:src="@mipmap/icon_cash_recode" /> android:src="@mipmap/icon_cash_recode" />
</RelativeLayout> </RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rl_cash_exchage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_3" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
>
<RelativeLayout
android:id="@+id/id_rl_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
>
<LinearLayout
android:id="@+id/id_ll_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="30dp"
android:background="@drawable/icon_puzzle_bg"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="183dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rl_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
<ImageView
android:id="@+id/id_img_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:src="@drawable/icon_desc" />
</RelativeLayout>
<ImageView
android:id="@+id/id_img_one_click_puzzle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="30dp"
android:src="@drawable/icon_one_click_puzzle" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rl_bottom"
android:layout_width="wrap_content"
android:layout_height="140dp"
android:layout_gravity="center"
/>
</LinearLayout>
<RelativeLayout
android:id="@+id/id_rl_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-50dp"
android:layout_marginTop="90dp"
android:layout_toRightOf="@+id/id_ll_content">
<ImageView
android:id="@+id/iv_dialog_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_dialog_close" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/id_rl_red_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_56"
android:layout_height="@dimen/dp_56" >
<TextView
android:id="@+id/id_tv_bottom_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/icon_bottom_one_gray"
android:layout_centerInParent="true"/>
<TextView
android:id="@+id/id_tv_number"
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@drawable/icon_criye_bg"
android:layout_alignParentRight="true"
android:gravity="center"
android:textColor="@color/white"
android:textSize="15sp"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/id_tv_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/icon_img_one_gray"/>
</RelativeLayout>
...@@ -112,13 +112,14 @@ ...@@ -112,13 +112,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/layout_drops_title" android:layout_below="@+id/layout_drops_title"
android:layout_marginTop="120dp" android:layout_marginTop="120dp"
android:layout_marginBottom="20dp" android:layout_marginBottom="@dimen/dp_15"
android:paddingLeft="15dp" android:paddingLeft="15dp"
android:paddingRight="15dp" android:paddingRight="15dp"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_10"
android:gravity="center" android:gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
......
...@@ -67,8 +67,8 @@ dependencies { ...@@ -67,8 +67,8 @@ dependencies {
api ("com.bx:adsdk:1.3.3"){ api ("com.bx:adsdk:1.3.3"){
exclude group: 'com.google.code.gson' exclude group: 'com.google.code.gson'
} }
api 'com.ym.admodule:admodule:1.0.1.21' api 'com.ym.admodule:admodule:1.0.2.1'
api 'com.airbnb.android:lottie:3.1.0'
/* api 'androidx.appcompat:appcompat:1.2.0-alpha02' /* api 'androidx.appcompat:appcompat:1.2.0-alpha02'
api 'com.android.support:design:28.0.0' api 'com.android.support:design:28.0.0'
api 'com.android.support:support-v4:28.0.0' api 'com.android.support:support-v4:28.0.0'
......
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