3.2.1
This commit is contained in:
parent
278b795190
commit
8a03631c5e
@ -34,8 +34,8 @@ android {
|
||||
applicationId "com.arpa.hndahesudintocctmsdriver"
|
||||
minSdkVersion 22
|
||||
targetSdkVersion 30
|
||||
versionCode 51
|
||||
versionName "3.2.0"
|
||||
versionCode 52
|
||||
versionName "3.2.1"
|
||||
flavorDimensions "CHANNEL_VALUE"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
|
@ -2,6 +2,7 @@ package com.arpa.hndahesudintocctmsdriver.ui.business;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@ -9,6 +10,15 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.amap.api.services.core.AMapException;
|
||||
import com.amap.api.services.core.LatLonPoint;
|
||||
import com.amap.api.services.core.PoiItem;
|
||||
import com.amap.api.services.core.SuggestionCity;
|
||||
import com.amap.api.services.poisearch.PoiResult;
|
||||
import com.amap.api.services.poisearch.PoiSearch;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.alert.ToastUtil;
|
||||
import com.dahe.mylibrary.utils.ImageLoader;
|
||||
import com.dahe.mylibrary.utils.ToastUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.BusinessBean;
|
||||
@ -39,53 +49,70 @@ import okhttp3.Response;
|
||||
* @date 2021/9/6 9:59
|
||||
* @description:
|
||||
*/
|
||||
public class BusinessActivity extends BaseActivity {
|
||||
public class BusinessActivity extends BaseActivity implements PoiSearch.OnPoiSearchListener {
|
||||
|
||||
private BaseRecyclerView business_type;
|
||||
private BaseRecyclerView business_list;
|
||||
private LocationGDUtil ld;
|
||||
private TextView address;
|
||||
private BusinessListBean blb;
|
||||
private Gson gson=new Gson();
|
||||
private List<Object> bbs=new ArrayList<>();
|
||||
private Gson gson = new Gson();
|
||||
private List<Object> bbs = new ArrayList<>();
|
||||
private CustomDialog customDialog;
|
||||
private int sum=0;
|
||||
private String type="餐饮";
|
||||
private int sum = 0;
|
||||
private String type = "餐饮";
|
||||
private PoiSearch.Query query;
|
||||
private List<PoiItem> poiItems;// poi数据
|
||||
|
||||
@Override
|
||||
public void msgMethod(Message m) {
|
||||
super.msgMethod(m);
|
||||
switch (m.what){
|
||||
switch (m.what) {
|
||||
case RequsetCodeConstants.SUCCESS:
|
||||
if(CacheGroup.cacheList.get("business_list")!=null){
|
||||
Log.e("--res--",CacheGroup.cacheList.get("business_list")+"");
|
||||
blb=gson.fromJson(CacheGroup.cacheList.get("business_list"),BusinessListBean.class);
|
||||
if(blb.getCode()==200){
|
||||
if (CacheGroup.cacheList.get("business_list") != null) {
|
||||
Log.e("--res--", CacheGroup.cacheList.get("business_list") + "");
|
||||
blb = gson.fromJson(CacheGroup.cacheList.get("business_list"), BusinessListBean.class);
|
||||
if (blb.getCode() == 200) {
|
||||
forGetBusDel();
|
||||
}else{
|
||||
Toast.makeText(con,blb.getMsg(),Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(con, blb.getMsg(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
CacheGroup.cacheList.remove("business_list");
|
||||
}
|
||||
break;
|
||||
case LocationGDUtil.RES:
|
||||
address.setText(ld.getAddress());
|
||||
new BusinessRequest().GetBusinessList(con,hd,ld.getLongitude()+"",ld.getLatitude()+"",type);
|
||||
// new BusinessRequest().GetBusinessList(con,hd,ld.getLongitude()+"",ld.getLatitude()+"",type);
|
||||
|
||||
try {
|
||||
customDialog.dismiss();
|
||||
LatLonPoint lp = new LatLonPoint(ld.getLatitude(), ld.getLongitude());
|
||||
PoiSearch poiSearch = new PoiSearch(this, query);
|
||||
poiSearch.setOnPoiSearchListener(this);
|
||||
poiSearch.setBound(new PoiSearch.SearchBound(lp, 5000, true));//
|
||||
// 设置搜索区域为以lp点为圆心,其周围5000米范围
|
||||
poiSearch.searchPOIAsyn();// 异步搜索
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 2:
|
||||
BusinessBean.DataDTO bds=gson.fromJson((String) m.obj,BusinessBean.DataDTO.class);
|
||||
BusinessBean.DataDTO bds = gson.fromJson((String) m.obj, BusinessBean.DataDTO.class);
|
||||
bbs.add(bds);
|
||||
initBusListDel();
|
||||
break;
|
||||
case 3:
|
||||
Log.e("aaa",(String) m.obj);
|
||||
BusinessBean.DataDTO bd=gson.fromJson((String) m.obj,BusinessBean.DataDTO.class);
|
||||
Log.e("aaa", (String) m.obj);
|
||||
BusinessBean.DataDTO bd = gson.fromJson((String) m.obj, BusinessBean.DataDTO.class);
|
||||
|
||||
if(bd!=null){
|
||||
if (bd != null) {
|
||||
//if (BeanUtil.isBean(bd.getClass())) {
|
||||
try {
|
||||
business_list.addItemV(bd);
|
||||
}catch (Exception e){
|
||||
Log.e("遇到了",bd.toString());
|
||||
} catch (Exception e) {
|
||||
Log.e("遇到了", bd.toString());
|
||||
}
|
||||
//}
|
||||
}
|
||||
@ -98,71 +125,130 @@ public class BusinessActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
StateStyleUtil.stateTextColor(this);
|
||||
setContentView(R.layout.activity_business);
|
||||
con=this;
|
||||
business_type=findViewById(R.id.business_type);
|
||||
business_list=findViewById(R.id.business_list);
|
||||
address=findViewById(R.id.address);
|
||||
con = this;
|
||||
business_type = findViewById(R.id.business_type);
|
||||
business_list = findViewById(R.id.business_list);
|
||||
address = findViewById(R.id.address);
|
||||
try {
|
||||
type=getIntent().getExtras().getString("type");
|
||||
}catch (Exception e){
|
||||
type="餐饮";
|
||||
type = getIntent().getExtras().getString("type");
|
||||
} catch (Exception e) {
|
||||
type = "餐饮";
|
||||
}
|
||||
initView(null);
|
||||
customDialog=new CustomDialog(con, "正在定位...");
|
||||
customDialog = new CustomDialog(con, "正在定位...");
|
||||
customDialog.show();
|
||||
ld=new LocationGDUtil(con,hd);
|
||||
ld = new LocationGDUtil(con, hd);
|
||||
ld.onCreate();
|
||||
|
||||
changeType(type);
|
||||
|
||||
}
|
||||
|
||||
List<Object> list_type=new ArrayList<>();
|
||||
List<Object> list_type = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void initView(Object obj) {
|
||||
super.initView(obj);
|
||||
list_type.add(new Model("餐饮",R.mipmap.icon_canguan));
|
||||
list_type.add(new Model("住宿",R.mipmap.icon_jiudian));
|
||||
list_type.add(new Model("商店",R.mipmap.icon_shangdian));
|
||||
list_type.add(new Model("加油站",R.mipmap.icon_jiayouzhan));
|
||||
list_type.add(new Model("汽车维修",R.mipmap.icon_xiuche));
|
||||
business_type.createG(4,con,list_type,R.layout.item_business_type).setOnItemViewListener((position, o, v) -> {
|
||||
Model m= (Model) o;
|
||||
ImageView type_img=v.findViewById(R.id.type_icon);
|
||||
list_type.add(new Model("餐饮", R.mipmap.icon_canguan));
|
||||
list_type.add(new Model("住宿", R.mipmap.icon_jiudian));
|
||||
list_type.add(new Model("商店", R.mipmap.icon_shangdian));
|
||||
list_type.add(new Model("加油站", R.mipmap.icon_jiayouzhan));
|
||||
list_type.add(new Model("汽车维修", R.mipmap.icon_xiuche));
|
||||
business_type.createG(4, con, list_type, R.layout.item_business_type).setOnItemViewListener((position, o, v) -> {
|
||||
Model m = (Model) o;
|
||||
ImageView type_img = v.findViewById(R.id.type_icon);
|
||||
type_img.setImageResource(m.getType_img());
|
||||
v.setOnClickListener(v1 -> {
|
||||
sum=0;
|
||||
bbs=new ArrayList<>();
|
||||
customDialog=new CustomDialog(con, "正在切换...");
|
||||
sum = 0;
|
||||
bbs = new ArrayList<>();
|
||||
customDialog = new CustomDialog(con, "正在切换...");
|
||||
customDialog.show();
|
||||
new BusinessRequest().GetBusinessList(con,hd,ld.getLongitude()+"",ld.getLatitude()+"",m.getType_name());
|
||||
changeType(m.getType_name());
|
||||
// new BusinessRequest().GetBusinessList(con,hd,ld.getLongitude()+"",ld.getLatitude()+"",m.getType_name());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void forGetBusDel(){
|
||||
@Override
|
||||
public void onPoiSearched(PoiResult poiResult, int i) {
|
||||
if (poiResult != null && poiResult.getQuery() != null) {// 搜索poi的结果
|
||||
poiItems = poiResult.getPois();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息
|
||||
if (poiItems != null && poiItems.size() > 0) {
|
||||
initBusListDel();
|
||||
} else {
|
||||
ToastUtils.showToast(con, "对不起,没有搜索到相关数据!");
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showToast(con, "对不起,没有搜索到相关数据!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPoiItemSearched(PoiItem poiItem, int i) {
|
||||
System.out.println(poiItem);
|
||||
}
|
||||
|
||||
private void changeType(String type) {
|
||||
query = new PoiSearch.Query(type, "", "");
|
||||
query.setExtensions("all");
|
||||
query.setPageSize(20);// 设置每页最多返回多少条poiitem
|
||||
query.setPageNum(0);// 设置查第一页
|
||||
|
||||
if (ld.getLatitude() != 0) {
|
||||
try {
|
||||
|
||||
LatLonPoint lp = new LatLonPoint(ld.getLatitude(), ld.getLongitude());
|
||||
PoiSearch poiSearch = new PoiSearch(this, query);
|
||||
poiSearch.setOnPoiSearchListener(this);
|
||||
poiSearch.setBound(new PoiSearch.SearchBound(lp, 5000, true));//
|
||||
// 设置搜索区域为以lp点为圆心,其周围5000米范围
|
||||
poiSearch.searchPOIAsyn();// 异步搜索
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forGetBusDel() {
|
||||
customDialog.dismiss();
|
||||
//business_list.remo
|
||||
Log.e("-数组-",gson.toJson(blb));
|
||||
for (int i=0;i<blb.getData().getResults().size();i++) {
|
||||
Log.e("-数组-", gson.toJson(blb));
|
||||
for (int i = 0; i < blb.getData().getResults().size(); i++) {
|
||||
//new BusinessRequest().GetBusiness(con,hd,blb.getData().getResults().get(i).getOpenshopid());
|
||||
String url="https://openapi.dianping.com/router/poiinfo/detailinfo";
|
||||
requestGet(url+Md5Util.resDelUrl(blb.getData().getResults().get(i).getOpenshopid()));
|
||||
String url = "https://openapi.dianping.com/router/poiinfo/detailinfo";
|
||||
requestGet(url + Md5Util.resDelUrl(blb.getData().getResults().get(i).getOpenshopid()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void initBusListDel(){
|
||||
public void initBusListDel() {
|
||||
customDialog.dismiss();
|
||||
//开始渲染
|
||||
business_list.createV(con,bbs,R.layout.item_business_list).setOnItemViewListener((position, o, v) -> {
|
||||
BusinessBean.DataDTO bd= (BusinessBean.DataDTO) o;
|
||||
v.setOnClickListener(v1 -> {
|
||||
business_list.createV(con, poiItems, R.layout.item_business_list).setOnItemViewListener((position, o, v) -> {
|
||||
PoiItem bd = (PoiItem) o;
|
||||
ImageView img = v.findViewById(R.id.photo_url);
|
||||
TextView name = v.findViewById(R.id.name);
|
||||
TextView address = v.findViewById(R.id.address);
|
||||
TextView taste = v.findViewById(R.id.taste);
|
||||
|
||||
if (bd.getPhotos().size() > 0 && !TextUtils.isEmpty(bd.getPhotos().get(0).getUrl())) {
|
||||
ImageLoader.getInstance().loadRoundImage(con, bd.getPhotos().get(0).getUrl(), 10, img);
|
||||
}
|
||||
|
||||
name.setText(bd.getTitle());
|
||||
address.setText(bd.getSnippet());
|
||||
taste.setText(bd.getTel());
|
||||
|
||||
// v.setOnClickListener(v1 -> {
|
||||
// Intent in=new Intent(con, WebActivity.class);
|
||||
// in.putExtra("url",bd.getBusiness_url());
|
||||
// in.putExtra("title",bd.getName());
|
||||
// startActivity(in);
|
||||
});
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
public void requestGet(String url){
|
||||
public void requestGet(String url) {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
Request request = new Request.Builder()
|
||||
@ -178,22 +264,22 @@ public class BusinessActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
if(response.code()==200){
|
||||
String body=response.body().string();
|
||||
Log.e("-body-",body);
|
||||
BusinessBean bb=gson.fromJson(body,BusinessBean.class);
|
||||
if(bb.getCode()==200){
|
||||
if (response.code() == 200) {
|
||||
String body = response.body().string();
|
||||
Log.e("-body-", body);
|
||||
BusinessBean bb = gson.fromJson(body, BusinessBean.class);
|
||||
if (bb.getCode() == 200) {
|
||||
sum++;
|
||||
//bbs.add(bb.getData());
|
||||
if(sum==1){
|
||||
Log.e("--添加--",bbs.size()+"_"+blb.getData().getResults().size());
|
||||
MsgUtil.addHdMsgWatBody(hd,2,gson.toJson(bb.getData()));
|
||||
}else{
|
||||
Log.e("--添加--",bbs.size()+"_"+blb.getData().getResults().size());
|
||||
MsgUtil.addHdMsgWatBody(hd,3,gson.toJson(bb.getData()));
|
||||
if (sum == 1) {
|
||||
Log.e("--添加--", bbs.size() + "_" + blb.getData().getResults().size());
|
||||
MsgUtil.addHdMsgWatBody(hd, 2, gson.toJson(bb.getData()));
|
||||
} else {
|
||||
Log.e("--添加--", bbs.size() + "_" + blb.getData().getResults().size());
|
||||
MsgUtil.addHdMsgWatBody(hd, 3, gson.toJson(bb.getData()));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
@ -201,8 +287,7 @@ public class BusinessActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Model{
|
||||
class Model {
|
||||
private String type_name;
|
||||
private int type_img;
|
||||
|
||||
|
@ -468,7 +468,7 @@ public class HomeFragment extends BaseFragment {
|
||||
case 0:
|
||||
//startActivity(new Intent(con, OrderListActivity.class));
|
||||
PermissionX.init(getActivity())
|
||||
.permissions(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
||||
.permissions(Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
.request((allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
Intent in = new Intent(con, BusinessActivity.class);
|
||||
|
@ -22,6 +22,7 @@
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_marginTop="@dimen/dp_7"
|
||||
@ -37,10 +38,11 @@
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/sp_13" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_marginTop="@dimen/dp_7"
|
||||
android:layout_marginTop="@dimen/dp_18"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
@ -51,12 +53,13 @@
|
||||
android:text="店铺地址:"/>
|
||||
<TextView
|
||||
android:id="@+id/address"
|
||||
android:singleLine="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_13" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_marginTop="@dimen/dp_7"
|
||||
android:layout_marginTop="@dimen/dp_18"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
@ -64,13 +67,15 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_13"
|
||||
android:text="口味:"/>
|
||||
android:text="联系方式:"/>
|
||||
<TextView
|
||||
android:id="@+id/taste"
|
||||
android:singleLine="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_13" />
|
||||
<TextView
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_13"
|
||||
@ -81,6 +86,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_13" />
|
||||
<TextView
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_13"
|
||||
|
Loading…
Reference in New Issue
Block a user