Commit 4cf9a81e authored by mengcuiguang's avatar mengcuiguang

代码优化

parent d809c8ce
This diff is collapsed.
This diff is collapsed.
...@@ -11,6 +11,8 @@ import com.duben.loveplayletu.utils.AppPreferencesManager ...@@ -11,6 +11,8 @@ import com.duben.loveplayletu.utils.AppPreferencesManager
import com.duben.loveplayletu.utils.DeviceUuidFactory import com.duben.loveplayletu.utils.DeviceUuidFactory
import com.duben.library.net.neterror.BaseSubscriber import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable import com.duben.library.net.neterror.Throwable
import com.duben.loveplayletu.common.AppConfig
import com.google.gson.JsonObject
import java.util.HashMap import java.util.HashMap
class HomePresenter : BasePresenter<HomeView>() { class HomePresenter : BasePresenter<HomeView>() {
...@@ -77,47 +79,40 @@ class HomePresenter : BasePresenter<HomeView>() { ...@@ -77,47 +79,40 @@ class HomePresenter : BasePresenter<HomeView>() {
}) })
} }
private fun showTurn() { fun orders() {
AppHttpManager.getInstance(loanApplication) AppHttpManager.getInstance(loanApplication)
.call(loanService.showTurn(), .call(loanService.orders(),
object : BaseSubscriber<BaseResponse<NineShowBean>>() { object : BaseSubscriber<BaseResponse<BannerList>>() {
override fun onCompleted() { override fun onCompleted() {
if (isLinkView) return if (isLinkView) return
} }
override fun onNext(baseResponse: BaseResponse<NineShowBean>) { override fun onError(e: Throwable) {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<BannerList>) {
if (isLinkView) return if (isLinkView) return
val code = baseResponse.status val code = baseResponse.status
val message = baseResponse.message val message = baseResponse.message
when (code) { when (code) {
200 -> { 200 -> {
val data = baseResponse.data view.ordersSuc(baseResponse.data)
if (data != null) { }
view.showTurnSuc(data) else -> {
view.showToast(message)
// AppPreferencesManager.get()
// .put(Constant.LUCKY_FLAG, data.isShow)
// AppPreferencesManager.get()
// .put(Constant.LUCKY_COMPLETE, data.complete)
// AppPreferencesManager.get()
// .put(Constant.LUCKY_NEED, data.need)
}
} }
} }
} }
override fun onError(e: Throwable?) {
if (isLinkView) return
}
}) })
} }
fun orders() { fun signAfterSeconds() {
AppHttpManager.getInstance(loanApplication) AppHttpManager.getInstance(loanApplication)
.call(loanService.orders(), .call(loanService.signAfterSeconds(),
object : BaseSubscriber<BaseResponse<BannerList>>() { object : BaseSubscriber<BaseResponse<JsonObject>>() {
override fun onCompleted() { override fun onCompleted() {
if (isLinkView) return if (isLinkView) return
} }
...@@ -126,15 +121,17 @@ class HomePresenter : BasePresenter<HomeView>() { ...@@ -126,15 +121,17 @@ class HomePresenter : BasePresenter<HomeView>() {
if (isLinkView) return if (isLinkView) return
} }
override fun onNext(baseResponse: BaseResponse<BannerList>) { override fun onNext(baseResponse: BaseResponse<JsonObject>) {
if (isLinkView) return if (isLinkView) return
val code = baseResponse.status val code = baseResponse.status
val message = baseResponse.message val message = baseResponse.message
when (code) { when (code) {
200 -> { 200 -> {
view.ordersSuc(baseResponse.data) try {
view.signAfterSecondsSuc(baseResponse.data.get("time").asInt)
} catch (e: Exception) {
e.printStackTrace()
}
} }
else -> { else -> {
view.showToast(message) view.showToast(message)
......
...@@ -10,5 +10,5 @@ interface HomeView : BaseView { ...@@ -10,5 +10,5 @@ interface HomeView : BaseView {
fun getSoltVedioSuc(data: IndexList?) fun getSoltVedioSuc(data: IndexList?)
fun getRecommendVedioSuc(data: RecoBean?) fun getRecommendVedioSuc(data: RecoBean?)
fun showTurnSuc(data: NineShowBean) fun signAfterSecondsSuc(time:Int)
} }
...@@ -343,6 +343,12 @@ public interface LoanService { ...@@ -343,6 +343,12 @@ public interface LoanService {
@POST("api/vedioV1/confs") @POST("api/vedioV1/confs")
Observable<BaseResponse<JsonObject>> showVedioConfs(); Observable<BaseResponse<JsonObject>> showVedioConfs();
/**
* 视频页广告开关
*/
@POST("api/vip/signAfterSeconds")
Observable<BaseResponse<JsonObject>> signAfterSeconds();
/** /**
* 默认http工厂 * 默认http工厂
......
package com.duben.loveplayletu.ui.activitys package com.duben.loveplayletu.ui.activitys
import android.os.Bundle
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View import android.view.View
import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieComposition
import com.airbnb.lottie.LottieCompositionFactory
import com.airbnb.lottie.LottieDrawable
import com.duben.library.utils.nodoubleclick.AntiShake import com.duben.library.utils.nodoubleclick.AntiShake
import com.duben.loveplayletu.R import com.duben.loveplayletu.R
import com.duben.loveplayletu.mvp.model.OrderRecordBean
import com.duben.loveplayletu.ui.activitys.base.BaseActivity import com.duben.loveplayletu.ui.activitys.base.BaseActivity
import com.duben.loveplayletu.ui.widgets.SimpleCountDownTimer import com.duben.loveplayletu.ui.widgets.SimpleCountDownTimer
import kotlinx.android.synthetic.main.activity_alipaytime.* import kotlinx.android.synthetic.main.activity_alipaytime.*
...@@ -14,8 +20,12 @@ import kotlinx.android.synthetic.main.activity_alipaytime.* ...@@ -14,8 +20,12 @@ import kotlinx.android.synthetic.main.activity_alipaytime.*
* 作者:孟崔广 * 作者:孟崔广
*/ */
class AlipayTimeActivity : BaseActivity(), View.OnClickListener { class AlipayTimeActivity : BaseActivity(), View.OnClickListener {
companion object {
const val ALIPAY_TIME = "alipay_time"
}
private var countDownTimer: SimpleCountDownTimer? = null private var countDownTimer: SimpleCountDownTimer? = null
private var alipaytime = 0
override fun getContentViewLayoutID() = R.layout.activity_alipaytime override fun getContentViewLayoutID() = R.layout.activity_alipaytime
...@@ -25,9 +35,16 @@ class AlipayTimeActivity : BaseActivity(), View.OnClickListener { ...@@ -25,9 +35,16 @@ class AlipayTimeActivity : BaseActivity(), View.OnClickListener {
override fun getOverridePendingTransitionMode() = TransitionMode.FADE override fun getOverridePendingTransitionMode() = TransitionMode.FADE
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
alipaytime = it.getInt(ALIPAY_TIME, 0)
}
}
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
countDownTimer= SimpleCountDownTimer(30*60*1000, tv_alipaytime).setOnFinishListener { countDownTimer = SimpleCountDownTimer(alipaytime.toLong() * 1000, tv_alipaytime).setOnFinishListener {
showToast("11111") finish()
}.start() as SimpleCountDownTimer? }.start() as SimpleCountDownTimer?
} }
...@@ -57,4 +74,15 @@ class AlipayTimeActivity : BaseActivity(), View.OnClickListener { ...@@ -57,4 +74,15 @@ class AlipayTimeActivity : BaseActivity(), View.OnClickListener {
// } // }
} }
private fun playCollectAnim(view: LottieAnimationView) {
val lottieDrawable = LottieDrawable()
LottieCompositionFactory.fromAsset(context, "home_collect.json")
.addListener { result: LottieComposition? ->
lottieDrawable.setImagesAssetsFolder("images/")
lottieDrawable.composition = result
lottieDrawable.loop(false)
lottieDrawable.playAnimation()
}
view.setImageDrawable(lottieDrawable)
}
} }
\ No newline at end of file
...@@ -10,11 +10,12 @@ ...@@ -10,11 +10,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <com.airbnb.lottie.LottieAnimationView
android:layout_width="200dp" android:id="@+id/zan_iv"
android:layout_height="200dp" android:layout_width="35dp"
android:layout_gravity="center" android:layout_height="35dp"
android:src="@mipmap/ic_my_new"></ImageView> android:layout_marginTop="10dp"
android:src="@mipmap/home_collect_img_0" />
<TextView <TextView
android:id="@+id/tv_alipaytime" android:id="@+id/tv_alipaytime"
......
...@@ -243,17 +243,22 @@ ...@@ -243,17 +243,22 @@
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
<ImageView <com.airbnb.lottie.LottieAnimationView
android:id="@+id/iv_kefu_main" android:id="@+id/iv_kefu_main"
android:layout_width="80dp" android:layout_width="80dp"
android:layout_height="88dp" android:layout_height="88dp"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:visibility="gone"
android:layout_marginBottom="90dp" android:layout_marginBottom="90dp"
android:gravity="center" android:gravity="center"
app:lottie_fileName="main_alipay.json"
app:lottie_autoPlay="true"
app:lottie_loop="true"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />
<LinearLayout <LinearLayout
android:id="@+id/ll_lucky" android:id="@+id/ll_lucky"
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
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