Commit 8c41ac44 by fengquan

feat: 倾诉列表添加搜索框 & 接口调试

parent 09db41a9
......@@ -9,5 +9,7 @@
<activity
android:name=".intro.ExpertIntroActivity"
android:screenOrientation="portrait" />
<activity android:name=".home.ConfideSearchActivity"
android:screenOrientation="portrait"/>
</application>
</manifest>
......@@ -2,12 +2,15 @@ package com.ydl.confide.home
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Build
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.TextView
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SimpleItemAnimator
......@@ -24,6 +27,8 @@ import com.ydl.confide.home.bean.ConfideHomeBodyBean
import com.ydl.confide.home.bean.ConfideHomeDataBean
import com.ydl.confide.home.bean.ConfideHomeFiterItemBean
import com.ydl.confide.home.config.IConfideHomeConfig
import com.ydl.confide.home.constants.FinalString
import com.ydl.confide.home.constants.FinalString.SEARCH_REQUEST_CODE
import com.ydl.confide.home.contract.IConfideHomeContract
import com.ydl.confide.home.event.ConfideHomeEventImpl
import com.ydl.confide.home.event.IConfideHomeEvent
......@@ -120,6 +125,9 @@ class ConfideHomeActivity :
private var dp48 = 0
private var bottomSheetDialogFragment: ConfideBottomSheetDialogFragment? = null
private var keyword : String = "";
init {
//初始化参数
initParam()
......@@ -129,6 +137,7 @@ class ConfideHomeActivity :
private fun initParam() {
allFiltersBean = ConfideHomeAllFiltersBean(
page,
"",
ConfideHomeFiterItemBean().apply {
id = "-1"
name = ""
......@@ -177,6 +186,7 @@ class ConfideHomeActivity :
//需要将当前列表已存在的老师uid数组发送到后端去重,因为排序实时变化
this.page = page
allFiltersBean!!.page = page
allFiltersBean!!.keywords = keyword
if (1 == page) {
//显示加载中
showProgressDialog()
......@@ -337,8 +347,15 @@ class ConfideHomeActivity :
"0",
true
)
}
rl_search_head.setOnClickListener {
var intent = Intent(this, ConfideSearchActivity::class.java)
if (!TextUtils.isEmpty(keyword)){
intent.putExtra(FinalString.CONFIDE_SEARCH_KEY_WORD,keyword)
}
startActivityForResult(intent,SEARCH_REQUEST_CODE)
}
}
......@@ -410,7 +427,7 @@ class ConfideHomeActivity :
initParam()
hideError()
cacheList?.addAll(0, list)
cacheList?.add(0, ConfideHomeDataBean(IConfideHomeConfig.TYPE_SEARCH,null,null,null, -1))
cacheList?.add(0, ConfideHomeDataBean(IConfideHomeConfig.TYPE_SEARCH,null,null,null, -1,keyword))
updateAdapter()
setSuspendListener()
v_filterView.refreshView()
......@@ -429,6 +446,18 @@ class ConfideHomeActivity :
v_filterView.setHomeView(this)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == SEARCH_REQUEST_CODE && resultCode == RESULT_OK) {
val keyWord = data?.getStringExtra(FinalString.CONFIDE_SEARCH_KEY_WORD)
if (keyWord != null){
keyword = keyWord
rl_search_head.findViewById<TextView>(R.id.etSearch).setText(keyword)
onRefresh()
}
}
}
/**
* 更新适配器数据
*/
......
package com.ydl.confide.home
import android.content.Context
import android.content.Intent
import android.text.Editable
import android.text.TextUtils
import android.text.TextWatcher
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.TextView
import com.ydl.confide.R
import com.ydl.confide.home.constants.FinalString
import com.ydl.ydlcommon.base.BaseActivity
import kotlinx.android.synthetic.main.confide_search_activity.*
class ConfideSearchActivity : BaseActivity() {
override fun initDataAndEvent() {
val keyWord = intent.getStringExtra(FinalString.CONFIDE_SEARCH_KEY_WORD)
if (!TextUtils.isEmpty(keyWord)){
etSearch?.setText(keyWord)
iv_delete_icon.visibility = View.VISIBLE
}
etSearch.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
val keyword = etSearch!!.text.trim().toString()
val intent = Intent()
intent.putExtra(FinalString.CONFIDE_SEARCH_KEY_WORD, keyword)
setResult(RESULT_OK,intent)
finish()
}
true
}
findViewById<TextView>(R.id.tv_search_cancle).setOnClickListener {
setResult(RESULT_OK)
finish()
}
if (etSearch.requestFocus()) {
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
val isShowing = imm.showSoftInput(etSearch, InputMethodManager.SHOW_IMPLICIT)
if (!isShowing) {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
}
}
etSearch.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
if (TextUtils.isEmpty(s)) {
iv_delete_icon.visibility = View.INVISIBLE
} else {
iv_delete_icon.visibility = View.VISIBLE
}
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
})
iv_delete_icon.setOnClickListener {
etSearch.setText("")
}
}
override fun layoutResId(): Int {
return R.layout.confide_search_activity
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.ydl.confide.home.adapter
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.text.Editable
import android.text.TextUtils
import android.text.TextWatcher
......@@ -15,14 +16,19 @@ import android.widget.ImageView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.ydl.confide.R
import com.ydl.confide.home.ConfideHomeActivity
import com.ydl.confide.home.ConfideSearchActivity
import com.ydl.confide.home.bean.ConfideHomeDataBean
import com.ydl.confide.home.config.IConfideHomeConfig
import com.ydl.confide.home.constants.FinalString
import com.ydl.confide.home.constants.FinalString.SEARCH_REQUEST_CODE
import com.ydl.confide.home.contract.IConfideHomeContract
import com.ydl.confide.home.event.IConfideHomeEvent
import com.ydl.confide.home.widget.*
import com.ydl.ydlcommon.utils.DisplayUtils
import com.ydl.ydlcommon.utils.KeyboardChangeListener
import com.yidianling.common.tools.RxKeyboardTool
import kotlinx.android.synthetic.main.confide_home_activity.view.*
/**
* @author yuanwai
......@@ -187,43 +193,17 @@ class ConfideHomeAdapter(
val recentBody = mListData!![position].body
holder.rv.adapter = VideoShowAdapter(recentBody, confideHomeEvent)
} else if (holder is SearchViewHolder) {
holder.searchView.findViewById<EditText>(R.id.etSearch)
.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Log.e("fqLog", "点击了");
RxKeyboardTool.hideSoftInput(mContext as Activity?)
holder.searchView.etSearch.setText(mListData!![position].keyword)
holder.searchView.setOnClickListener {
var intent = Intent(mContext, ConfideSearchActivity::class.java)
if (!TextUtils.isEmpty(mListData!![position].keyword)){
intent.putExtra(FinalString.CONFIDE_SEARCH_KEY_WORD,mListData!![position].keyword)
}
true
if (mContext is ConfideHomeActivity){
val confideHomeActivity = mContext as ConfideHomeActivity
confideHomeActivity.startActivityForResult(intent,SEARCH_REQUEST_CODE)
}
val keyboardChangeListener = KeyboardChangeListener(mContext as Activity?)
keyboardChangeListener.setKeyBoardListener { isShow, i ->
if (!isShow){
holder.searchView.findViewById<EditText>(R.id.etSearch).clearFocus()
}
}
holder.searchView.findViewById<EditText>(R.id.etSearch).addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(p0: Editable?) {
if (TextUtils.isEmpty(p0)) {
holder.searchView.findViewById<ImageView>(R.id.iv_delete_icon).visibility = View.INVISIBLE
} else {
holder.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) {
}
})
holder.searchView.findViewById<ImageView>(R.id.iv_delete_icon).setOnClickListener {
holder.searchView.findViewById<EditText>(R.id.etSearch).setText("")
}
} else if (holder is EmptyViewHolder) {
} else {
......
......@@ -9,6 +9,8 @@ package com.ydl.confide.home.bean
*/
data class ConfideHomeAllFiltersBean(
var page : Int,
//通过倾诉师的名字搜索
var keywords : String,
//选择的综合排序Id
var selectSort : ConfideHomeFiterItemBean?,
//选择的性别id
......@@ -19,4 +21,6 @@ data class ConfideHomeAllFiltersBean(
val selectGoodData : ArrayList<ConfideHomeFiterItemBean>?,
//当前列表已存在专家uid列表
var notInUid : ArrayList<Int> = ArrayList()
)
\ No newline at end of file
......@@ -30,4 +30,6 @@ data class ConfideHomeDataBean(
/**
* 为你推荐Id 本地使用 用于区分音频播放区域
*/
var recommendId : Int)
\ No newline at end of file
var recommendId : Int,
var keyword : String = "")
\ No newline at end of file
......@@ -19,4 +19,9 @@ public class FinalString {
//连接倾听未绑定手机提示
public static final String TEL_BINDPHONE = "电话连接需要绑定手机哦~";
public static final String CONFIDE_SEARCH_KEY_WORD = "confide_key_word";
public static final int SEARCH_REQUEST_CODE = 1;
}
......@@ -51,6 +51,7 @@ class ConfideHomeHttpImpl private constructor() : IConfideHomeHttp {
val sb = StringBuffer()
sb.append("page").append("=").append(param.page).append("&")
.append("keywords").append("=").append(param.getKeywords()).append("&")
.append("sortType").append("=").append(param.getSortType()).append("&")
.append("sexType").append("=").append(param.getSexType()).append("&")
.append("ageType").append("=").append(param.getAgeType()).append("&")
......
......@@ -30,6 +30,8 @@ class ConfideRecommendParam private constructor(builder: Builder){
*/
private var goodType : String = ""
private var keyWords : String = ""
//当前列表已存在专家uid列表
var notInUid : ArrayList<Int> = ArrayList()
......@@ -49,6 +51,10 @@ class ConfideRecommendParam private constructor(builder: Builder){
return goodType
}
fun getKeywords() : String{
return keyWords
}
init {
this.page = builder.page
this.sortType = builder.sortType
......@@ -56,6 +62,7 @@ class ConfideRecommendParam private constructor(builder: Builder){
this.ageType = builder.ageType
this.goodType = builder.goodType
this.notInUid = builder.notInUid
this.keyWords = builder.keyWords
}
class Builder {
......@@ -65,6 +72,7 @@ class ConfideRecommendParam private constructor(builder: Builder){
internal var ageType : String = ""
internal var goodType : String = ""
internal var notInUid : ArrayList<Int> = ArrayList()
internal var keyWords : String = ""
fun page(page: Int): Builder {
this.page = page
......@@ -91,9 +99,17 @@ class ConfideRecommendParam private constructor(builder: Builder){
return this
}
fun keyWords(keyWords: String): Builder {
this.keyWords = keyWords
return this
}
fun build() : ConfideRecommendParam{
return ConfideRecommendParam(this)
}
}
}
......
......@@ -54,7 +54,7 @@ class ConfideHomeRecycleViewListener : RecyclerView.OnScrollListener() {
mRecyclerView.scrollBy(0, 1)
val childAt = mRecyclerView.getChildAt(mIndex)
if (childAt !is ConfideHomeFilterView) return
val top = childAt.top
val top = childAt.top - childAt.height
if(top==0 || top==1){
//已滚动到顶部
......
......@@ -56,38 +56,6 @@ class ConfideHomeRecyleSuspendListener : RecyclerView.OnScrollListener() {
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) {
......@@ -104,15 +72,6 @@ class ConfideHomeRecyleSuspendListener : RecyclerView.OnScrollListener() {
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) {
......@@ -160,13 +119,5 @@ class ConfideHomeRecyleSuspendListener : RecyclerView.OnScrollListener() {
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
......@@ -54,7 +54,7 @@ class ConfideHomeSexAgePopupWindow(context: Context, sexData: ArrayList<ConfideH
tvSexTitle.text = "性别筛选"
tvAgeTitle.text = "年龄筛选"
if (null == mAllFiltersBean){
mAllFiltersBean = ConfideHomeAllFiltersBean(allFiltersBean.page,allFiltersBean.selectSort,allFiltersBean.selectSex,allFiltersBean.selectAgeData,allFiltersBean.selectGoodData)
mAllFiltersBean = ConfideHomeAllFiltersBean(allFiltersBean.page,"",allFiltersBean.selectSort,allFiltersBean.selectSex,allFiltersBean.selectAgeData,allFiltersBean.selectGoodData)
}
initData(sexData,ageData,mAllFiltersBean!!)
initSexData(view,mAllFiltersBean!!)
......
......@@ -490,6 +490,10 @@ class ConfideHomeUtils {
if (-1 != allFiltersBean.page) {
param.page(allFiltersBean.page)
}
if (null != allFiltersBean.keywords){
param.keyWords(allFiltersBean.keywords)
}
//综合排序
if (null != allFiltersBean.selectSort && !TextUtils.isEmpty(allFiltersBean.selectSort!!.id) && "-1" != allFiltersBean.selectSort!!.id) {
param.sortType(allFiltersBean.selectSort!!.id!!)
......
......@@ -167,7 +167,7 @@
android:src="@drawable/confide_icon_input_search"
android:tag="tag_search_input_img" />
<EditText
<TextView
android:id="@+id/etSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
......@@ -4,8 +4,7 @@
android:id="@+id/rl_search"
android:layout_width="match_parent"
android:layout_height="@dimen/platform_dp_48"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="blocksDescendants"
>
<View
......@@ -29,7 +28,7 @@
android:src="@drawable/confide_icon_input_search"
android:tag="tag_search_input_img" />
<EditText
<TextView
android:id="@+id/etSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rl_search"
android:layout_width="match_parent"
android:layout_height="@dimen/platform_dp_48"
android:paddingStart="15dp"
android:tag="tag_search_input"
>
<View
android:id="@+id/view_search_input_bg"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_centerVertical="true"
android:layout_marginRight="60dp"
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="15dp"
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:focusable="true"
android:focusableInTouchMode="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" />
<TextView
android:id="@+id/tv_search_cancle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:padding="5dp"
android:text="取消"
android:textColor="#242424"
android:textSize="15dp" />
</RelativeLayout>
<View
android:id="@+id/v_topLine"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="@+id/rl_search"
android:layout_marginTop="@dimen/platform_dp_6"
android:background="@color/platform_color_E0E0E0"
/>
</LinearLayout>
\ No newline at end of file
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