|
|
@@ -2,8 +2,14 @@ package com.modular.booking.activity.services;
|
|
|
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
+import android.support.v7.app.ActionBar;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.text.TextWatcher;
|
|
|
+import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.widget.AdapterView;
|
|
|
+import android.widget.ImageView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@@ -15,8 +21,12 @@ import com.common.data.ListUtils;
|
|
|
import com.core.app.Constants;
|
|
|
import com.core.app.MyApplication;
|
|
|
import com.core.base.OABaseActivity;
|
|
|
+import com.core.interfac.OnVoiceCompleteListener;
|
|
|
import com.core.utils.BaiduMapUtil;
|
|
|
+import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.DistanceUtils;
|
|
|
+import com.core.utils.ToastUtil;
|
|
|
+import com.core.widget.ClearEditText;
|
|
|
import com.core.widget.EmptyLayout;
|
|
|
import com.core.widget.VoiceSearchView;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
@@ -65,8 +75,80 @@ public class BServiceListActivity extends OABaseActivity {
|
|
|
emptyLayout=new EmptyLayout(mContext,mListView.getRefreshableView());
|
|
|
mListAdapter=new ItemBserviceListAdapter(mContext,modelList);
|
|
|
mListView.setAdapter(mListAdapter);
|
|
|
+
|
|
|
+ initSearchView();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ private ImageView mBackImageView, mVoiceImageView;
|
|
|
+ private ClearEditText mSearchEditText;
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
+ private void initSearchView() {
|
|
|
+ View view = LayoutInflater.from(ct).inflate(R.layout.action_book_service_search, null);
|
|
|
+ mBackImageView = (ImageView) view.findViewById(R.id.book_service_search_back);
|
|
|
+ mVoiceImageView = (ImageView) view.findViewById(R.id.book_service_search_voice_iv);
|
|
|
+ mSearchEditText = (ClearEditText) view.findViewById(R.id.book_service_search_et);
|
|
|
+ ActionBar bar = this.getSupportActionBar();
|
|
|
+ bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
|
|
+ bar.setCustomView(view);
|
|
|
+ mBackImageView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mVoiceImageView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ CommonUtil.getVoiceText(ct, mSearchEditText, new OnVoiceCompleteListener() {
|
|
|
+ @Override
|
|
|
+ public void onVoiceComplete() {
|
|
|
+ // TODO: 2017/9/30 语音输入后开始搜索
|
|
|
+ ToastUtil.showToast(BServiceListActivity.this, "语音输入完毕");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mEmptyLayout = new EmptyLayout(this, mListView.getRefreshableView());
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
+
|
|
|
+ mSearchEditText.addTextChangedListener(new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ if (!TextUtils.isEmpty(s.toString())){
|
|
|
+ if (!ListUtils.isEmpty(modelList)){
|
|
|
+ List<SBListModel> tempList=new ArrayList<>();
|
|
|
+ for (int i = 0; i <modelList.size() ; i++) {
|
|
|
+ if (modelList.get(i).getName().contains(s.toString())){
|
|
|
+ tempList.add(modelList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ListUtils.isEmpty(tempList)) mEmptyLayout.showEmpty();
|
|
|
+ LogUtil.d(TAG,"tempList:"+JSON.toJSONString(tempList.toString()));
|
|
|
+ mListAdapter.setObjects(tempList);
|
|
|
+ mListAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ mListAdapter.setObjects(modelList);
|
|
|
+ mListAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
private void initEvent() {
|
|
|
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|