Commit b6d32c3b by fengquan

feat: 测评精品搜索页面调整

parent f26136ca
...@@ -3,12 +3,13 @@ package com.yidianling.tests.list.view ...@@ -3,12 +3,13 @@ package com.yidianling.tests.list.view
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import androidx.core.content.ContextCompat
import androidx.viewpager.widget.ViewPager
import android.view.View import android.view.View
import android.widget.PopupWindow import android.widget.PopupWindow
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.viewpager.widget.ViewPager
import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.facade.annotation.Route
import com.google.android.material.tabs.TabLayout
import com.ydl.ydlcommon.base.BaseMvpActivity import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.bean.StatusBarOptions import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.BuryPointUtils import com.ydl.ydlcommon.utils.BuryPointUtils
...@@ -32,7 +33,8 @@ import com.yidianling.tests.search.TestSearchActivity ...@@ -32,7 +33,8 @@ import com.yidianling.tests.search.TestSearchActivity
import kotlinx.android.synthetic.main.tests_activity_test_category_list.* import kotlinx.android.synthetic.main.tests_activity_test_category_list.*
@Route(path = "/ceshi/category_list") @Route(path = "/ceshi/category_list")
class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListActivityPresenter>(), TestListActivityView, PopupWindow.OnDismissListener { class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListActivityPresenter>(),
TestListActivityView, PopupWindow.OnDismissListener {
private var isMine: Boolean = false private var isMine: Boolean = false
private var tabName: String? = null private var tabName: String? = null
...@@ -51,12 +53,13 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA ...@@ -51,12 +53,13 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA
var selectedConditionList: HashMap<Int, HashMap<String, CategotyPopItem>> = HashMap() var selectedConditionList: HashMap<Int, HashMap<String, CategotyPopItem>> = HashMap()
var sortPopup: CategoryPopupWindow? = null; var sortPopup: CategoryPopupWindow? = null;
var filterPopup: CategoryPopupWindow? = null;
var currentPageIndex: Int = 0 var currentPageIndex: Int = 0
val SELECT_SORT: String = "SELECT_SORT" val SELECT_SORT: String = "SELECT_SORT"
val SELECT_FILTER: String = "SELECT_FILTER" val SELECT_FILTER: String = "SELECT_FILTER"
private var testCategoryAdapter: TestListPagerAdapter? = null private var testCategoryAdapter: TestListPagerAdapter? = null
var title = arrayOf("全部", "付费", "免费")
companion object { companion object {
private const val EXTRA_IS_MINE = "is_mine" private const val EXTRA_IS_MINE = "is_mine"
...@@ -116,15 +119,50 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA ...@@ -116,15 +119,50 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA
showSortPopupWindow() showSortPopupWindow()
} }
dr_filter.setOnClickListener { for (i in title) {
showFilterPopupWindow() val tab = tab_tabLayout.newTab().setText(i);
tab_tabLayout.addTab(tab)
}
tab_tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab?) {
when (tab?.text.toString()) {
"全部" -> {
selectFilterItem = filterList[0]
}
"付费" -> {
selectFilterItem = filterList[1]
}
"免费" -> {
selectFilterItem = filterList[2]
} }
}
onDismiss()
}
override fun onTabUnselected(tab: TabLayout.Tab?) {
}
override fun onTabReselected(tab: TabLayout.Tab?) {
}
})
mPresenter.fetchTestTypeList() mPresenter.fetchTestTypeList()
vvp_test.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { vvp_test.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {} override fun onPageScrollStateChanged(state: Int) {}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {} override fun onPageScrolled(
position: Int,
positionOffset: Float,
positionOffsetPixels: Int
) {
}
override fun onPageSelected(position: Int) { override fun onPageSelected(position: Int) {
currentPageIndex = position currentPageIndex = position
...@@ -136,8 +174,11 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA ...@@ -136,8 +174,11 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA
BuryPointUtils.getInstance().createMap() BuryPointUtils.getInstance().createMap()
.put("test_type_click", testCategory?.get(position)?.name + "") .put("test_type_click", testCategory?.get(position)?.name + "")
.burryPoint("Testtype_click") .burryPoint("Testtype_click")
if (("my" == testCategory?.get(position)?.tab || "unpay" == testCategory?.get(position)?.tab) ) { if (("my" == testCategory?.get(position)?.tab || "unpay" == testCategory?.get(
TestsIn.loginByOneKeyLogin(this@TestCategoryListActivity,true) position
)?.tab)
) {
TestsIn.loginByOneKeyLogin(this@TestCategoryListActivity, true)
} }
} }
}) })
...@@ -154,7 +195,8 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA ...@@ -154,7 +195,8 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA
filterList.add(CategotyPopItem("免费", "2")) filterList.add(CategotyPopItem("免费", "2"))
sortPopup = CategoryPopupWindow(this, sortPopup = CategoryPopupWindow(this,
sortList.toList() as ArrayList<CategotyPopItem>, object : CategoryConditionRecyclerViewAdapter.OnItemSelectedListener { sortList.toList() as ArrayList<CategotyPopItem>,
object : CategoryConditionRecyclerViewAdapter.OnItemSelectedListener {
override fun onSortItemSelected(sortItem: CategotyPopItem) { override fun onSortItemSelected(sortItem: CategotyPopItem) {
selectSortItem = sortItem selectSortItem = sortItem
if (selectSortItem.key == sortConditionDefaultKey) { if (selectSortItem.key == sortConditionDefaultKey) {
...@@ -166,21 +208,8 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA ...@@ -166,21 +208,8 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA
} }
}) })
filterPopup = CategoryPopupWindow(this,
filterList.toList() as ArrayList<CategotyPopItem>, object : CategoryConditionRecyclerViewAdapter.OnItemSelectedListener {
override fun onSortItemSelected(sortItem: CategotyPopItem) {
selectFilterItem = sortItem
if (selectFilterItem.key == filterConditionDefaultKey) {
updateFilterTextViewStatus(dr_filter, sortItem.value!!, true)
} else {
updateFilterTextViewStatus(dr_filter, sortItem.value!!, false)
}
filterPopup?.dismiss()
}
})
sortPopup?.setOnDismissListener(this) sortPopup?.setOnDismissListener(this)
filterPopup?.setOnDismissListener(this)
} }
override fun onDismiss() { override fun onDismiss() {
...@@ -200,24 +229,18 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA ...@@ -200,24 +229,18 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA
updateFilterTextViewStatus(dr_sort, selectSortItem.value!!, false) updateFilterTextViewStatus(dr_sort, selectSortItem.value!!, false)
} }
if (selectFilterItem.key == filterConditionDefaultKey) { updateTabLayoutStatus(tab_tabLayout, selectFilterItem.value!!)
updateFilterTextViewStatus(dr_filter, selectFilterItem.value!!, true)
} else { } else {
updateFilterTextViewStatus(dr_filter, selectFilterItem.value!!, false)
}
}else{
selectSortItem = CategotyPopItem("综合排序", sortConditionDefaultKey) selectSortItem = CategotyPopItem("综合排序", sortConditionDefaultKey)
selectFilterItem= CategotyPopItem("全部", filterConditionDefaultKey) selectFilterItem = CategotyPopItem("全部", filterConditionDefaultKey)
updateFilterTextViewStatus(dr_sort, selectSortItem.value!!, true) updateFilterTextViewStatus(dr_sort, selectSortItem.value!!, true)
updateFilterTextViewStatus(dr_filter, selectFilterItem.value!!, true) updateTabLayoutStatus(tab_tabLayout, selectFilterItem.value!!)
} }
sortPopup?.adapter?.lastSelectText = selectSortItem.value sortPopup?.adapter?.lastSelectText = selectSortItem.value
filterPopup?.adapter?.lastSelectText = selectFilterItem.value
sortPopup?.adapter?.notifyDataSetChanged() sortPopup?.adapter?.notifyDataSetChanged()
filterPopup?.adapter?.notifyDataSetChanged()
} }
private fun updateConditionList() { private fun updateConditionList() {
...@@ -229,11 +252,11 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA ...@@ -229,11 +252,11 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA
conditionList[SELECT_FILTER] = selectFilterItem conditionList[SELECT_FILTER] = selectFilterItem
selectedConditionList[currentPageIndex] = conditionList selectedConditionList[currentPageIndex] = conditionList
refreshFragmentPageData(selectSortItem.key!!,selectFilterItem.key!!) refreshFragmentPageData(selectSortItem.key!!, selectFilterItem.key!!)
} }
private fun refreshFragmentPageData(sort:String,filter:String) { private fun refreshFragmentPageData(sort: String, filter: String) {
testCategoryAdapter?.getFragmentByPosition(currentPageIndex)?.refreshListData(sort,filter) testCategoryAdapter?.getFragmentByPosition(currentPageIndex)?.refreshListData(sort, filter)
} }
...@@ -294,23 +317,38 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA ...@@ -294,23 +317,38 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA
view_mask.visibility = View.VISIBLE view_mask.visibility = View.VISIBLE
} }
//显示筛选弹窗
private fun showFilterPopupWindow() {
filterPopup?.showAsDropDown(ll_sort)
view_mask.visibility = View.VISIBLE
}
private fun updateFilterTextViewStatus(tv: TextView, text: String, isNormal: Boolean) { private fun updateFilterTextViewStatus(tv: TextView, text: String, isNormal: Boolean) {
tv.text = text tv.text = text
if (isNormal) { if (isNormal) {
tv.setTextColor(ContextCompat.getColor(this, R.color.platform_colorTextDefault)) tv.setTextColor(ContextCompat.getColor(this, R.color.platform_colorTextDefault))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.platform_ic_arrow_drop_down_grey_500_18dp, 0) tv.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
R.drawable.platform_ic_arrow_drop_down_grey_500_18dp,
0
)
} else { } else {
tv.setTextColor(ContextCompat.getColor(this, R.color.platform_main_theme)) tv.setTextColor(ContextCompat.getColor(this, R.color.platform_main_theme))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.tests_ic_arrow_drop_down, 0) tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.tests_ic_arrow_drop_down, 0)
} }
} }
private fun updateTabLayoutStatus(tabLayout: TabLayout, text: String) {
when (text) {
"全部" -> {
tabLayout.getTabAt(0)?.select()
}
"付费" -> {
tabLayout.getTabAt(1)?.select()
}
"免费" -> {
tabLayout.getTabAt(2)?.select()
}
}
}
override fun onFailed(msg: String?) { override fun onFailed(msg: String?) {
ToastUtil.toastShort(msg ?: "") ToastUtil.toastShort(msg ?: "")
} }
......
...@@ -117,8 +117,8 @@ class TestListRecyclerAdapter(private val context: Context, ...@@ -117,8 +117,8 @@ class TestListRecyclerAdapter(private val context: Context,
tvCoupon.visibility = View.GONE tvCoupon.visibility = View.GONE
textView.setPadding(dp5!!,dp2!!,dp5!!,dp2!!) textView.setPadding(dp5!!,dp2!!,dp5!!,dp2!!)
textView.text = "免费" textView.text = "免费"
textView.setBackgroundResource(R.drawable.tests_testhome_recom_price_bg) textView.setBackgroundResource(R.drawable.tests_testhome_recom_price_red_bg)
textView.setTextColor(Color.parseColor("#34CD65")) textView.setTextColor(Color.parseColor("#FF5B05"))
}else{ }else{
var newPrice = TestHomeUtils.getOriginalPrice(tvCoupon,price,couponMoney) var newPrice = TestHomeUtils.getOriginalPrice(tvCoupon,price,couponMoney)
textView.setPadding(0,dp5!!,dp5!!,0) textView.setPadding(0,dp5!!,dp5!!,0)
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:radius="3dp"/>
<solid
android:color="#1AFF5B05"/>
</shape>
\ No newline at end of file
...@@ -87,6 +87,15 @@ ...@@ -87,6 +87,15 @@
android:orientation="horizontal" android:orientation="horizontal"
> >
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_tabLayout"
android:layout_width="0dp"
android:layout_height="44dp"
app:tabIndicatorColor="@color/blue"
app:tabIndicatorHeight="3dp"
app:tabIndicatorFullWidth="false"
android:layout_weight="1"/>
<com.ydl.ydlcommon.view.DrawableRightTextView <com.ydl.ydlcommon.view.DrawableRightTextView
android:id="@+id/dr_sort" android:id="@+id/dr_sort"
style="@style/tests_FilterTextViewStyle" style="@style/tests_FilterTextViewStyle"
...@@ -99,17 +108,6 @@ ...@@ -99,17 +108,6 @@
android:textColor="@color/platform_color_242424" android:textColor="@color/platform_color_242424"
/> />
<com.ydl.ydlcommon.view.DrawableRightTextView
android:id="@+id/dr_filter"
style="@style/tests_FilterTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="44dp"
android:drawableEnd="@drawable/platform_ic_arrow_drop_down_grey_500_18dp"
android:drawableRight="@drawable/platform_ic_arrow_drop_down_grey_500_18dp"
android:paddingLeft="15dp"
android:text="全部"
android:textColor="@color/platform_color_242424"
/>
</LinearLayout> </LinearLayout>
<RelativeLayout <RelativeLayout
......
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