Skip to content

Commit

Permalink
修复搜索页问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ncguobiao committed Jun 12, 2018
1 parent 18681c9 commit 805084a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
isBuildModule=false
isBuildModule=true
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ package com.example.search.ui.activity
import android.annotation.TargetApi
import android.graphics.Typeface
import android.os.Build
import android.support.annotation.RequiresApi
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.transition.Fade
import android.transition.Transition
import android.transition.TransitionInflater
import android.view.KeyEvent
import android.view.View
import android.view.animation.AnimationUtils
import android.view.inputmethod.EditorInfo
import android.widget.TextView
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.baselibrary.base.BaseMvpActivity
import com.example.baselibrary.base.closeKeyBord
Expand Down Expand Up @@ -47,7 +46,7 @@ class SearchActivity : BaseMvpActivity<SearchPresenter>(), SearchContract.View {
private var loadingMore = false

private var itemList = ArrayList<HomeBean.Issue.Item>()

private lateinit var mHotKeywordsAdapter: HotKeywordsAdapter
private val mResultAdapter by lazy {
CategoryDetailAdapter(this, itemList, R.layout.item_category_detail)
}
Expand All @@ -58,6 +57,8 @@ class SearchActivity : BaseMvpActivity<SearchPresenter>(), SearchContract.View {

private var keyWords: String?=null

@TargetApi(Build.VERSION_CODES.CUPCAKE)
@RequiresApi(Build.VERSION_CODES.CUPCAKE)
override fun initView() {
mPresenter.attachView(this)

Expand All @@ -84,22 +85,20 @@ class SearchActivity : BaseMvpActivity<SearchPresenter>(), SearchContract.View {
//取消
tv_cancel.setOnClickListener {
onBackPressed() }

//键盘的搜索按钮
et_search_view.setOnEditorActionListener(object : TextView.OnEditorActionListener {
override fun onEditorAction(v: TextView?, actionId: Int, event: KeyEvent?): Boolean {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
closeSoftKeyboard()
keyWords = et_search_view.text.toString().trim()
if (keyWords.isNullOrEmpty()) {
showToast("请输入你感兴趣的关键词")
} else {
mPresenter.querySearchData(keyWords!!)
}
et_search_view.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
closeSoftKeyboard()
keyWords = et_search_view.text.toString().trim()
if (keyWords.isNullOrEmpty()) {
showToast("请输入你感兴趣的关键词")
} else {
mPresenter.querySearchData(keyWords!!)
}
return false
}

})
false
}

mLayoutStatusView = multipleStatusView

Expand All @@ -108,7 +107,7 @@ class SearchActivity : BaseMvpActivity<SearchPresenter>(), SearchContract.View {
StatusBarUtil.setPaddingSmart(this, toolbar)
}

private lateinit var mHotKeywordsAdapter: HotKeywordsAdapter



/**
Expand Down Expand Up @@ -142,6 +141,12 @@ class SearchActivity : BaseMvpActivity<SearchPresenter>(), SearchContract.View {
override fun setSearchResult(issue: HomeBean.Issue) {
loadingMore = false
hideHotWordView()

tv_search_count.visibility = View.VISIBLE
tv_search_count.text = String.format(resources.getString(R.string.search_result_count), keyWords, issue.total)

itemList = issue.itemList
mResultAdapter.addData(issue.itemList)
}

override fun closeSoftKeyboard() {
Expand Down Expand Up @@ -295,7 +300,7 @@ class SearchActivity : BaseMvpActivity<SearchPresenter>(), SearchContract.View {
}

override fun onRevealShow() {

setUpView()
}
})
} else {
Expand All @@ -312,7 +317,6 @@ class SearchActivity : BaseMvpActivity<SearchPresenter>(), SearchContract.View {
override fun onDestroy() {
CleanLeakUtils.fixInputMethodManagerLeak(this)
super.onDestroy()
mPresenter.detachView()
mTextTypeface = null

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CategoryDetailAdapter(context: Context,dataList:ArrayList<HomeBean.Issue.I
holder.setText(R.id.tv_tag, "#${itemData?.category}/$timeFormat")

holder.setOnItemClickListener(listener = View.OnClickListener {
goToVideoPlayer(mContext as Activity, holder.getView(R.id.iv_image), item)
goToVideoPlayer(context as Activity, holder.getView(R.id.iv_image), item)
})
}

Expand All @@ -76,7 +76,7 @@ class CategoryDetailAdapter(context: Context,dataList:ArrayList<HomeBean.Issue.I
.withObject(Constants.BUNDLE_VIDEO_DATA, itemData)
.withBoolean(Constants.Companion.TRANSITION, true)//sdk大于等于16的动画方法:
.withOptionsCompat(activityOptions)
.navigation()
.navigation(activity)
} else {
ARouter.getInstance().build(RouterPath.Video.PATH_VIDEO)
.withObject(Constants.BUNDLE_VIDEO_DATA, itemData)
Expand Down

0 comments on commit 805084a

Please sign in to comment.