删除车辆刷新列表奔溃处理
This commit is contained in:
parent
bc86fdf444
commit
9600c213d4
@ -0,0 +1,21 @@
|
|||||||
|
package com.arpa.hndahesudintocctmsdriver.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hlh
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2021/11/2 18:51
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
public class RefreshCarListEvent {
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public RefreshCarListEvent(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.arpa.hndahesudintocctmsdriver.event.RefreshCarListEvent;
|
||||||
import com.arpa.hndahesudintocctmsdriver.event.VehicleEvent;
|
import com.arpa.hndahesudintocctmsdriver.event.VehicleEvent;
|
||||||
import com.arpa.hndahesudintocctmsdriver.util.alert.ToastUtil;
|
import com.arpa.hndahesudintocctmsdriver.util.alert.ToastUtil;
|
||||||
import com.dahe.mylibrary.utils.ToastUtils;
|
import com.dahe.mylibrary.utils.ToastUtils;
|
||||||
@ -81,7 +82,7 @@ public class VehicleAuthActivity extends BaseAppCompatActivity {
|
|||||||
bb=gson.fromJson(CacheGroup.cacheList.get(DEL_CAR),BaseBean.class);
|
bb=gson.fromJson(CacheGroup.cacheList.get(DEL_CAR),BaseBean.class);
|
||||||
if (bb.getCode()==200) {
|
if (bb.getCode()==200) {
|
||||||
Toast.makeText(con,"删除成功",Toast.LENGTH_SHORT).show();
|
Toast.makeText(con,"删除成功",Toast.LENGTH_SHORT).show();
|
||||||
VehicleEvent ve = new VehicleEvent("");
|
RefreshCarListEvent ve = new RefreshCarListEvent("");
|
||||||
EventBus.getDefault().post(ve);
|
EventBus.getDefault().post(ve);
|
||||||
finish();
|
finish();
|
||||||
}else{
|
}else{
|
||||||
|
@ -18,6 +18,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.arpa.hndahesudintocctmsdriver.event.PersonEvent;
|
import com.arpa.hndahesudintocctmsdriver.event.PersonEvent;
|
||||||
|
import com.arpa.hndahesudintocctmsdriver.event.RefreshCarListEvent;
|
||||||
import com.arpa.hndahesudintocctmsdriver.event.VehicleEvent;
|
import com.arpa.hndahesudintocctmsdriver.event.VehicleEvent;
|
||||||
import com.arpa.hndahesudintocctmsdriver.parts.ConfigParts;
|
import com.arpa.hndahesudintocctmsdriver.parts.ConfigParts;
|
||||||
import com.arpa.hndahesudintocctmsdriver.parts.StartOrderParts;
|
import com.arpa.hndahesudintocctmsdriver.parts.StartOrderParts;
|
||||||
@ -63,32 +64,32 @@ public class MyFragment extends BaseFragment {
|
|||||||
private UserBean userBean;
|
private UserBean userBean;
|
||||||
private StartOrderBean sob;
|
private StartOrderBean sob;
|
||||||
private CarListBean clb;
|
private CarListBean clb;
|
||||||
private Gson gson=new Gson();
|
private Gson gson = new Gson();
|
||||||
private UserRequset ur;
|
private UserRequset ur;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void msgMethod(Message m) {
|
public void msgMethod(Message m) {
|
||||||
super.msgMethod(m);
|
super.msgMethod(m);
|
||||||
switch (m.what){
|
switch (m.what) {
|
||||||
case 200:
|
case 200:
|
||||||
refreshLayout.finishRefresh();
|
refreshLayout.finishRefresh();
|
||||||
if(CacheGroup.cacheList.get(WoDeFragment.VEHICLE_LIST)!=null){
|
if (CacheGroup.cacheList.get(WoDeFragment.VEHICLE_LIST) != null) {
|
||||||
clb=gson.fromJson(CacheGroup.cacheList.get(WoDeFragment.VEHICLE_LIST),CarListBean.class);
|
clb = gson.fromJson(CacheGroup.cacheList.get(WoDeFragment.VEHICLE_LIST), CarListBean.class);
|
||||||
if(clb.getCode()==200){
|
if (clb.getCode() == 200) {
|
||||||
initVehicleList(true);
|
initVehicleList(true);
|
||||||
}else{
|
} else {
|
||||||
Toast.makeText(con,clb.getRes(),Toast.LENGTH_LONG).show();
|
Toast.makeText(con, clb.getRes(), Toast.LENGTH_LONG).show();
|
||||||
initVehicleList(false);
|
initVehicleList(false);
|
||||||
}
|
}
|
||||||
CacheGroup.cacheList.remove(WoDeFragment.VEHICLE_LIST);
|
CacheGroup.cacheList.remove(WoDeFragment.VEHICLE_LIST);
|
||||||
}
|
}
|
||||||
if (CacheGroup.cacheList.get("userdata")!=null){
|
if (CacheGroup.cacheList.get("userdata") != null) {
|
||||||
userBean=gson.fromJson(CacheGroup.cacheList.get("userdata"), UserBean.class);
|
userBean = gson.fromJson(CacheGroup.cacheList.get("userdata"), UserBean.class);
|
||||||
if(userBean.getCode()==200 ){
|
if (userBean.getCode() == 200) {
|
||||||
SPUtil.insSP(con,"data","userdata",CacheGroup.cacheList.get("userdata"));
|
SPUtil.insSP(con, "data", "userdata", CacheGroup.cacheList.get("userdata"));
|
||||||
initAuth();
|
initAuth();
|
||||||
}else{
|
} else {
|
||||||
Toast.makeText(con,userBean.getMsg(),Toast.LENGTH_SHORT).show();
|
Toast.makeText(con, userBean.getMsg(), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
CacheGroup.cacheList.remove("userdata");
|
CacheGroup.cacheList.remove("userdata");
|
||||||
}
|
}
|
||||||
@ -100,12 +101,12 @@ public class MyFragment extends BaseFragment {
|
|||||||
@org.jetbrains.annotations.Nullable
|
@org.jetbrains.annotations.Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
||||||
root=inflater.inflate(R.layout.fragment_my,container,false);
|
root = inflater.inflate(R.layout.fragment_my, container, false);
|
||||||
con=root.getContext();
|
con = root.getContext();
|
||||||
brv=root.findViewById(R.id.rv);
|
brv = root.findViewById(R.id.rv);
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
userBean= UserParts.getUser(con);
|
userBean = UserParts.getUser(con);
|
||||||
ur=new UserRequset(con,hd);
|
ur = new UserRequset(con, hd);
|
||||||
getRequest();
|
getRequest();
|
||||||
initId();
|
initId();
|
||||||
initRefreshLoad();
|
initRefreshLoad();
|
||||||
@ -114,7 +115,7 @@ public class MyFragment extends BaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initRefreshLoad() {
|
public void initRefreshLoad() {
|
||||||
refreshLayout =root.findViewById(R.id.srl);
|
refreshLayout = root.findViewById(R.id.srl);
|
||||||
refreshLayout.setOnRefreshListener(refreshLayout -> {
|
refreshLayout.setOnRefreshListener(refreshLayout -> {
|
||||||
getRequest();
|
getRequest();
|
||||||
});
|
});
|
||||||
@ -123,7 +124,7 @@ public class MyFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void initView(Object obj) {
|
public void initView(Object obj) {
|
||||||
super.initView(obj);
|
super.initView(obj);
|
||||||
brv_vehicle=root.findViewById(R.id.brv_vehicle);
|
brv_vehicle = root.findViewById(R.id.brv_vehicle);
|
||||||
ur.vehicleList("1");
|
ur.vehicleList("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,83 +132,85 @@ public class MyFragment extends BaseFragment {
|
|||||||
//执行中订单
|
//执行中订单
|
||||||
|
|
||||||
//车辆信息
|
//车辆信息
|
||||||
public void initVehicleList(boolean isSuccess){
|
public void initVehicleList(boolean isSuccess) {
|
||||||
//车辆信息
|
//车辆信息
|
||||||
List<ManyBean> list_vehicle=new ArrayList<>();
|
List<ManyBean> list_vehicle = new ArrayList<>();
|
||||||
for (CarListBean.DataDTO datum : clb.getData()) {
|
for (CarListBean.DataDTO datum : clb.getData()) {
|
||||||
list_vehicle.add(new ManyBean(datum,R.layout.my_item_vehicle));
|
list_vehicle.add(new ManyBean(datum, R.layout.my_item_vehicle));
|
||||||
}
|
}
|
||||||
if(list_vehicle.size()==0){
|
if (list_vehicle.size() == 0) {
|
||||||
list_vehicle.add(new ManyBean(new Model(),R.layout.my_item_vehicle_null));
|
list_vehicle.add(new ManyBean(new Model(), R.layout.my_item_vehicle_null));
|
||||||
}
|
}
|
||||||
brv_vehicle.creates(con,list_vehicle).setOnItemViewListener((position, o, v, layout) -> {
|
brv_vehicle.creates(con, list_vehicle).setOnItemViewListener((position, o, v, layout) -> {
|
||||||
switch (layout){
|
switch (layout) {
|
||||||
case R.layout.my_item_vehicle:
|
case R.layout.my_item_vehicle:
|
||||||
CarListBean.DataDTO cd= (CarListBean.DataDTO) o;
|
CarListBean.DataDTO cd = (CarListBean.DataDTO) o;
|
||||||
View br=v.findViewById(R.id.br);
|
View br = v.findViewById(R.id.br);
|
||||||
if(position==(clb.getData().size()-1) && position!=2){
|
if (position == (clb.getData().size() - 1) && position != 2) {
|
||||||
LinearLayout add_box=v.findViewById(R.id.add_box);
|
LinearLayout add_box = v.findViewById(R.id.add_box);
|
||||||
TextView add_no=v.findViewById(R.id.add_no);
|
TextView add_no = v.findViewById(R.id.add_no);
|
||||||
add_no.setVisibility(View.GONE);
|
add_no.setVisibility(View.GONE);
|
||||||
add_box.setVisibility(View.VISIBLE);
|
add_box.setVisibility(View.VISIBLE);
|
||||||
br.setVisibility(View.GONE);
|
br.setVisibility(View.GONE);
|
||||||
add_box.setOnClickListener(v1 -> {
|
add_box.setOnClickListener(v1 -> {
|
||||||
Intent in=new Intent(con, VehicleAuthActivity.class);
|
Intent in = new Intent(con, VehicleAuthActivity.class);
|
||||||
in.putExtra("carId","");
|
in.putExtra("carId", "");
|
||||||
startActivity(in);
|
startActivity(in);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
v.setOnClickListener(v1 -> {
|
v.setOnClickListener(v1 -> {
|
||||||
Intent in=new Intent(con, VehicleAuthActivity.class);
|
Intent in = new Intent(con, VehicleAuthActivity.class);
|
||||||
in.putExtra("carId",cd.getCarId());
|
in.putExtra("carId", cd.getCarId());
|
||||||
startActivity(in);
|
startActivity(in);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case R.layout.my_item_vehicle_null:
|
case R.layout.my_item_vehicle_null:
|
||||||
v.setOnClickListener(v12 -> {
|
v.setOnClickListener(v12 -> {
|
||||||
Intent in=new Intent(con, VehicleAuthActivity.class);
|
Intent in = new Intent(con, VehicleAuthActivity.class);
|
||||||
in.putExtra("carId","");
|
in.putExtra("carId", "");
|
||||||
startActivity(in);
|
startActivity(in);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class Model{ }
|
class Model {
|
||||||
|
}
|
||||||
|
|
||||||
public void getRequest(){
|
public void getRequest() {
|
||||||
sob= StartOrderParts.getStartOrder(con);
|
sob = StartOrderParts.getStartOrder(con);
|
||||||
ur.User();
|
ur.User();
|
||||||
ur.vehicleList("1");
|
ur.vehicleList("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinearLayout onGetUser,onAllOrder,onAuth,onDriverHome;
|
private LinearLayout onGetUser, onAllOrder, onAuth, onDriverHome;
|
||||||
private ImageView onContact,onOpinion,onUpdate,onSetUp;
|
private ImageView onContact, onOpinion, onUpdate, onSetUp;
|
||||||
private TextView name,phone;
|
private TextView name, phone;
|
||||||
private ImageView dang_auth,no_auth,name_auth;
|
private ImageView dang_auth, no_auth, name_auth;
|
||||||
private LinearLayout auth_box;
|
private LinearLayout auth_box;
|
||||||
private ImageView img_head;
|
private ImageView img_head;
|
||||||
|
|
||||||
public void initId(){
|
public void initId() {
|
||||||
//
|
//
|
||||||
name=root.findViewById(R.id.name);
|
name = root.findViewById(R.id.name);
|
||||||
phone=root.findViewById(R.id.phone);
|
phone = root.findViewById(R.id.phone);
|
||||||
dang_auth=root.findViewById(R.id.dang_auth);
|
dang_auth = root.findViewById(R.id.dang_auth);
|
||||||
no_auth=root.findViewById(R.id.no_auth);
|
no_auth = root.findViewById(R.id.no_auth);
|
||||||
name_auth=root.findViewById(R.id.name_auth);
|
name_auth = root.findViewById(R.id.name_auth);
|
||||||
auth_box=root.findViewById(R.id.auth_box);
|
auth_box = root.findViewById(R.id.auth_box);
|
||||||
//
|
//
|
||||||
onGetUser=root.findViewById(R.id.onGetUser);
|
onGetUser = root.findViewById(R.id.onGetUser);
|
||||||
onAllOrder=root.findViewById(R.id.onAllOrder);
|
onAllOrder = root.findViewById(R.id.onAllOrder);
|
||||||
onAuth=root.findViewById(R.id.onAuth);
|
onAuth = root.findViewById(R.id.onAuth);
|
||||||
onDriverHome=root.findViewById(R.id.onDriverHome);
|
onDriverHome = root.findViewById(R.id.onDriverHome);
|
||||||
onContact=root.findViewById(R.id.onContact);
|
onContact = root.findViewById(R.id.onContact);
|
||||||
onOpinion=root.findViewById(R.id.onOpinion);
|
onOpinion = root.findViewById(R.id.onOpinion);
|
||||||
onUpdate=root.findViewById(R.id.onUpdate);
|
onUpdate = root.findViewById(R.id.onUpdate);
|
||||||
onSetUp=root.findViewById(R.id.onSetUp);
|
onSetUp = root.findViewById(R.id.onSetUp);
|
||||||
img_head=root.findViewById(R.id.img_head);
|
img_head = root.findViewById(R.id.img_head);
|
||||||
//认证
|
//认证
|
||||||
no_auth.setOnClickListener(v -> startActivity(new Intent(con, PersonalAuthActivity.class)));
|
no_auth.setOnClickListener(v -> startActivity(new Intent(con, PersonalAuthActivity.class)));
|
||||||
//用户信息
|
//用户信息
|
||||||
@ -222,27 +225,27 @@ public class MyFragment extends BaseFragment {
|
|||||||
.permissions(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
.permissions(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
||||||
.request((allGranted, grantedList, deniedList) -> {
|
.request((allGranted, grantedList, deniedList) -> {
|
||||||
if (allGranted) {
|
if (allGranted) {
|
||||||
Intent in=new Intent(con, BusinessActivity.class);
|
Intent in = new Intent(con, BusinessActivity.class);
|
||||||
in.putExtra("type","餐饮");
|
in.putExtra("type", "餐饮");
|
||||||
startActivity(in);
|
startActivity(in);
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getContext(),"请先开启定位权限",Toast.LENGTH_LONG).show();
|
Toast.makeText(getContext(), "请先开启定位权限", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//联系我们
|
//联系我们
|
||||||
onContact.setOnClickListener(v -> {
|
onContact.setOnClickListener(v -> {
|
||||||
String serviceMobile="";
|
String serviceMobile = "";
|
||||||
if(ConfigParts.getConfigParts(con)!=null){
|
if (ConfigParts.getConfigParts(con) != null) {
|
||||||
serviceMobile=ConfigParts.getConfigParts(con).getData().getServiceMobile();
|
serviceMobile = ConfigParts.getConfigParts(con).getData().getServiceMobile();
|
||||||
serviceMobile=StringUtil.isNull(serviceMobile,"");
|
serviceMobile = StringUtil.isNull(serviceMobile, "");
|
||||||
}
|
}
|
||||||
String[] title={"平台客服:"+serviceMobile};
|
String[] title = {"平台客服:" + serviceMobile};
|
||||||
String[] value={serviceMobile};
|
String[] value = {serviceMobile};
|
||||||
new XPopup.Builder(con)
|
new XPopup.Builder(con)
|
||||||
.isDarkTheme(false)
|
.isDarkTheme(false)
|
||||||
.isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
|
.isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
|
||||||
.asCenterList("请选择",title,
|
.asCenterList("请选择", title,
|
||||||
(position1, text) -> {
|
(position1, text) -> {
|
||||||
Intent intent = new Intent(Intent.ACTION_DIAL);
|
Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||||
Uri data = Uri.parse("tel:" + value[position1]);
|
Uri data = Uri.parse("tel:" + value[position1]);
|
||||||
@ -253,36 +256,36 @@ public class MyFragment extends BaseFragment {
|
|||||||
});
|
});
|
||||||
//咨询建议
|
//咨询建议
|
||||||
onOpinion.setOnClickListener(v -> {
|
onOpinion.setOnClickListener(v -> {
|
||||||
Intent in=new Intent(con, WebActivity.class);
|
Intent in = new Intent(con, WebActivity.class);
|
||||||
in.putExtra("title","咨询建议");
|
in.putExtra("title", "咨询建议");
|
||||||
in.putExtra("url","");
|
in.putExtra("url", "");
|
||||||
startActivity(in);
|
startActivity(in);
|
||||||
});
|
});
|
||||||
//检查更新
|
//检查更新
|
||||||
onUpdate.setOnClickListener(v -> Toast.makeText(con,"当前已经是最新版本",Toast.LENGTH_LONG).show());
|
onUpdate.setOnClickListener(v -> Toast.makeText(con, "当前已经是最新版本", Toast.LENGTH_LONG).show());
|
||||||
//系统设置
|
//系统设置
|
||||||
onSetUp.setOnClickListener(v -> startActivity(new Intent(con, SetupActivity.class)));
|
onSetUp.setOnClickListener(v -> startActivity(new Intent(con, SetupActivity.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initAuth(){
|
public void initAuth() {
|
||||||
if(userBean.getData()!=null){
|
if (userBean.getData() != null) {
|
||||||
name.setText(StringUtil.isNull(userBean.getData().getUname(),"未实名"));
|
name.setText(StringUtil.isNull(userBean.getData().getUname(), "未实名"));
|
||||||
phone.setText(StringUtil.isNull(userBean.getData().getRname(),""));
|
phone.setText(StringUtil.isNull(userBean.getData().getRname(), ""));
|
||||||
if(2==userBean.getData().getPartyMemberStatus()){
|
if (2 == userBean.getData().getPartyMemberStatus()) {
|
||||||
|
|
||||||
}
|
}
|
||||||
if("1".equals(userBean.getData().getRealAuthentication())){
|
if ("1".equals(userBean.getData().getRealAuthentication())) {
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!"".equals(userBean.getData().getHeadportraitUrl())){
|
if (!"".equals(userBean.getData().getHeadportraitUrl())) {
|
||||||
Glide.with(con).load(userBean.getData().getHeadportraitUrl()).into(img_head);
|
Glide.with(con).load(userBean.getData().getHeadportraitUrl()).into(img_head);
|
||||||
}
|
}
|
||||||
if(userBean!=null && 100003==userBean.getData().getAuditStatus()){
|
if (userBean != null && 100003 == userBean.getData().getAuditStatus()) {
|
||||||
auth_box.setVisibility(View.GONE);
|
auth_box.setVisibility(View.GONE);
|
||||||
no_auth.setVisibility(View.GONE);
|
no_auth.setVisibility(View.GONE);
|
||||||
}else{
|
} else {
|
||||||
auth_box.setVisibility(View.GONE);
|
auth_box.setVisibility(View.GONE);
|
||||||
no_auth.setVisibility(View.VISIBLE);
|
no_auth.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
@ -290,12 +293,19 @@ public class MyFragment extends BaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void processResult(VehicleEvent event) {
|
public void processResult(VehicleEvent event) {
|
||||||
Log.e("-msg-",event.getMessage());
|
Log.e("-msg-", event.getMessage());
|
||||||
if(!"挂".equals(event.getMessage())) {
|
if (!"挂".equals(event.getMessage())) {
|
||||||
ur.vehicleList("1");
|
ur.vehicleList("1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void refreshCarListEvent(RefreshCarListEvent event) {
|
||||||
|
Log.e("-msg-", event.getMessage());
|
||||||
|
ur.vehicleList("1");
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void personResult(PersonEvent home) {
|
public void personResult(PersonEvent home) {
|
||||||
Log.e("-res-", home.getMessage());
|
Log.e("-res-", home.getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user