Commit 903a8813 by konghaorui

晚上首页Fragment逻辑、补充分隔符、更新json缓存文件

parent 1b107bf5
...@@ -34,6 +34,7 @@ public final class DemoGlobalConfig implements IConfigModule { ...@@ -34,6 +34,7 @@ public final class DemoGlobalConfig implements IConfigModule {
builder.setFrom("ydl".equals(BuildConfig.FLAVOR) ? YDLConstants.FROM_YDL : YDLConstants.FROM_XLZX) builder.setFrom("ydl".equals(BuildConfig.FLAVOR) ? YDLConstants.FROM_YDL : YDLConstants.FROM_XLZX)
.addUrl("github", APP_DOMAIN) .addUrl("github", APP_DOMAIN)
.setEnv(appEnv) .setEnv(appEnv)
.setName("yidianling")
.setDebug(BuildConfig.DEBUG); .setDebug(BuildConfig.DEBUG);
} }
} }
...@@ -5,8 +5,8 @@ ext { ...@@ -5,8 +5,8 @@ ext {
ydl_app = [ ydl_app = [
appName : "心理咨询壹点灵", appName : "心理咨询壹点灵",
applicationId: "com.cxzapp.yidianling", applicationId: "com.cxzapp.yidianling",
versionName : "4.0.31", versionName : "4.0.81",
versionCode : 4031, versionCode : 4081,
] ]
xlzx_app = [ xlzx_app = [
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -37,6 +37,7 @@ import com.yidianling.home.listener.HomeConfideRecyleSuspendListener ...@@ -37,6 +37,7 @@ import com.yidianling.home.listener.HomeConfideRecyleSuspendListener
import com.yidianling.home.model.bean.* import com.yidianling.home.model.bean.*
import com.yidianling.home.presenter.HomePresenterImpl import com.yidianling.home.presenter.HomePresenterImpl
import com.yidianling.home.ui.view.CouponDialog import com.yidianling.home.ui.view.CouponDialog
import com.yidianling.home.ui.view.HomeSpaceItemDecoration
import com.yidianling.home.utils.HomeAnimUtils import com.yidianling.home.utils.HomeAnimUtils
import com.yidianling.user.api.service.IUserService import com.yidianling.user.api.service.IUserService
import kotlinx.android.synthetic.ydl.home_fragment.* import kotlinx.android.synthetic.ydl.home_fragment.*
...@@ -96,22 +97,22 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>() ...@@ -96,22 +97,22 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>()
} }
override fun initDataAndEvent() { override fun initDataAndEvent() {
val homeViewOrder = HomeViewConfig.HomeViewOrder() // val homeViewOrder = HomeViewConfig.HomeViewOrder()
//
homeViewOrder.bannerIndex = -1 // homeViewOrder.bannerIndex = -1
homeViewOrder.testIndex = 1 // homeViewOrder.testIndex = 1
homeViewOrder.consultIndex = 2 // homeViewOrder.consultIndex = 2
homeViewOrder.footerIndex = 3 // homeViewOrder.footerIndex = 3
//
homeViewOrder.fmIndex = null // homeViewOrder.fmIndex = null
homeViewOrder.articleIndex = null // homeViewOrder.articleIndex = null
homeViewOrder.dynamicIndex = null // homeViewOrder.dynamicIndex = null
homeViewOrder.museIndex = null // homeViewOrder.museIndex = null
homeViewOrder.confideIndex = null // homeViewOrder.confideIndex = null
homeViewOrder.courseIndex = null // homeViewOrder.courseIndex = null
homeViewOrder.buttonIndex = null // homeViewOrder.buttonIndex = null
//
HomeViewConfig.setOrder(homeViewOrder) // HomeViewConfig.setOrder(homeViewOrder)
initHomeEvent() initHomeEvent()
initView() initView()
...@@ -124,16 +125,18 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>() ...@@ -124,16 +125,18 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>()
} }
private fun initAdapter() { private fun initAdapter() {
// mPresenter?.localHomeData(this.context, "home_data.json") mPresenter?.localHomeData(this.context, "home_data.json")
adapter = YdlHomeAdapter(context, homeEvent!!, ArrayList()) adapter = YdlHomeAdapter(context, homeEvent!!, ArrayList())
val layoutManager = LinearLayoutManager(context) val layoutManager = LinearLayoutManager(context)
home_module_fragment_recycler.layoutManager = layoutManager home_module_fragment_recycler.layoutManager = layoutManager
home_module_fragment_recycler.adapter = adapter home_module_fragment_recycler.adapter = adapter
val space = resources.getDimension(R.dimen.platform_dp_24).toInt()
home_module_fragment_recycler.addItemDecoration(HomeSpaceItemDecoration(space))
initRvListener() initRvListener()
} }
open fun initRvListener() { open fun initRvListener() {
// home_module_fragment_recycler.addOnScrollListener(homeEvent?.onPageScroll(view_rl_top_bg)) home_module_fragment_recycler.addOnScrollListener(homeEvent?.onPageScroll(view_rl_top_bg))
scrollListner = HomeConfideRecyleSuspendListener() scrollListner = HomeConfideRecyleSuspendListener()
home_module_fragment_recycler.addOnScrollListener(scrollListner) home_module_fragment_recycler.addOnScrollListener(scrollListner)
setSuspendListener() setSuspendListener()
...@@ -141,18 +144,14 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>() ...@@ -141,18 +144,14 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>()
private fun initView() { private fun initView() {
if(HomeViewConfig.getOrder().bannerIndex==null||HomeViewConfig.getOrder().bannerIndex==-1){ if(HomeViewConfig.getOrder().bannerIndex==null||HomeViewConfig.getOrder().bannerIndex==-1){
var marginTop = this.resources.getDimension(R.dimen.home_home_title_bar_height) var marginTop = this.resources.getDimension(R.dimen.home_home_title_bar_height)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
val statusBarHeight = StatusBarUtils.getStatusBarHeight(activity) val statusBarHeight = StatusBarUtils.getStatusBarHeight(activity)
marginTop += statusBarHeight marginTop += statusBarHeight
} }
val lp = home_swipe_refresh_layout.layoutParams as FrameLayout.LayoutParams val lp = home_swipe_refresh_layout.layoutParams as FrameLayout.LayoutParams
lp.topMargin = marginTop.toInt() lp.topMargin = marginTop.toInt()
home_swipe_refresh_layout.layoutParams = lp home_swipe_refresh_layout.layoutParams = lp
} }
searchText = this.resources.getText(R.string.home_search_hint).toString() searchText = this.resources.getText(R.string.home_search_hint).toString()
home_swipe_refresh_layout?.setOnRefreshListener(this) home_swipe_refresh_layout?.setOnRefreshListener(this)
......
package com.yidianling.home.ui.view
import android.graphics.Rect
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.RecyclerView.ItemDecoration
import android.view.View
import com.yidianling.home.constract.HomeViewConfig
/**
* Created by haorui on 2020/3/23.
* Des:
*/
class HomeSpaceItemDecoration(var mSpace: Int) : ItemDecoration() {
override fun getItemOffsets(
outRect: Rect,
view: View,
parent: RecyclerView,
state: RecyclerView.State
) {
super.getItemOffsets(outRect, view, parent, state)
val position = parent.getChildAdapterPosition(view)
when(val viewType = parent.adapter.getItemViewType(position)){
HomeViewConfig.getOrder().bannerIndex->{
//空banner时不设置间距
if (viewType!=-1&&HomeViewConfig.getOrder().buttonIndex==null){
outRect.bottom = mSpace
}
}
else ->{
if (HomeViewConfig.getOrder().footerIndex!=null){
//底部footer显示时,倒数第一、二个View不设置间距
if ( position!=parent.adapter.itemCount-1
&& position!=parent.adapter.itemCount-2){
outRect.bottom = mSpace
}
}else{
outRect.bottom = mSpace
}
}
}
}
}
\ No newline at end of file
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:paddingTop="@dimen/platform_dp_24"
android:paddingBottom="@dimen/platform_dp_14"> android:paddingBottom="@dimen/platform_dp_14">
<View <View
......
...@@ -114,7 +114,7 @@ class GlobalConfig private constructor(var builder: Builder) { ...@@ -114,7 +114,7 @@ class GlobalConfig private constructor(var builder: Builder) {
.setMultipleUrlMap(multipleUrl) .setMultipleUrlMap(multipleUrl)
if (okHttpClient == null) { if (okHttpClient == null) {
okHttpClient = HttpConfig.getInstance().createOkHttp(context, appFrom, appDebug) okHttpClient = HttpConfig.getInstance().createOkHttp()
} }
apiFactory.setOkClient(okHttpClient) apiFactory.setOkClient(okHttpClient)
......
...@@ -104,7 +104,12 @@ class HttpConfig { ...@@ -104,7 +104,12 @@ class HttpConfig {
} }
} }
fun createOkHttp(context: Context, appFrom: String, appDebug: Boolean): OkHttpClient { fun createOkHttp(): OkHttpClient {
val globalConfig = BaseApp.instance.getGlobalConfig()
val context = BaseApp.getApp()
val appDebug = globalConfig.appDebug
val appName = globalConfig.appName
//获取证书 //获取证书
val cerInputStream = context.resources.openRawResource(com.ydl.ydlcommon.R.raw.ydl_trust); val cerInputStream = context.resources.openRawResource(com.ydl.ydlcommon.R.raw.ydl_trust);
val builder = OkHttpConfig.Builder(context); val builder = OkHttpConfig.Builder(context);
...@@ -116,7 +121,7 @@ class HttpConfig { ...@@ -116,7 +121,7 @@ class HttpConfig {
} }
return builder return builder
.setInterceptor(commonParams(),requestHead(appFrom)) .setInterceptor(commonParams(),requestHead(appName))
.setRequestHandler(getRequestHandler()) .setRequestHandler(getRequestHandler())
.setReadTimeout(15) .setReadTimeout(15)
.setWriteTimeout(15) .setWriteTimeout(15)
...@@ -251,7 +256,7 @@ class HttpConfig { ...@@ -251,7 +256,7 @@ class HttpConfig {
private data class Param(val name: String, val value: String) private data class Param(val name: String, val value: String)
// 添加请求头 // 添加请求头
private fun requestHead(appFrom: String): Interceptor { private fun requestHead(appName: String): Interceptor {
return Interceptor { return Interceptor {
val request = it.request() val request = it.request()
val paramsString = StringBuilder() val paramsString = StringBuilder()
...@@ -318,7 +323,7 @@ class HttpConfig { ...@@ -318,7 +323,7 @@ class HttpConfig {
) )
) )
.addHeader(OS_TYPE, "2") .addHeader(OS_TYPE, "2")
.addHeader(APP_NAME, appFrom) .addHeader(APP_NAME, appName)
val loginBean = ModularServiceManager.getPlatformUserService()?.getUser() val loginBean = ModularServiceManager.getPlatformUserService()?.getUser()
if (loginBean != null) { if (loginBean != null) {
builder.addHeader(TOKEN, loginBean.token) builder.addHeader(TOKEN, loginBean.token)
......
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