From 805084af6a1f301205cb3e008c4c3c11b8888372 Mon Sep 17 00:00:00 2001 From: guobiao <568164681@qq.com> Date: Tue, 12 Jun 2018 09:17:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=90=9C=E7=B4=A2=E9=A1=B5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../search/ui/activity/SearchActivity.kt | 42 ++++++++++--------- .../ui/adapter/CategoryDetailAdapter.kt | 4 +- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1877b3a..fd6546b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/search/src/main/java/com/example/search/ui/activity/SearchActivity.kt b/search/src/main/java/com/example/search/ui/activity/SearchActivity.kt index d7bf13f..e6dea0f 100644 --- a/search/src/main/java/com/example/search/ui/activity/SearchActivity.kt +++ b/search/src/main/java/com/example/search/ui/activity/SearchActivity.kt @@ -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 @@ -47,7 +46,7 @@ class SearchActivity : BaseMvpActivity(), SearchContract.View { private var loadingMore = false private var itemList = ArrayList() - + private lateinit var mHotKeywordsAdapter: HotKeywordsAdapter private val mResultAdapter by lazy { CategoryDetailAdapter(this, itemList, R.layout.item_category_detail) } @@ -58,6 +57,8 @@ class SearchActivity : BaseMvpActivity(), SearchContract.View { private var keyWords: String?=null + @TargetApi(Build.VERSION_CODES.CUPCAKE) + @RequiresApi(Build.VERSION_CODES.CUPCAKE) override fun initView() { mPresenter.attachView(this) @@ -84,22 +85,20 @@ class SearchActivity : BaseMvpActivity(), 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 @@ -108,7 +107,7 @@ class SearchActivity : BaseMvpActivity(), SearchContract.View { StatusBarUtil.setPaddingSmart(this, toolbar) } - private lateinit var mHotKeywordsAdapter: HotKeywordsAdapter + /** @@ -142,6 +141,12 @@ class SearchActivity : BaseMvpActivity(), 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() { @@ -295,7 +300,7 @@ class SearchActivity : BaseMvpActivity(), SearchContract.View { } override fun onRevealShow() { - + setUpView() } }) } else { @@ -312,7 +317,6 @@ class SearchActivity : BaseMvpActivity(), SearchContract.View { override fun onDestroy() { CleanLeakUtils.fixInputMethodManagerLeak(this) super.onDestroy() - mPresenter.detachView() mTextTypeface = null } diff --git a/search/src/main/java/com/example/search/ui/adapter/CategoryDetailAdapter.kt b/search/src/main/java/com/example/search/ui/adapter/CategoryDetailAdapter.kt index a63dc28..a551c18 100644 --- a/search/src/main/java/com/example/search/ui/adapter/CategoryDetailAdapter.kt +++ b/search/src/main/java/com/example/search/ui/adapter/CategoryDetailAdapter.kt @@ -49,7 +49,7 @@ class CategoryDetailAdapter(context: Context,dataList:ArrayList