Commit ea852fdd authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 86e8ec62
......@@ -19,6 +19,7 @@ object Constant {
const val PAGE_SIZE = 10
const val ROUTE_BOOK_ID = "BOOK_ID"
const val IS_FIRST_VEDIO = "is_first_vedio"
// 协议地址
var REGISTER_URL =
......
package com.duben.infinitefunjia.mvp.model;
import java.io.Serializable;
public class FirstBookBean implements Serializable {
private BookBean articleMsg;
public BookBean getArticleMsg() {
return articleMsg;
}
public void setArticleMsg(BookBean articleMsg) {
this.articleMsg = articleMsg;
}
}
......@@ -5,9 +5,7 @@ import com.duben.infinitefunjia.common.DeviceInfo
import com.duben.library.net.neterror.Throwable
import com.duben.infinitefunjia.manager.AppHttpManager
import com.duben.infinitefunjia.manager.UserManager
import com.duben.infinitefunjia.mvp.model.BaseResponse
import com.duben.infinitefunjia.mvp.model.BookListBean
import com.duben.infinitefunjia.mvp.model.UserBean
import com.duben.infinitefunjia.mvp.model.*
import com.duben.infinitefunjia.mvp.views.BookCityView
import com.duben.infinitefunjia.utils.DeviceUuidFactory
import com.duben.library.net.neterror.BaseSubscriber
......@@ -207,4 +205,31 @@ class BookCityPresenter : BasePresenter<BookCityView>() {
}
fun getSoltVedio() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.firstArticle(),
object : BaseSubscriber<BaseResponse<FirstBookBean>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<FirstBookBean>) {
if (isLinkView) return
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
view.getSoltVedioSuc(baseResponse.data)
}
}
}
})
}
}
\ No newline at end of file
......@@ -184,7 +184,8 @@ class VipPresenter : BasePresenter<VipView>() {
fun getVipPayParams(payChannel: String, pid: String,isInstallAlipay:Boolean) {
val vo = HashMap<String, Any>()
vo["payChannel"] = payChannel
// vo["payChannel"] = payChannel
vo["payChannel"] = "ALIPAY"
vo["pid"] = pid
vo["isInstallAlipay"] = isInstallAlipay
AppHttpManager.getInstance(loanApplication)
......@@ -206,7 +207,8 @@ class VipPresenter : BasePresenter<VipView>() {
val code: Int = baseResponse.getStatus()
when (code) {
200 -> {
view.getVipPayParamsSuc(payChannel, baseResponse.data)
// view.getVipPayParamsSuc(payChannel, baseResponse.data)
view.getVipPayParamsSuc("ALIPAY", baseResponse.data)
}
else -> {
view.showToast(baseResponse.getMessage())
......
package com.duben.infinitefunjia.mvp.views
import com.duben.infinitefunjia.mvp.model.BookBean
import com.duben.infinitefunjia.mvp.model.BookListBean
import com.duben.infinitefunjia.mvp.model.FirstBookBean
interface BookCityView : BaseView {
fun getHotBookSuc(data: BookListBean)
......@@ -11,4 +13,5 @@ interface BookCityView : BaseView {
fun getBannerBookSuc(data: BookListBean)
fun getBannerBookFail()
fun getSoltVedioSuc(data: FirstBookBean)
}
......@@ -2,6 +2,8 @@ package com.duben.infinitefunjia.net;
import android.text.TextUtils;
import com.duben.infinitefunjia.mvp.model.BookBean;
import com.duben.infinitefunjia.mvp.model.FirstBookBean;
import com.google.gson.JsonObject;
import com.duben.infinitefunjia.BuildConfig;
import com.duben.infinitefunjia.mvp.model.BannerList;
......@@ -245,6 +247,14 @@ public interface LoanService {
@POST("api/book/articleList")
Observable<BaseResponse<BookListBean>> getArticleList(@Body Map<String, Object> vo);
/**
* 书库分类
*
* @return
*/
@POST("api/book/firstArticle")
Observable<BaseResponse<FirstBookBean>> firstArticle();
/**
* 默认http工厂
*/
......
......@@ -62,13 +62,7 @@ class GuideActivity : BaseActivity(), GuideView {
btn_guide_start.setOnClickListener {
vp_guide_viewpager.currentItem = ++count
if (count == layouts.size) {
if (TextUtils.isEmpty(UserManager.getInstance().userID)) {
readyGoThenKill(MainActivity::class.java)
} else {
val bundle = Bundle()
// bundle.putBoolean(VipActivity.IS_GUIDE, true)
readyGoThenKill(VipActivity::class.java, bundle)
}
//带点渐变动画
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
}
......
......@@ -94,11 +94,7 @@ class SplashAdActivity : BaseActivity() {
* 跳转到主页面
*/
private fun goToMainActivity() {
if (UserManager.getInstance().vipFlag) {
readyGoThenKill(MainActivity::class.java)
} else {
readyGoThenKill(VipActivity::class.java)
}
}
/**
......
......@@ -160,25 +160,30 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
* 设置content样式
*/
private fun setVipContent(bean: VipBean.ListBean) {
if (bean.isAlipay && bean.isWeixin) {
ll_vip_alipay.visibility = View.VISIBLE
ll_vip_wx.visibility = View.VISIBLE
payType = WEIXIN_PAY
iv_vip_wx.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_none)
} else if (bean.isAlipay && !bean.isWeixin) {
// if (bean.isAlipay && bean.isWeixin) {
// ll_vip_alipay.visibility = View.VISIBLE
// ll_vip_wx.visibility = View.VISIBLE
// payType = WEIXIN_PAY
// iv_vip_wx.setImageResource(R.mipmap.ic_vip_enable_blue)
// iv_vip_alipay.setImageResource(R.mipmap.ic_vip_none)
// } else if (bean.isAlipay && !bean.isWeixin) {
// ll_vip_alipay.visibility = View.VISIBLE
// ll_vip_wx.visibility = View.GONE
// payType = ALIPAY
// iv_vip_alipay.setImageResource(R.mipmap.ic_vip_enable_blue)
// iv_vip_wx.setImageResource(R.mipmap.ic_vip_none)
// } else if (!bean.isAlipay && bean.isWeixin) {
// ll_vip_alipay.visibility = View.GONE
// ll_vip_wx.visibility = View.VISIBLE
// payType = WEIXIN_PAY
// iv_vip_wx.setImageResource(R.mipmap.ic_vip_enable_blue)
// iv_vip_alipay.setImageResource(R.mipmap.ic_vip_none)
// }
ll_vip_alipay.visibility = View.VISIBLE
ll_vip_wx.visibility = View.GONE
payType = ALIPAY
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_wx.setImageResource(R.mipmap.ic_vip_none)
} else if (!bean.isAlipay && bean.isWeixin) {
ll_vip_alipay.visibility = View.GONE
ll_vip_wx.visibility = View.VISIBLE
payType = WEIXIN_PAY
iv_vip_wx.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_none)
}
if (!TextUtils.isEmpty(bean.remarks)) {
......@@ -264,8 +269,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> {
if (UserManager.getInstance().newFlag
&& vipList != null && vipList!!.size > 0
if (vipList != null && vipList!!.size > 0
) {
vipAdapter.setPosition(0)
......@@ -293,8 +297,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
when (v?.id) {
R.id.ic_vip_quit -> {
if (UserManager.getInstance().newFlag &&
vipList != null && vipList!!.size > 0
if (vipList != null && vipList!!.size > 0
) {
vipAdapter.setPosition(0)
vipAdapter.notifyDataSetChanged()
......
package com.duben.infinitefunjia.ui.fragment
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.Spanned
......@@ -17,14 +19,17 @@ import com.duben.infinitefunjia.common.Constant
import com.duben.infinitefunjia.manager.UserManager
import com.duben.infinitefunjia.mvp.model.BookBean
import com.duben.infinitefunjia.mvp.model.BookListBean
import com.duben.infinitefunjia.mvp.model.FirstBookBean
import com.duben.infinitefunjia.mvp.presenters.BookCityPresenter
import com.duben.infinitefunjia.mvp.views.BookCityView
import com.duben.infinitefunjia.ui.activitys.BookReadActivity
import com.duben.infinitefunjia.ui.activitys.BookSearchActivity
import com.duben.infinitefunjia.ui.activitys.VipActivity
import com.duben.infinitefunjia.ui.adapter.HotBookAdapter
import com.duben.infinitefunjia.ui.adapter.NewBookAdapter
import com.duben.infinitefunjia.ui.adapter.ImageTitleAdapter
import com.duben.infinitefunjia.ui.fragment.base.LazyLoadBaseFragment
import com.duben.infinitefunjia.utils.AppPreferencesManager
import com.duben.infinitefunjia.utils.GridSpacingItemDecoration
import com.duben.infinitefunjia.utils.RoundBackgroundColorSpan
import com.duben.library.utils.GlideUtils
......@@ -55,6 +60,10 @@ class BookCityFragment : LazyLoadBaseFragment(), BookCityView, View.OnClickListe
initView()
initListener()
Handler(Looper.getMainLooper()).postDelayed({
goToMainActivity()
}, 300)
}
private fun initView() {
......@@ -121,6 +130,10 @@ class BookCityFragment : LazyLoadBaseFragment(), BookCityView, View.OnClickListe
rv_newbook.adapter = newBookAdapter
}
private fun goToMainActivity() {
bookCityPresenter.getSoltVedio()
}
override fun onHiddenChanged(hidden: Boolean) {
if (hidden) { // 不在最前端界面显示
onPause()
......@@ -178,6 +191,20 @@ class BookCityFragment : LazyLoadBaseFragment(), BookCityView, View.OnClickListe
}
override fun getBannerBookFail() {}
override fun getSoltVedioSuc(data: FirstBookBean) {
val firstVedio = AppPreferencesManager.get().getBoolean(Constant.IS_FIRST_VEDIO, true)
if (data.articleMsg != null && firstVedio) {
val bundle = Bundle()
bundle.putString(Constant.ROUTE_BOOK_ID, data.articleMsg.id)
readyGo(BookReadActivity::class.java, bundle)
} else {
if (!UserManager.getInstance().vipFlag) {
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_MAIN, true)
readyGo(VipActivity::class.java, bundle)
}
}
}
override fun onClick(v: View?) {
v?.let {
......
......@@ -103,10 +103,10 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
backPhoneDialog()
}
R.id.ll_my_set -> {
val bundle = Bundle()
bundle.putString(Constant.ROUTE_BOOK_ID, "80670")
readyGo(LongBookReadActivity::class.java, bundle)
// readyGo(SettingsActivity::class.java)
// val bundle = Bundle()
// bundle.putString(Constant.ROUTE_BOOK_ID, "80670")
// readyGo(LongBookReadActivity::class.java, bundle)
readyGo(SettingsActivity::class.java)
}
}
......
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