Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
09db41a9
Commit
09db41a9
authored
Jun 14, 2022
by
fengquan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 倾诉列表添加搜索框
parent
9014f2e8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
261 additions
and
13 deletions
+261
-13
ConfideHomeActivity.kt
m-confide/src/main/java/com/ydl/confide/home/ConfideHomeActivity.kt
+2
-1
ConfideHomeAdapter.kt
m-confide/src/main/java/com/ydl/confide/home/adapter/ConfideHomeAdapter.kt
+0
-0
IConfideHomeConfig.kt
m-confide/src/main/java/com/ydl/confide/home/config/IConfideHomeConfig.kt
+2
-0
ConfideHomeRecyleSuspendListener.kt
m-confide/src/main/java/com/ydl/confide/home/listener/ConfideHomeRecyleSuspendListener.kt
+110
-11
confide_icon_input_search.png
m-confide/src/main/res/drawable-xxhdpi/confide_icon_input_search.png
+0
-0
confide_bg_hot_search_input.xml
m-confide/src/main/res/drawable/confide_bg_hot_search_input.xml
+9
-0
confide_edit_cursor_drawable.xml
m-confide/src/main/res/drawable/confide_edit_cursor_drawable.xml
+8
-0
confide_home_activity.xml
m-confide/src/main/res/layout/confide_home_activity.xml
+66
-1
confide_home_search_header.xml
m-confide/src/main/res/layout/confide_home_search_header.xml
+64
-0
No files found.
m-confide/src/main/java/com/ydl/confide/home/ConfideHomeActivity.kt
View file @
09db41a9
...
...
@@ -410,6 +410,7 @@ class ConfideHomeActivity :
initParam
()
hideError
()
cacheList
?.
addAll
(
0
,
list
)
cacheList
?.
add
(
0
,
ConfideHomeDataBean
(
IConfideHomeConfig
.
TYPE_SEARCH
,
null
,
null
,
null
,
-
1
))
updateAdapter
()
setSuspendListener
()
v_filterView
.
refreshView
()
...
...
@@ -419,7 +420,7 @@ class ConfideHomeActivity :
* 设置筛选模块悬浮顶部监听数据
*/
private
fun
setSuspendListener
()
{
listSuspendListener
?.
setFilterView
(
v_filterView
,
vFilterLine
)
listSuspendListener
?.
setFilterView
(
v_filterView
,
rl_search_head
,
vFilterLine
)
listSuspendListener
?.
setSectionAdapter
(
mConfideAdapter
!!
)
}
...
...
m-confide/src/main/java/com/ydl/confide/home/adapter/ConfideHomeAdapter.kt
View file @
09db41a9
This diff is collapsed.
Click to expand it.
m-confide/src/main/java/com/ydl/confide/home/config/IConfideHomeConfig.kt
View file @
09db41a9
...
...
@@ -20,6 +20,7 @@ interface IConfideHomeConfig{
const
val
TYPE_RECOMMEND
=
5
const
val
TYPE_SOUND
=
6
const
val
TYPE_VIDEO_SHOW
=
7
const
val
TYPE_SEARCH
=
8
const
val
TYPE_FOOTER
=
999
/**
* section id. 与上面相对应
...
...
@@ -31,6 +32,7 @@ interface IConfideHomeConfig{
const
val
SECTION_RECOMMEND
=
10005
const
val
SECTION_SOUND
=
10006
const
val
SECTION_CONSULTANT
=
10007
const
val
SECTION_SEARCH
=
10008
const
val
SECTION_FOOTER
=
19999
...
...
m-confide/src/main/java/com/ydl/confide/home/listener/ConfideHomeRecyleSuspendListener.kt
View file @
09db41a9
package
com.ydl.confide.home.listener
import
android.text.Editable
import
android.text.TextUtils
import
android.text.TextWatcher
import
android.util.Log
import
android.view.View
import
android.widget.EditText
import
android.widget.ImageView
import
android.widget.RelativeLayout
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
android.view.View
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.RxImageTool
import
com.ydl.confide.R
import
com.ydl.confide.home.adapter.ConfideHomeAdapter
import
com.ydl.confide.home.config.IConfideHomeConfig
import
com.ydl.confide.home.widget.ConfideHomeFilterView
import
com.ydl.ydlcommon.base.BaseActivityMgr
import
com.ydl.ydlcommon.utils.KeyboardChangeListener
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.RxImageTool
/**
* @author yuanwai
...
...
@@ -22,9 +32,14 @@ class ConfideHomeRecyleSuspendListener : RecyclerView.OnScrollListener() {
private
var
mSuspensionHeight
:
Int
=
RxImageTool
.
dip2px
(
48f
)
private
var
mSearchViewHeight
:
Int
=
RxImageTool
.
dip2px
(
48f
)
private
var
filterView
:
ConfideHomeFilterView
?
=
null
private
var
searchView
:
RelativeLayout
?
=
null
private
var
divView
:
View
?
=
null
private
var
searchText
=
""
private
var
adapter
:
ConfideHomeAdapter
?
=
null
fun
setFilterView
(
filterView
:
ConfideHomeFilterView
,
divView
:
View
)
{
...
...
@@ -32,6 +47,49 @@ class ConfideHomeRecyleSuspendListener : RecyclerView.OnScrollListener() {
this
.
divView
=
divView
}
fun
setFilterView
(
filterView
:
ConfideHomeFilterView
,
searchView
:
RelativeLayout
,
divView
:
View
)
{
this
.
filterView
=
filterView
this
.
divView
=
divView
this
.
searchView
=
searchView
val
keyboardChangeListener
=
KeyboardChangeListener
(
BaseActivityMgr
.
INST
.
topActivity
)
keyboardChangeListener
.
setKeyBoardListener
{
isShow
,
i
->
if
(!
isShow
)
{
searchView
.
findViewById
<
EditText
>(
R
.
id
.
etSearch
).
clearFocus
()
}
}
searchView
.
findViewById
<
EditText
>(
R
.
id
.
etSearch
).
addTextChangedListener
(
object
:
TextWatcher
{
override
fun
afterTextChanged
(
p0
:
Editable
?)
{
if
(
TextUtils
.
isEmpty
(
p0
))
{
searchView
.
findViewById
<
ImageView
>(
R
.
id
.
iv_delete_icon
).
visibility
=
View
.
INVISIBLE
}
else
{
searchView
.
findViewById
<
ImageView
>(
R
.
id
.
iv_delete_icon
).
visibility
=
View
.
VISIBLE
}
}
override
fun
beforeTextChanged
(
p0
:
CharSequence
,
p1
:
Int
,
p2
:
Int
,
p3
:
Int
)
{
}
override
fun
onTextChanged
(
char
:
CharSequence
,
p1
:
Int
,
p2
:
Int
,
p3
:
Int
)
{
if
(
char
!=
null
){
searchText
=
char
.
toString
()
}
}
})
searchView
.
findViewById
<
ImageView
>(
R
.
id
.
iv_delete_icon
).
setOnClickListener
{
searchView
.
findViewById
<
EditText
>(
R
.
id
.
etSearch
).
setText
(
""
)
}
}
fun
setSectionAdapter
(
adapter
:
ConfideHomeAdapter
)
{
this
.
adapter
=
adapter
}
...
...
@@ -41,6 +99,20 @@ class ConfideHomeRecyleSuspendListener : RecyclerView.OnScrollListener() {
if
(
null
!=
filterView
)
{
mSuspensionHeight
=
filterView
!!
.
height
}
if
(
searchView
!=
null
)
{
mSearchViewHeight
=
searchView
!!
.
height
}
searchView
!!
.
findViewById
<
EditText
>(
R
.
id
.
etSearch
).
clearFocus
()
val
viewHolder
=
recyclerView
.
findViewHolderForAdapterPosition
(
1
)
if
(
viewHolder
!=
null
&&
viewHolder
is
ConfideHomeAdapter
.
SearchViewHolder
)
{
viewHolder
.
itemView
.
findViewById
<
EditText
>(
R
.
id
.
etSearch
).
clearFocus
()
if
(
newState
==
1
){
searchView
!!
.
findViewById
<
EditText
>(
R
.
id
.
etSearch
).
setText
(
viewHolder
.
itemView
.
findViewById
<
EditText
>(
R
.
id
.
etSearch
).
text
)
}
}
}
override
fun
onScrolled
(
recyclerView
:
RecyclerView
,
dx
:
Int
,
dy
:
Int
)
{
...
...
@@ -49,26 +121,52 @@ class ConfideHomeRecyleSuspendListener : RecyclerView.OnScrollListener() {
return
}
val
manager
=
recyclerView
!!
.
layoutManager
as
LinearLayoutManager
val
findFirstCompletelyVisibleItemPosition
=
manager
.
findFirstCompletelyVisibleItemPosition
();
if
(
findFirstCompletelyVisibleItemPosition
!=
0
&&
findFirstCompletelyVisibleItemPosition
!=
1
)
{
searchView
?.
visibility
=
View
.
VISIBLE
}
else
{
searchView
?.
visibility
=
View
.
INVISIBLE
}
if
(
mCurrentPosition
!=
manager
.
findFirstVisibleItemPosition
())
{
mCurrentPosition
=
manager
.
findFirstVisibleItemPosition
()
}
LogUtil
.
e
(
"http----------------type="
+
adapter
!!
.
getItemViewType
(
mCurrentPosition
))
if
(
adapter
!!
.
getItemViewType
(
mCurrentPosition
)
==
IConfideHomeConfig
.
TYPE_RECOMMEND
)
{
LogUtil
.
e
(
"http----------------type="
+
adapter
!!
.
getItemViewType
(
mCurrentPosition
))
if
(
adapter
!!
.
getItemViewType
(
mCurrentPosition
+
1
)
==
IConfideHomeConfig
.
TYPE_RECOMMEND
)
{
var
view
=
manager
.
findViewByPosition
(
mCurrentPosition
+
1
)
if
(
view
!=
null
)
{
if
(
view
.
top
<=
mSuspensionHeight
)
{
filterView
!!
.
visibility
=
View
.
VISIBLE
divView
?.
visibility
=
View
.
VISIBLE
}
else
{
if
(
view
is
ConfideHomeFilterView
)
{
if
(
view
.
top
<=
mSuspensionHeight
)
{
filterView
!!
.
visibility
=
View
.
VISIBLE
divView
?.
visibility
=
View
.
VISIBLE
}
else
{
// filterView!!.visibility = View.INVISIBLE
filterView
!!
.
visibility
=
View
.
INVISIBLE
divView
?.
visibility
=
View
.
INVISIBLE
}
}
}
}
else
if
(
adapter
!!
.
getItemViewType
(
mCurrentPosition
)
==
IConfideHomeConfig
.
TYPE_RECOMMEND
||
adapter
!!
.
getItemViewType
(
mCurrentPosition
)
==
IConfideHomeConfig
.
TYPE_SOUND
){
}
else
if
(
adapter
!!
.
getItemViewType
(
mCurrentPosition
+
1
)
==
IConfideHomeConfig
.
TYPE_RECOMMEND
||
adapter
!!
.
getItemViewType
(
mCurrentPosition
+
1
)
==
IConfideHomeConfig
.
TYPE_SOUND
)
{
filterView
!!
.
visibility
=
View
.
VISIBLE
divView
?.
visibility
=
View
.
VISIBLE
}
else
{
}
else
{
filterView
!!
.
visibility
=
View
.
INVISIBLE
divView
?.
visibility
=
View
.
INVISIBLE
}
if
(
searchView
?.
visibility
!=
View
.
VISIBLE
){
val
viewHolder
=
recyclerView
.
findViewHolderForAdapterPosition
(
1
)
if
(
viewHolder
!=
null
&&
viewHolder
is
ConfideHomeAdapter
.
SearchViewHolder
)
{
viewHolder
.
itemView
.
findViewById
<
EditText
>(
R
.
id
.
etSearch
).
setText
(
searchText
)
}
}
}
}
\ No newline at end of file
m-confide/src/main/res/drawable-xxhdpi/confide_icon_input_search.png
0 → 100644
View file @
09db41a9
1.53 KB
m-confide/src/main/res/drawable/confide_bg_hot_search_input.xml
0 → 100644
View file @
09db41a9
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<corners
android:radius=
"40dp"
/>
<solid
android:color=
"#F7F7F7"
/>
<stroke
android:width=
"1px"
android:color=
"#E6E6E6"
/>
</shape>
\ No newline at end of file
m-confide/src/main/res/drawable/confide_edit_cursor_drawable.xml
0 → 100644
View file @
09db41a9
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<size
android:width=
"1dp"
/>
<span
style=
"font-family: Arial, Helvetica, sans-serif;"
/>
<solid
android:color=
"@color/platform_main_theme"
/>
</shape>
\ No newline at end of file
m-confide/src/main/res/layout/confide_home_activity.xml
View file @
09db41a9
...
...
@@ -16,7 +16,8 @@
<com.jcodecraeer.xrecyclerview.XRecyclerView
android:id=
"@+id/rv_list"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"match_parent"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/quick_consult_card"
...
...
@@ -137,11 +138,75 @@
android:background=
"#80000000"
android:visibility=
"gone"
/>
<RelativeLayout
android:id=
"@+id/rl_search_head"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/platform_dp_48"
android:background=
"@color/white"
android:visibility=
"gone"
tools:visibility=
"gone"
>
<View
android:id=
"@+id/view_search_input_bg"
android:layout_width=
"match_parent"
android:layout_height=
"32dp"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"@dimen/confide_dp_15"
android:layout_marginRight=
"@dimen/confide_dp_15"
android:background=
"@drawable/confide_bg_hot_search_input"
android:tag=
"tag_search_input_bg"
/>
<ImageView
android:id=
"@+id/iv_search_icon"
android:layout_width=
"14dp"
android:layout_height=
"14dp"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"@dimen/platform_dp_25"
android:layout_marginRight=
"10dp"
android:scaleType=
"centerCrop"
android:src=
"@drawable/confide_icon_input_search"
android:tag=
"tag_search_input_img"
/>
<EditText
android:id=
"@+id/etSearch"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"20dp"
android:layout_toLeftOf=
"@+id/iv_delete_icon"
android:layout_toRightOf=
"@id/iv_search_icon"
android:background=
"@null"
android:cursorVisible=
"true"
android:hint=
"请输入倾诉师姓名"
android:imeOptions=
"actionSearch"
android:maxLength=
"100"
android:singleLine=
"true"
android:tag=
"tag_search_input_edit"
android:textColor=
"#242424"
android:textColorHint=
"#b3b3b3"
android:textCursorDrawable=
"@drawable/confide_edit_cursor_drawable"
android:textSize=
"13sp"
/>
<ImageView
android:id=
"@+id/iv_delete_icon"
android:layout_width=
"14dp"
android:layout_height=
"14dp"
android:layout_alignRight=
"@+id/view_search_input_bg"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"12dp"
android:scaleType=
"centerCrop"
android:src=
"@drawable/platform_delete"
android:visibility=
"invisible"
/>
</RelativeLayout>
<com.ydl.confide.home.widget.ConfideHomeFilterView
android:id=
"@+id/v_filterView"
android:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:background=
"@color/white"
android:layout_below=
"@+id/rl_search_head"
android:visibility=
"gone"
tools:visibility=
"gone"
/>
...
...
m-confide/src/main/res/layout/confide_home_search_header.xml
0 → 100644
View file @
09db41a9
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/rl_search"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/platform_dp_48"
android:focusable=
"true"
android:focusableInTouchMode=
"true"
>
<View
android:id=
"@+id/view_search_input_bg"
android:layout_width=
"match_parent"
android:layout_height=
"32dp"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"@dimen/confide_dp_15"
android:layout_marginRight=
"@dimen/confide_dp_15"
android:background=
"@drawable/confide_bg_hot_search_input"
android:tag=
"tag_search_input_bg"
/>
<ImageView
android:id=
"@+id/iv_search_icon"
android:layout_width=
"14dp"
android:layout_height=
"14dp"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"@dimen/platform_dp_25"
android:layout_marginRight=
"10dp"
android:scaleType=
"centerCrop"
android:src=
"@drawable/confide_icon_input_search"
android:tag=
"tag_search_input_img"
/>
<EditText
android:id=
"@+id/etSearch"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"20dp"
android:layout_toLeftOf=
"@+id/iv_delete_icon"
android:layout_toRightOf=
"@id/iv_search_icon"
android:background=
"@null"
android:cursorVisible=
"true"
android:hint=
"请输入倾诉师姓名"
android:imeOptions=
"actionSearch"
android:maxLength=
"100"
android:singleLine=
"true"
android:tag=
"tag_search_input_edit"
android:textColor=
"#242424"
android:textColorHint=
"#b3b3b3"
android:textCursorDrawable=
"@drawable/confide_edit_cursor_drawable"
android:textSize=
"13sp"
/>
<ImageView
android:id=
"@+id/iv_delete_icon"
android:layout_width=
"14dp"
android:layout_height=
"14dp"
android:layout_alignRight=
"@+id/view_search_input_bg"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"12dp"
android:scaleType=
"centerCrop"
android:src=
"@drawable/platform_delete"
android:visibility=
"invisible"
/>
</RelativeLayout>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment