Commit c6b27f97 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 22d3bb3d
......@@ -341,6 +341,12 @@ public interface LoanService {
@POST("api/user/reportAlipayMsg")
Observable<BaseResponse<Object>> reportAlipayMsg(@Body Map<String, Object> vo);
/**
* 取消猜歌
*/
@POST("api/reward/refreshTaskCount")
Observable<BaseResponse<Object>> refreshTaskCount();
/**
* 默认http工厂
*/
......
......@@ -9,6 +9,7 @@ import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieComposition
import com.airbnb.lottie.LottieCompositionFactory
import com.airbnb.lottie.LottieDrawable
import com.duben.dayplaylet.MintsApplication
import com.duben.dayplaylet.R
import com.duben.dayplaylet.ad.AdManager
import com.duben.dayplaylet.ad.AdStatusListener
......@@ -16,8 +17,10 @@ import com.duben.dayplaylet.ad.NoPreAdManager
import com.duben.dayplaylet.ad.half.HalfScreenManager
import com.duben.dayplaylet.common.Constant
import com.duben.dayplaylet.manager.AlipayAuthManager
import com.duben.dayplaylet.manager.AppHttpManager
import com.duben.dayplaylet.manager.TrackManager
import com.duben.dayplaylet.manager.UserManager
import com.duben.dayplaylet.mvp.model.BaseResponse
import com.duben.dayplaylet.ui.activitys.base.BaseActivity
import com.duben.dayplaylet.ui.widgets.DialogListener
import com.duben.dayplaylet.ui.widgets.WithDrawSucDialog
......@@ -25,6 +28,8 @@ import com.duben.dayplaylet.ui.widgets.countdowntimer.CountDownTimerSupport
import com.duben.dayplaylet.ui.widgets.countdowntimer.OnCountDownTimerListener
import com.duben.dayplaylet.utils.rxutil.CommonRxTask
import com.duben.dayplaylet.utils.rxutil.RxjavaUtil
import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable
import com.duben.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_hint.*
import kotlinx.android.synthetic.main.activity_nine.*
......@@ -88,6 +93,8 @@ class NineActivity : BaseActivity(), View.OnClickListener {
when (v.id) {
R.id.iv_nine_back -> {
refreshTaskCount()
finish()
}
R.id.iv_nine_next -> {
......@@ -245,12 +252,14 @@ class NineActivity : BaseActivity(), View.OnClickListener {
mTimer?.setOnCountDownTimerListener(object : OnCountDownTimerListener {
override fun onTick(millisUntilFinished: Long) {
if (!this@NineActivity.isFinishing) {
tv_nine_timer?.text = "${millisUntilFinished / 1000}秒后自动领取"
}
}
override fun onFinish() {
if (!this@NineActivity.isFinishing) {
tv_nine_timer?.visibility = View.GONE
if (isClickFlag) return
if (!UserManager.getInstance().alipaySet) {
......@@ -280,4 +289,19 @@ class NineActivity : BaseActivity(), View.OnClickListener {
e.printStackTrace()
}
}
private fun refreshTaskCount() {
val baseApplication = MintsApplication.getContext() as MintsApplication
AppHttpManager.getInstance(baseApplication)
.call(baseApplication.loanService.refreshTaskCount(),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onError(e: Throwable) {
}
override fun onNext(t: BaseResponse<Any>) {
}
})
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import com.duben.dayplaylet.R
import com.duben.dayplaylet.ad.express.ExpressAdCallback
import com.duben.dayplaylet.ad.express.MyExpressManager
import com.duben.dayplaylet.ui.activitys.base.BaseActivity
import com.duben.dayplaylet.utils.SoundPoolUtil
import com.duben.dayplaylet.utils.UIUtils
import com.duben.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_song_award.*
......
......@@ -18,6 +18,7 @@ import com.duben.dayplaylet.common.AppConfig
import com.duben.dayplaylet.manager.TrackManager
import com.duben.dayplaylet.ui.activitys.base.BaseActivity
import com.duben.dayplaylet.utils.ConsumerToastUtil
import com.duben.dayplaylet.utils.SoundPoolUtil
import com.duben.dayplaylet.utils.SpanUtils
import com.duben.dayplaylet.utils.UIUtils
import com.duben.library.utils.nodoubleclick.AntiShake
......@@ -74,6 +75,7 @@ class TaskAwardActivity : BaseActivity(), View.OnClickListener {
}
override fun initViewsAndEvents() {
SoundPoolUtil.getInstance().getGoldVoice()
showAdView()
tv_award_hint.text = SpanUtils()
.append("金元宝")
......
......@@ -316,7 +316,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
}
if (signMsg == null) {
iv_main_sign.visibility = View.GONE
if (!isNoSignFlag) {
if (!isNoSignFlag && !isShowSignFlag) {
isNoSignFlag = true
HalfScreenManager.getInstance().showAd(requireActivity(), null)
}
......
......@@ -45,11 +45,8 @@ import com.duben.dayplaylet.ui.activitys.SongAwardActivity
import com.duben.dayplaylet.ui.fragment.base.LazyLoadBaseFragment
import com.duben.dayplaylet.ui.widgets.countdowntimer.CountDownTimerSupport
import com.duben.dayplaylet.ui.widgets.countdowntimer.OnCountDownTimerListener
import com.duben.dayplaylet.utils.FormatUtil
import com.duben.dayplaylet.utils.LogUtil
import com.duben.dayplaylet.utils.RxBus
import com.duben.dayplaylet.utils.*
import com.duben.dayplaylet.utils.RxBus.MsgEvent
import com.duben.dayplaylet.utils.SpanUtils
import com.duben.library.utils.nodoubleclick.AntiShake
import io.reactivex.Observer
import io.reactivex.disposables.Disposable
......@@ -89,6 +86,8 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
private var mPos = 0
private var isNineFlag = false
override fun getContentViewLayoutID() = R.layout.fragment_music
override fun initViewsAndEvents() {
......@@ -566,12 +565,16 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
if (it.completeCount >= it.turnNeedCount) {
tv_open_cash_info.visibility = View.GONE
Handler(Looper.getMainLooper()).postDelayed({
val bundle = Bundle()
bundle.putString(NineActivity.DRAW_ID, it.unitId)
bundle.putString(NineActivity.CASH, it.cash)
readyGo(NineActivity::class.java, bundle)
}, 800)
if (!isNineFlag) {
isNineFlag = true
Handler(Looper.getMainLooper()).postDelayed({
val bundle = Bundle()
bundle.putString(NineActivity.DRAW_ID, it.unitId)
bundle.putString(NineActivity.CASH, it.cash)
readyGo(NineActivity::class.java, bundle)
}, 800)
}
} else {
tv_open_cash_info.visibility = View.VISIBLE
tv_open_cash_info.text = SpanUtils()
......@@ -666,6 +669,8 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
}
override fun reportAddCoinMsgSuc(coin: Int, di: Int) {
SoundPoolUtil.getInstance().getGoldVoice()
when (mCarrierType) {
Constant.CARRIERTYPE_SONG_CLICK -> {
showRewardAnim(coin, di)
......@@ -751,6 +756,7 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
awardVideo(Constant.CARRIERTYPE_SONG_MORE)
}
SoundPoolUtil.getInstance().getGoldVoice()
mTimer = CountDownTimerSupport(8000, 1000)
mTimer?.setOnCountDownTimerListener(object :
OnCountDownTimerListener {
......
......@@ -43,6 +43,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
private var tasksAdapter: TasksAdapter? = null
private var drawCashDialog: DrawCashDialog? = null
private var taskInfoBean: TaskInfoBean? = null
override fun getContentViewLayoutID() = R.layout.fragment_main_my
......@@ -127,7 +128,11 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
showDrawCashDialog()
}
R.id.btn_task -> { // 任务,领金元宝
showAd(Constant.CARRIERTYPE_TASK_YUANBAO)
taskInfoBean?.let {
if (it.diMsg.complete < it.diMsg.max) {
showAd(Constant.CARRIERTYPE_TASK_YUANBAO)
}
}
}
R.id.tv_my_explain -> { // 收益说明
val bundle = Bundle()
......@@ -158,6 +163,13 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
}
override fun getHallListSuc(data: TaskInfoBean) {
this.taskInfoBean = data
pb_task.progress = data.diMsg.complete
pb_task.max = data.diMsg.max
tv_task_count.text = "今日剩余${data.diMsg.max - data.diMsg.complete}次"
tasksAdapter?.taskData = data.list
recy_tasks.adapter?.notifyDataSetChanged()
}
......
......@@ -25,10 +25,7 @@ import com.duben.dayplaylet.ui.activitys.DrawProgressActivity
import com.duben.dayplaylet.ui.activitys.MainActivity
import com.duben.dayplaylet.ui.fragment.MyFragment
import com.duben.dayplaylet.ui.fragment.base.LazyLoadBaseFragment
import com.duben.dayplaylet.utils.ConsumerToastUtil
import com.duben.dayplaylet.utils.ForegroundOrBackground
import com.duben.dayplaylet.utils.SpanUtils
import com.duben.dayplaylet.utils.ToastUtil
import com.duben.dayplaylet.utils.*
import com.duben.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_feekback.*
import kotlinx.android.synthetic.main.fragment_draw.*
......@@ -65,6 +62,7 @@ class DrawCashFragment : LazyLoadBaseFragment(), DrawCashView, DrawCashAdapter.O
private var currentDrawInfo: DrawInfoBean.DrawInfoItemBean? = null
var payChannel = ALIPAY
var alipayStatus = false
private var currentPosition = 0
override fun getContentViewLayoutID() = R.layout.fragment_draw
......@@ -120,9 +118,9 @@ class DrawCashFragment : LazyLoadBaseFragment(), DrawCashView, DrawCashAdapter.O
mDrawCashAdapter?.setNewInstance(data.list)
if (data.list.size > 0) {
currentDrawInfo = data.list.get(0)
mDrawCashAdapter?.setPosition(0)
this.onItemClick(0)
currentDrawInfo = data.list.get(currentPosition)
mDrawCashAdapter?.setPosition(currentPosition)
this.onItemClick(currentPosition)
}
}
......@@ -140,15 +138,17 @@ class DrawCashFragment : LazyLoadBaseFragment(), DrawCashView, DrawCashAdapter.O
.create()
mDrawCashAdapter?.setNewInstance(data.list)
if (data.list.size > 0) {
currentDrawInfo = data.list.get(0)
mDrawCashAdapter?.setPosition(0)
this.onItemClick(0)
currentDrawInfo = data.list.get(currentPosition)
mDrawCashAdapter?.setPosition(currentPosition)
this.onItemClick(currentPosition)
}
}
override fun onItemClick(position: Int) {
currentDrawInfo = yuanbaoBean?.list?.get(position)
currentPosition = position
if (drawType == DRAW_TYPE_CASH) {
currentPosition = position
// 红包
currentDrawInfo = redPkgBean?.list?.get(position)
}
......@@ -181,30 +181,6 @@ class DrawCashFragment : LazyLoadBaseFragment(), DrawCashView, DrawCashAdapter.O
when (v.id) {
R.id.btn_draw -> {
//1、支付渠道
if (TextUtils.equals(payChannel, WEIXIN_PAY)) {
// showToast("微信支付维护中")
return
}
// 2、授权支付宝
if (!alipayStatus) {
// 去授权
showToast("发起支付宝授权..")
AlipayAuthManager.authV2(requireActivity(),
object : AlipayAuthManager.AuthListener {
override fun authSuccess() {
showToast("支付宝授权成功")
}
override fun authFail(resultStatus: String) {
showToast("支付宝授权失败 " + resultStatus)
}
})
return
}
/**
* 21 任务弹框,
* 11 直接在当前页面观看视频,-- 立即赚钱
......@@ -215,13 +191,37 @@ class DrawCashFragment : LazyLoadBaseFragment(), DrawCashView, DrawCashAdapter.O
currentDrawInfo?.let {
when (it.status) {
1 -> {
//1、支付渠道
if (TextUtils.equals(payChannel, WEIXIN_PAY)) {
// showToast("微信支付维护中")
return
}
// 2、授权支付宝
if (!alipayStatus) {
// 去授权
showToast("发起支付宝授权..")
AlipayAuthManager.authV2(requireActivity(),
object : AlipayAuthManager.AuthListener {
override fun authSuccess() {
showToast("支付宝授权成功")
}
override fun authFail(resultStatus: String) {
showToast("支付宝授权失败 " + resultStatus)
}
})
return
}
if (it.isNeedSeeVedioBeforeCashout) {
//票
showAd(Constant.CARRIERTYPE_ONLY_SHOW)
} else {
//发起提现
TrackManager.getInstance().addCashoutReq(currentDrawInfo?.unitId)
showToast("提现成功")
showToast("发起提现成功")
}
}
11 -> {
......@@ -312,16 +312,25 @@ class DrawCashFragment : LazyLoadBaseFragment(), DrawCashView, DrawCashAdapter.O
Constant.CARRIERTYPE_ONLY_SHOW -> {
TrackManager.getInstance().addCashoutReq(currentDrawInfo?.unitId)
Handler(Looper.getMainLooper()).postDelayed({
showToast("提现成功")
showToast("发起提现成功")
}, 1000)
}
Constant.CARRIERTYPE_REWARD_COIN -> {
Handler(Looper.getMainLooper()).postDelayed({
Handler(Looper.getMainLooper()).postDelayed({
ConsumerToastUtil.showAwardText(requireContext(), AppConfig.awardRedpkg, 0)
}, 800)
onFragmentResume()
}, 1000)
}
Constant.CARRIERTYPE_REWARD_DI -> {
Handler(Looper.getMainLooper()).postDelayed({
Handler(Looper.getMainLooper()).postDelayed({
ConsumerToastUtil.showAwardText(requireContext(), 0, AppConfig.awardYuanbao)
}, 800)
onFragmentResume()
}, 1000)
}
......
......@@ -13,8 +13,13 @@ import com.duben.dayplaylet.R
object ConsumerToastUtil {
@JvmStatic
fun showAwardText(context: Context?, redPkgInt: Int, yuanbaoInt: Int) {
SoundPoolUtil.getInstance().getGoldVoice()
if (redPkgInt == 0 && yuanbaoInt == 0) return
if (context == null) return
try {
val toastview = LayoutInflater.from(context).inflate(R.layout.toast_text_layout, null)
val ll_toast_redpkg = toastview.findViewById<View>(R.id.ll_toast_redpkg) as LinearLayout
......
package com.duben.dayplaylet.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.media.MediaPlayer;
import android.media.SoundPool;
import com.duben.dayplaylet.MintsApplication;
import com.duben.dayplaylet.R;
public class SoundPoolUtil {
private static SoundPoolUtil soundPoolUtil;
private static Context context;
private SoundPool soundPool;
private MediaPlayer player;
//单例模式
public static SoundPoolUtil getInstance() {
SoundPoolUtil.context = MintsApplication.getContext();
if (soundPoolUtil == null)
soundPoolUtil = new SoundPoolUtil(context);
return soundPoolUtil;
}
@SuppressLint("NewApi")//这里初始化SoundPool的方法是安卓5.0以后提供的新方式
private SoundPoolUtil(Context context) {
soundPool = new SoundPool.Builder().build();
//加载音频文件
soundPool.load(context, R.raw.coin, 1);
}
public void play(int number) {
/**
* 播放音频
* params说明:
* //左耳道音量【0~1】
* //右耳道音量【0~1】
* //播放优先级【0表示最低优先级】
* //循环模式【0表示循环一次,-1表示一直循环,其他表示数字+1表示当前数字对应的循环次数】
* //播放速度【1是正常,范围从0~2】
*/
soundPool.play(number, 1, 1, 0, 0, 1);
}
public void getGoldVoice() {
player = MediaPlayer.create(context, R.raw.coin);
if (player != null) {
player.start();
}
}
public void onDestory() {
if (player != null) {
player.stop();
player.release();
player = null;
}
}
}
......@@ -37,6 +37,7 @@ import com.duben.dayplaylet.ui.adapter.VideoEpisodeAdapter
import com.duben.dayplaylet.ui.widgets.*
import com.duben.dayplaylet.utils.ForegroundOrBackground
import com.duben.dayplaylet.utils.FormatUtil
import com.duben.dayplaylet.utils.SoundPoolUtil
import com.duben.dayplaylet.utils.SpanUtils
import com.duben.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.drama_activity_api_detail.*
......@@ -463,6 +464,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
override fun reportAddCoinMsgSuc(coin: Int, di: Int) {
cdvv.reset()
videoPresenter.rdVedioMsg()
SoundPoolUtil.getInstance().getGoldVoice()
showRewardAnim(coin, di)
}
......
......@@ -65,6 +65,14 @@
android:layout_marginEnd="18dp" />
</FrameLayout>
<TextView
android:id="@+id/tv_nine_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="13sp"
android:textColor="@color/white"></TextView>
</LinearLayout>
</RelativeLayout>
......@@ -6,23 +6,28 @@
<ImageView
android:id="@+id/app_logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="120dp"
android:layout_marginTop="90dp"
android:src="@mipmap/ic_launcher_main" />
<TextView
<ImageView
android:id="@+id/iv_splash_title"
android:layout_below="@+id/app_logo"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_height="wrap_content"
android:layout_above="@id/progressBar"
android:text="@string/app_name"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="36sp" />
android:layout_marginTop="30dp"
android:src="@mipmap/ic_splash_top"
android:layout_height="wrap_content"/>
<ImageView
android:layout_below="@+id/iv_splash_title"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="90dp"
android:src="@mipmap/bg_splash_center"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
......
......@@ -6,23 +6,28 @@
<ImageView
android:id="@+id/app_logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="120dp"
android:layout_marginTop="90dp"
android:src="@mipmap/ic_launcher_main" />
<TextView
<ImageView
android:id="@+id/iv_splash_title"
android:layout_below="@+id/app_logo"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_height="wrap_content"
android:layout_above="@id/progressBar"
android:text="@string/app_name"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="36sp" />
android:layout_marginTop="30dp"
android:src="@mipmap/ic_splash_top"
android:layout_height="wrap_content"/>
<ImageView
android:layout_below="@+id/iv_splash_title"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="90dp"
android:src="@mipmap/bg_splash_center"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
......
......@@ -294,7 +294,7 @@
android:id="@+id/tv_task_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="今日剩余10次"
android:text="今日剩余-次"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/btn_task"
......
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