Commit 5126c0ac by 徐健

咨询列表UI校对

parent 71175894
ext {
kotlin_version = "1.3.21"
dev_mode = true
dev_mode = false
ydl_app = [
appName : "心理咨询壹点灵",
......@@ -44,7 +44,7 @@ ext {
//第三步 若干
"m-confide" : "0.0.41.3",
"m-consultant" : "0.0.51.14",
"m-consultant" : "0.0.51.17",
"m-fm" : "0.0.23.5",
"m-user" : "0.0.41.3",
"m-home" : "0.0.6.26",
......
......@@ -53,6 +53,7 @@ import com.yidianling.consultant.ui.view.AreaPopupWindow
import com.yidianling.consultant.ui.view.CategoryPopupWindow
import com.yidianling.consultant.ui.view.FilterPopupWindow
import com.yidianling.consultant.ui.view.SortPopupWindow
import com.yidianling.consultant.ui.view.topView.RecommendListView
import kotlinx.android.synthetic.main.consultant_activity_expert_search_list.*
import kotlinx.android.synthetic.main.consultant_item_filter_online.view.*
import kotlinx.android.synthetic.main.consultant_layout_search_content.*
......@@ -196,6 +197,13 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
srlContainer.setProgressViewOffset(false, 0, 200)
srlContainer.setOnRefreshListener(this)
recommendListView.addViewPagerScrollStateListener(object : RecommendListView.ViewPagerScrollStateCallback {
override fun viewPagerScroll(isScrolling: Boolean) {
//如果viewpager正在滚动,则禁止下拉刷新
srlContainer.isEnabled = !isScrolling
}
})
appbar_layout.addOnOffsetChangedListener { appbarLayout, i ->
srlContainer.isEnabled = i >= 0
}
......
......@@ -49,6 +49,7 @@ import com.yidianling.consultant.ui.view.AreaPopupWindow
import com.yidianling.consultant.ui.view.CategoryPopupWindow
import com.yidianling.consultant.ui.view.FilterPopupWindow
import com.yidianling.consultant.ui.view.SortPopupWindow
import com.yidianling.consultant.ui.view.topView.RecommendListView
import kotlinx.android.synthetic.main.consultant_activity_expert_search_list.*
import kotlinx.android.synthetic.main.consultant_item_filter_online.view.*
import kotlinx.android.synthetic.main.consultant_layout_search_content.*
......@@ -156,6 +157,13 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
srlContainer.setOnRefreshListener(this)
initNetLossView()
recommendListView.addViewPagerScrollStateListener(object : RecommendListView.ViewPagerScrollStateCallback {
override fun viewPagerScroll(isScrolling: Boolean) {
//如果viewpager正在滚动,则禁止下拉刷新
srlContainer.isEnabled = !isScrolling
}
})
appbar_layout.addOnOffsetChangedListener { appbarLayout, i ->
srlContainer.isEnabled = i >= 0
}
......
package com.yidianling.consultant.ui.view
import android.content.Context
import android.support.v4.widget.SwipeRefreshLayout
import android.util.AttributeSet
import android.view.MotionEvent
// 判断 X 轴的 Y 轴的 移动的距离差 来判断是否 需要拦截事件
class ExpertSearchSwipeRefreshLayout(context: Context, attrs: AttributeSet) :
SwipeRefreshLayout(context, attrs) {
// 上一次触摸时的X坐标
private var mPreDownX: Float = 0.toFloat()
private var mPreDownY: Float = 0.toFloat()
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
when (ev.action) {
MotionEvent.ACTION_DOWN -> {
mPreDownX = ev.x
mPreDownY = ev.y
}
MotionEvent.ACTION_MOVE -> {
val eventX = ev.x
val eventY = ev.y
val xAbs = Math.abs(eventX - mPreDownX)
val yAbs = Math.abs(eventY - mPreDownY)
// 如果 X 轴移动的 距离大于 Y 轴移动的距离
// 那么 不拦截 触摸事件 交给 下面的处理
if (xAbs > yAbs) {
return false
}
}
}
return super.onInterceptTouchEvent(ev)
}
}
......@@ -5,20 +5,18 @@ import android.content.Context
import android.support.v4.view.PagerAdapter
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.utils.RxLifecycleUtils
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.R
import com.yidianling.consultant.bean.ExpertSearchBigShotBean
import com.yidianling.consultant.bean.ExpertSearchRecommandBean
import com.yidianling.consultant.http.ExpertSearchHttpImpl
import io.reactivex.Scheduler
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
......@@ -54,8 +52,8 @@ class RecommendListView : LinearLayout {
private var minHeight: Int = 0 // viewPager最小高度
private var maxHeight: Int = 0 // viewPager最大高度
private var dp_15: Int = RxImageTool.dp2px(15f)
private var dp_5: Int = RxImageTool.dp2px(5f)
private var dp_10: Int = RxImageTool.dp2px(10f)
private var dp_4: Int = RxImageTool.dp2px(4f)
private fun initView() {
......@@ -148,14 +146,24 @@ class RecommendListView : LinearLayout {
val item = RecommendItemView(mContext!!)
item.setPadding(RxImageTool.dp2px(15f), RxImageTool.dp2px(9f), RxImageTool.dp2px(15f), RxImageTool.dp2px(11f))
item.setPadding(
RxImageTool.dp2px(15f),
RxImageTool.dp2px(9f),
RxImageTool.dp2px(15f),
RxImageTool.dp2px(11f)
)
item.setData(mSceneSpecialTopicList[index])
ll.addView(item)
if (index + 1 < mSceneSpecialTopicList.size) {
val item1 = RecommendItemView(mContext!!)
item1.setPadding(0, RxImageTool.dp2px(9f), RxImageTool.dp2px(15f), RxImageTool.dp2px(11f))
item1.setPadding(
0,
RxImageTool.dp2px(9f),
RxImageTool.dp2px(15f),
RxImageTool.dp2px(11f)
)
item1.setData(mSceneSpecialTopicList[index + 1])
ll.addView(item1)
......@@ -180,14 +188,24 @@ class RecommendListView : LinearLayout {
val item = RecommendItemView(mContext!!)
item.setPadding(RxImageTool.dp2px(15f), RxImageTool.dp2px(9f), RxImageTool.dp2px(15f), RxImageTool.dp2px(11f))
item.setPadding(
RxImageTool.dp2px(15f),
RxImageTool.dp2px(9f),
RxImageTool.dp2px(15f),
RxImageTool.dp2px(11f)
)
item.setData(mSceneSpecialTopicList[index])
ll.addView(item)
if (index + 1 < mSceneSpecialTopicList.size) {
val item1 = RecommendItemView(mContext!!)
item1.setPadding(0, RxImageTool.dp2px(9f), RxImageTool.dp2px(15f), RxImageTool.dp2px(11f))
item1.setPadding(
0,
RxImageTool.dp2px(9f),
RxImageTool.dp2px(15f),
RxImageTool.dp2px(11f)
)
item1.setData(mSceneSpecialTopicList[index + 1])
ll.addView(item1)
......@@ -212,6 +230,25 @@ class RecommendListView : LinearLayout {
}
private fun addListener() {
recommendViewPager.setOnTouchListener(object : View.OnTouchListener {
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
when (event?.action) {
MotionEvent.ACTION_MOVE -> {
mListener?.viewPagerScroll(true)
}
MotionEvent.ACTION_UP -> {
mListener?.viewPagerScroll(false)
}
MotionEvent.ACTION_CANCEL -> {
mListener?.viewPagerScroll(false)
}
}
return false
}
})
recommendViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {
}
......@@ -236,20 +273,20 @@ class RecommendListView : LinearLayout {
private fun setSelectedIndex(position: Int) {
if (position == 0) {
leftIndicator.layoutParams = LayoutParams(dp_15, dp_5)
leftIndicator.layoutParams = LayoutParams(dp_10, dp_4)
val marginParams = leftIndicator.layoutParams as MarginLayoutParams
marginParams.rightMargin = RxImageTool.dp2px(6f)
leftIndicator.layoutParams = marginParams
leftIndicator.setBackgroundResource(R.drawable.consultant_indicator_selected)
rightIndicator.layoutParams = LayoutParams(dp_5, dp_5)
rightIndicator.layoutParams = LayoutParams(dp_4, dp_4)
rightIndicator.setBackgroundResource(R.drawable.consultant_indicator_unselected)
} else {
leftIndicator.layoutParams = LayoutParams(dp_5, dp_5)
leftIndicator.layoutParams = LayoutParams(dp_4, dp_4)
val marginParams = leftIndicator.layoutParams as MarginLayoutParams
marginParams.rightMargin = RxImageTool.dp2px(6f)
leftIndicator.layoutParams = marginParams
leftIndicator.setBackgroundResource(R.drawable.consultant_indicator_unselected)
rightIndicator.layoutParams = LayoutParams(dp_15, dp_5)
rightIndicator.layoutParams = LayoutParams(dp_10, dp_4)
rightIndicator.setBackgroundResource(R.drawable.consultant_indicator_selected)
}
}
......@@ -398,5 +435,18 @@ class RecommendListView : LinearLayout {
}
}
private var mListener: ViewPagerScrollStateCallback? = null
fun addViewPagerScrollStateListener(listener: ViewPagerScrollStateCallback?) {
listener?.let {
mListener = listener
}
}
interface ViewPagerScrollStateCallback {
fun viewPagerScroll(isScrolling: Boolean) //isScrolling
}
}
\ No newline at end of file
......@@ -2,10 +2,10 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:height="5dp"
android:width="15dp" />
<size android:height="4dp"
android:width="10dp" />
<corners android:radius="2.5dp" />
<corners android:radius="2dp" />
<solid android:color="#000000"/>
......
......@@ -2,10 +2,10 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:height="5dp"
android:width="5dp" />
<size android:height="4dp"
android:width="4dp" />
<corners android:radius="2.5dp" />
<corners android:radius="2dp" />
<solid android:color="#dddddd"/>
......
......@@ -11,7 +11,7 @@
layout="@layout/consultant_layout_search_toolbar"
android:layout_width="match_parent"
android:layout_height="48dp" />
<android.support.v4.widget.SwipeRefreshLayout
<com.yidianling.consultant.ui.view.ExpertSearchSwipeRefreshLayout
android:id="@+id/srlContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
......@@ -63,6 +63,6 @@
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</com.yidianling.consultant.ui.view.ExpertSearchSwipeRefreshLayout>
</LinearLayout>
......@@ -9,7 +9,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardElevation="0dp"
app:cardCornerRadius="6dp">
app:cardCornerRadius="4dp">
<ImageView
android:id="@+id/consultant_one_img_1"
android:layout_width="match_parent"
......
......@@ -10,7 +10,7 @@
android:layout_weight="1"
android:layout_height="match_parent"
app:cardElevation="0dp"
app:cardCornerRadius="6dp"
app:cardCornerRadius="4dp"
android:layout_marginRight="5dp">
<ImageView
android:id="@+id/consultant_three_img_1"
......@@ -25,7 +25,7 @@
android:layout_weight="1"
android:layout_height="match_parent"
app:cardElevation="0dp"
app:cardCornerRadius="6dp"
app:cardCornerRadius="4dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<ImageView
......@@ -41,7 +41,7 @@
android:layout_weight="1"
android:layout_height="match_parent"
app:cardElevation="0dp"
app:cardCornerRadius="6dp"
app:cardCornerRadius="4dp"
android:layout_marginLeft="5dp">
<ImageView
android:id="@+id/consultant_three_img_3"
......
......@@ -10,7 +10,7 @@
android:layout_weight="1"
android:layout_height="match_parent"
app:cardElevation="0dp"
app:cardCornerRadius="6dp"
app:cardCornerRadius="4dp"
android:layout_marginRight="5dp">
<ImageView
android:id="@+id/consultant_two_img_1"
......@@ -25,7 +25,7 @@
android:layout_weight="1"
android:layout_height="match_parent"
app:cardElevation="0dp"
app:cardCornerRadius="6dp"
app:cardCornerRadius="4dp"
android:layout_marginLeft="5dp">
<ImageView
android:id="@+id/consultant_two_img_2"
......
......@@ -14,20 +14,21 @@
<LinearLayout
android:id="@+id/recommendViewPagerIndicator"
android:layout_width="match_parent"
android:layout_height="15dp"
android:layout_height="14dp"
android:paddingBottom="10dp"
android:orientation="horizontal"
android:background="#FAFAFA"
android:gravity="center">
<View
android:id="@+id/leftIndicator"
android:layout_width="15dp"
android:layout_height="5dp"
android:layout_width="10dp"
android:layout_height="4dp"
android:layout_marginRight="3dp"/>
<View
android:id="@+id/rightIndicator"
android:layout_width="15dp"
android:layout_height="5dp"
android:layout_width="10dp"
android:layout_height="4dp"
android:layout_marginLeft="3dp"/>
</LinearLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -11,6 +12,8 @@
android:layout_height="40dp"
android:background="#eeeeee"
android:layout_marginRight="10dp"
app:cardCornerRadius="2dp"
app:cardElevation="0dp"
>
<ImageView
android:id="@+id/top_item_img"
......@@ -31,16 +34,17 @@
android:layout_weight="1"
android:gravity="left|top"
android:text="标题"
android:textSize="14dp"
android:textSize="13dp"
android:textStyle="bold"
android:maxLines="1"
android:textColor="#242424"
android:textStyle="bold"/>
android:layout_marginTop="1dp"
android:textColor="#242424"/>
<TextView
android:id="@+id/top_item_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|top"
android:gravity="left"
android:text="我是描述"
android:maxLines="1"
android:textSize="11dp"
......
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