Commit ea852fdd authored by mengcuiguang's avatar mengcuiguang

代码优化

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