Commit 903a8813 by konghaorui

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

parent 1b107bf5
......@@ -34,6 +34,7 @@ public final class DemoGlobalConfig implements IConfigModule {
builder.setFrom("ydl".equals(BuildConfig.FLAVOR) ? YDLConstants.FROM_YDL : YDLConstants.FROM_XLZX)
.addUrl("github", APP_DOMAIN)
.setEnv(appEnv)
.setName("yidianling")
.setDebug(BuildConfig.DEBUG);
}
}
......@@ -5,8 +5,8 @@ ext {
ydl_app = [
appName : "心理咨询壹点灵",
applicationId: "com.cxzapp.yidianling",
versionName : "4.0.31",
versionCode : 4031,
versionName : "4.0.81",
versionCode : 4081,
]
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
import com.yidianling.home.model.bean.*
import com.yidianling.home.presenter.HomePresenterImpl
import com.yidianling.home.ui.view.CouponDialog
import com.yidianling.home.ui.view.HomeSpaceItemDecoration
import com.yidianling.home.utils.HomeAnimUtils
import com.yidianling.user.api.service.IUserService
import kotlinx.android.synthetic.ydl.home_fragment.*
......@@ -96,22 +97,22 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>()
}
override fun initDataAndEvent() {
val homeViewOrder = HomeViewConfig.HomeViewOrder()
homeViewOrder.bannerIndex = -1
homeViewOrder.testIndex = 1
homeViewOrder.consultIndex = 2
homeViewOrder.footerIndex = 3
homeViewOrder.fmIndex = null
homeViewOrder.articleIndex = null
homeViewOrder.dynamicIndex = null
homeViewOrder.museIndex = null
homeViewOrder.confideIndex = null
homeViewOrder.courseIndex = null
homeViewOrder.buttonIndex = null
HomeViewConfig.setOrder(homeViewOrder)
// val homeViewOrder = HomeViewConfig.HomeViewOrder()
//
// homeViewOrder.bannerIndex = -1
// homeViewOrder.testIndex = 1
// homeViewOrder.consultIndex = 2
// homeViewOrder.footerIndex = 3
//
// homeViewOrder.fmIndex = null
// homeViewOrder.articleIndex = null
// homeViewOrder.dynamicIndex = null
// homeViewOrder.museIndex = null
// homeViewOrder.confideIndex = null
// homeViewOrder.courseIndex = null
// homeViewOrder.buttonIndex = null
//
// HomeViewConfig.setOrder(homeViewOrder)
initHomeEvent()
initView()
......@@ -124,16 +125,18 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>()
}
private fun initAdapter() {
// mPresenter?.localHomeData(this.context, "home_data.json")
mPresenter?.localHomeData(this.context, "home_data.json")
adapter = YdlHomeAdapter(context, homeEvent!!, ArrayList())
val layoutManager = LinearLayoutManager(context)
home_module_fragment_recycler.layoutManager = layoutManager
home_module_fragment_recycler.adapter = adapter
val space = resources.getDimension(R.dimen.platform_dp_24).toInt()
home_module_fragment_recycler.addItemDecoration(HomeSpaceItemDecoration(space))
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()
home_module_fragment_recycler.addOnScrollListener(scrollListner)
setSuspendListener()
......@@ -141,18 +144,14 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>()
private fun initView() {
if(HomeViewConfig.getOrder().bannerIndex==null||HomeViewConfig.getOrder().bannerIndex==-1){
var marginTop = this.resources.getDimension(R.dimen.home_home_title_bar_height)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
val statusBarHeight = StatusBarUtils.getStatusBarHeight(activity)
marginTop += statusBarHeight
}
val lp = home_swipe_refresh_layout.layoutParams as FrameLayout.LayoutParams
lp.topMargin = marginTop.toInt()
home_swipe_refresh_layout.layoutParams = lp
}
searchText = this.resources.getText(R.string.home_search_hint).toString()
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 @@
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:paddingTop="@dimen/platform_dp_24"
android:paddingBottom="@dimen/platform_dp_14">
<View
......
......@@ -114,7 +114,7 @@ class GlobalConfig private constructor(var builder: Builder) {
.setMultipleUrlMap(multipleUrl)
if (okHttpClient == null) {
okHttpClient = HttpConfig.getInstance().createOkHttp(context, appFrom, appDebug)
okHttpClient = HttpConfig.getInstance().createOkHttp()
}
apiFactory.setOkClient(okHttpClient)
......
......@@ -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 builder = OkHttpConfig.Builder(context);
......@@ -116,7 +121,7 @@ class HttpConfig {
}
return builder
.setInterceptor(commonParams(),requestHead(appFrom))
.setInterceptor(commonParams(),requestHead(appName))
.setRequestHandler(getRequestHandler())
.setReadTimeout(15)
.setWriteTimeout(15)
......@@ -251,7 +256,7 @@ class HttpConfig {
private data class Param(val name: String, val value: String)
// 添加请求头
private fun requestHead(appFrom: String): Interceptor {
private fun requestHead(appName: String): Interceptor {
return Interceptor {
val request = it.request()
val paramsString = StringBuilder()
......@@ -318,7 +323,7 @@ class HttpConfig {
)
)
.addHeader(OS_TYPE, "2")
.addHeader(APP_NAME, appFrom)
.addHeader(APP_NAME, appName)
val loginBean = ModularServiceManager.getPlatformUserService()?.getUser()
if (loginBean != null) {
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