Commit bac8c9fe authored by maxiaoliang's avatar maxiaoliang

11

parent 0b399b85
...@@ -21,7 +21,7 @@ public class NetConfig { ...@@ -21,7 +21,7 @@ public class NetConfig {
} }
// 根据调试选项更新环境 // 根据调试选项更新环境
public static Environment sEnvironment = DEV;// 当前环境 public static Environment sEnvironment = PRODUCT;// 当前环境
public static String BASE_WEB_URL = ""; public static String BASE_WEB_URL = "";
public static String BASE_URL = ""; public static String BASE_URL = "";
public static String BASE_NEW_URL = ""; public static String BASE_NEW_URL = "";
......
...@@ -290,4 +290,9 @@ interface RounterApi { ...@@ -290,4 +290,9 @@ interface RounterApi {
@RounterUri(Constant.scheme + "://search") @RounterUri(Constant.scheme + "://search")
fun getIntentSearch(): Intent fun getIntentSearch(): Intent
@RounterUri(Constant.scheme + "://searchresult")
fun getIntentSearchReslut(
@RounterParam("keyword") keyword: String
): Intent
} }
\ No newline at end of file
...@@ -510,4 +510,14 @@ public class JumpUtils { ...@@ -510,4 +510,14 @@ public class JumpUtils {
Utils.showToast(AppContext.get(), "该版本暂不支持,请更新版本!"); Utils.showToast(AppContext.get(), "该版本暂不支持,请更新版本!");
} }
} }
public static void SearchReslutJumo(String keyword) {
try {
Intent intent = RounterBus.getRounter(RounterApi.class).getIntentSearchReslut(keyword);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
AppContext.get().startActivity(intent);
} catch (Exception e) {
Utils.showToast(AppContext.get(), "该版本暂不支持,请更新版本!");
}
}
} }
...@@ -344,6 +344,19 @@ ...@@ -344,6 +344,19 @@
android:scheme="xxsqshop" /> android:scheme="xxsqshop" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name=".activity.SearchResultActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="searchresult"
android:scheme="xxsqshop" />
</intent-filter>
</activity>
<activity <activity
......
...@@ -54,6 +54,7 @@ class SearchActivity : BaseActivity(), SearchContract.View, ...@@ -54,6 +54,7 @@ class SearchActivity : BaseActivity(), SearchContract.View,
SPUtils.getInstance(this).saveHistory(searchValue) SPUtils.getInstance(this).saveHistory(searchValue)
// showToast(searchValue) // showToast(searchValue)
// JumpUtils.SearchReslutJumo(searchValue, "0", "") // JumpUtils.SearchReslutJumo(searchValue, "0", "")
JumpUtils.SearchReslutJumo(searchValue)
} }
} }
} }
......
package com.zxbw.modulemain.activity
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.zxbw.modulemain.R
import com.zxbw.modulemain.adapter.SearchReslutAdapter
import com.zxbw.modulemain.contract.SearchReslutContract
import com.zxbw.modulemain.presenter.SearchResultPresenter
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.model.qy.TbGoodsEntity
import com.zxhl.cms.net.model.qy.TbGoodsItemEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener
import com.zxhl.cms.utils.RecyclerViewScrollListener
import kotlinx.android.synthetic.main.activity_layout_search_reslut.*
import kotlinx.android.synthetic.main.layout_search_reslut_empty_view.*
class SearchResultActivity : BaseActivity(), SearchReslutContract.View,
OnRecycleItemClickListener<TbGoodsItemEntity> {
private var mPresenter: SearchResultPresenter? = null
private var mAdapter: SearchReslutAdapter? = null
private var keyword: String? = ""
override fun onClick(v: View?) {
}
override fun before() {
super.before()
setStatusBarBackground(AppContext.get().resources.getColor(R.color.transparent))
}
override fun layoutID(): Int {
return R.layout.activity_layout_search_reslut
}
override fun init() {
keyword = intent?.data?.getQueryParameter("keyword") ?: ""
id_edit_search?.setText(keyword)
id_img_back?.setOnClickListener {
finish()
}
mPresenter = SearchResultPresenter(this)
mAdapter = SearchReslutAdapter(this, this)
id_rl_seach_reslut?.layoutManager = LinearLayoutManager(this)
id_rl_seach_reslut?.adapter = mAdapter
id_rl_seach_reslut?.addOnScrollListener(object : RecyclerViewScrollListener() {
override fun onScrollToBottom() {
super.onScrollToBottom()
if ((mAdapter?.list?.size ?: 0) > 0) {
mPresenter?.getShopSearchList(false, keyword)
}
}
})
id_refresh_layout?.setOnRefreshListener {
mPresenter?.getShopSearchList(true, keyword)
}
getSearchData()
id_edit_search?.setOnFocusChangeListener(object : View.OnFocusChangeListener {
override fun onFocusChange(v: View?, hasFocus: Boolean) {
if (hasFocus) {
}
}
})
id_edit_search?.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
keyword = s.toString().trim()
getSearchData()
}
override fun afterTextChanged(s: Editable?) {
}
})
}
override fun setData(isRefresh: Boolean, result: TbGoodsEntity?) {
id_ll_empty?.visibility = View.GONE
if (isRefresh) {
mAdapter?.clear()
}
id_refresh_layout?.isRefreshing = false
val start = mAdapter?.getItemCount() ?: 0
mAdapter?.appendToList(result?.result_list)
if (isRefresh) {
mAdapter?.notifyDataSetChanged()
} else {
val end = mAdapter?.getItemCount() ?: 0
mAdapter?.notifyItemRangeChanged(start, end)
}
}
override fun setEmptyView() {
mAdapter?.clear()
id_ll_empty?.visibility = View.VISIBLE
}
fun getSearchData() {
mPresenter?.getShopSearchList(true, keyword)
}
override fun onItemClick(view: View?, position: Int, data: TbGoodsItemEntity?) {
}
}
\ No newline at end of file
package com.zxbw.modulemain.adapter
import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.zxbw.modulemain.R
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseRecyclerAdapter
import com.zxhl.cms.net.model.qy.TbGoodsItemEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener
import com.zxhl.cms.utils.Utils
import com.zxhl.cms.widget.RecycleImageView
class SearchReslutAdapter : BaseRecyclerAdapter<TbGoodsItemEntity, SearchReslutAdapter.ViewHolder> {
private var mContext: Activity? = null
private val listener: OnRecycleItemClickListener<TbGoodsItemEntity>
constructor(
content: Activity?,
listener: OnRecycleItemClickListener<TbGoodsItemEntity>
) : super() {
this.listener = listener
mContext = content
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
var bean = mList[position]
holder.id_tv_goods_name?.text = bean.title
if (mContext?.isFinishing == false) {
if (bean.pict_url?.startsWith("//img") == true) {
holder.id_item_goods_img?.setLoadImageUrl("https:" + bean.pict_url, 0, 5)
} else {
holder.id_item_goods_img?.setLoadImageUrl(bean.pict_url, 0, 5)
}
}
holder.id_tv_tb_price_value?.text = "淘宝商城价 : ¥${bean.zk_final_price}"
if (bean.coupon_amount.isNullOrEmpty()) {
holder.id_tv_yhq_value?.visibility = View.GONE
holder.id_tv_goods_price?.text = "${bean.zk_final_price}"
} else {
holder.id_tv_yhq_value?.visibility = View.VISIBLE
holder.id_tv_yhq_value?.text = "${bean.coupon_amount}元券"
var z_price = bean.zk_final_price?.toDoubleOrNull() ?: 0 as Double
var c_price = bean.coupon_amount?.toDoubleOrNull() ?: 0 as Double
holder.id_tv_goods_price?.text = Utils.getNoMoreThanTwoDigits(
Utils.sub(
z_price,
c_price
)
)
}
if (bean.coupon_info.isNullOrEmpty()) {
holder.id_tv_manjian_value?.visibility = View.GONE
} else {
holder.id_tv_manjian_value?.visibility = View.VISIBLE
holder.id_tv_manjian_value?.text = "${bean.coupon_info}"
}
holder.id_rl_goods_item_view?.setOnClickListener {
listener.onItemClick(it, position, bean)
}
}
// override fun getItemCount(): Int {
// return 10
// }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(
LayoutInflater.from(AppContext.get())
.inflate(R.layout.item_layout_goods_view, parent, false)
)
}
class ViewHolder : RecyclerView.ViewHolder {
var id_rl_goods_item_view: RelativeLayout?
var id_item_goods_img: RecycleImageView?
var id_tv_goods_name: TextView?
var id_tv_yhq_value: TextView?
var id_tv_manjian_value: TextView?
var id_tv_tb_price_value: TextView?
var id_tv_goods_price: TextView?
constructor(
itemView: View
) : super(itemView) {
id_rl_goods_item_view =
itemView.findViewById<RelativeLayout>(R.id.id_rl_goods_item_view)
id_item_goods_img = itemView.findViewById<RecycleImageView>(R.id.id_item_goods_img)
id_tv_goods_name = itemView.findViewById<TextView>(R.id.id_tv_goods_name)
id_tv_yhq_value = itemView.findViewById<TextView>(R.id.id_tv_yhq_value)
id_tv_manjian_value = itemView.findViewById<TextView>(R.id.id_tv_manjian_value)
id_tv_tb_price_value = itemView.findViewById<TextView>(R.id.id_tv_tb_price_value)
id_tv_goods_price = itemView.findViewById<TextView>(R.id.id_tv_goods_price)
}
}
}
\ No newline at end of file
package com.zxbw.modulemain.contract
import com.zxhl.cms.net.model.qy.TbGoodsEntity
class SearchReslutContract {
interface View {
fun setData(boolean: Boolean,result: TbGoodsEntity?)
fun setEmptyView()
}
interface Presenter {
fun getShopSearchList(isRefresh: Boolean,keyword: String?)
}
}
\ No newline at end of file
package com.zxbw.modulemain.presenter
import android.util.Log
import com.zxbw.modulemain.contract.SearchReslutContract
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.qy.TbGoodsEntity
import com.zxhl.cms.net.model.shop.ShopListEntity
class SearchResultPresenter : SearchReslutContract.Presenter {
private val mView: SearchReslutContract.View
constructor(mView: SearchReslutContract.View) {
this.mView = mView
}
private var page = 1
private val size = 20
private var isMore = false
override fun getShopSearchList(isRefresh: Boolean, keyword: String?) {
if (isRefresh) {
page = 1
isMore = false
} else if (isMore) {
return
}
isMore = true
ApiClient.homeApi.getGoodsListSearch("", keyword.toString(), page, size)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<TbGoodsEntity>() {
override fun onSuccess(result: TbGoodsEntity?) {
// mView?.setData(result)
if (result != null) {
if (result.result_list.isNullOrEmpty()) {
if (page == 1) {
mView.setEmptyView()
}
} else {
if (result.result_list!!.size <= size) {
page++
isMore = false
} else {
isMore = true
}
mView.setData(isRefresh, result)
}
} else {
mView.setEmptyView()
}
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
// mView.setTbGoodsList(isRefresh, null)
}
})
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#ff9a6bf8" />
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
</shape>
\ No newline at end of file
<?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">
<LinearLayout
android:id="@+id/id_ll_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="30dp">
<ImageView
android:id="@+id/id_img_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:src="@drawable/icon_fanhui" />
<RelativeLayout
android:id="@+id/id_rl_search"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_weight="1"
android:background="@drawable/shape_9a6bf8_r20"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:visibility="visible">
<EditText
android:id="@+id/id_edit_search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:gravity="center_vertical"
android:padding="6dp"
android:textColor="@color/color_333333"
android:textCursorDrawable="@drawable/cursor_color"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/id_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rl_seach_reslut"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<include layout="@layout/layout_search_reslut_empty_view" />
</FrameLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/id_ll_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image_1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="当前列表为空"
android:textColor="@color/color_999999"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
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