AddressAdapter.java
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.people.location;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.foundation.bean.response.GdDistrictBean;
import com.wd.foundation.wdkit.utils.TextViewUtils;
import org.jetbrains.annotations.NotNull;
/**
* 描述:搜索地址的列表
*
* @author : lvjinhui
* @since: 2022/8/5
*/
public class AddressAdapter extends BaseQuickAdapter<GdDistrictBean, BaseViewHolder> {
public AddressAdapter() {
super(R.layout.adress_item);
}
@Override
protected void convert(@NonNull @NotNull BaseViewHolder viewHolder, GdDistrictBean item) {
TextView location = viewHolder.getView(R.id.location);
TextView address = viewHolder.getView(R.id.adress);
if (item.isAloneCity()) {
TextViewUtils.setText(location, item.getParentName());
address.setVisibility(View.VISIBLE);
if(TextUtils.isEmpty(item.getProvince())){
TextViewUtils.setText(address,item.getParentName());
}else{
if (item.getProvince().equals(item.getParentName())) {
TextViewUtils.setText(address,item.getParentName());
} else {
TextViewUtils.setText(address,item.getProvince() + item.getParentName());
}
}
} else {
TextViewUtils.setText(location, item.getName());
String poiAd = item.getParentName() + item.getName();
TextViewUtils.setText(address,poiAd);
if (TextUtils.isEmpty(poiAd)) {
address.setVisibility(View.GONE);
} else {
address.setVisibility(View.VISIBLE);
}
}
// viewHolder.setOnClickListener(R.id.item, new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent = new Intent();
// intent.putExtra(KEY_ADDRESS, item.optString("poiName"));
// setResult(RESULT_OK, intent);
// finish();
// }
// });
}
}