删除车辆刷新列表奔溃处理

This commit is contained in:
lijia 2024-07-08 09:49:52 +08:00
parent bc86fdf444
commit 9600c213d4
3 changed files with 122 additions and 90 deletions

View File

@ -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;
}
}

View File

@ -14,6 +14,7 @@ import android.widget.Toast;
import androidx.annotation.Nullable;
import com.arpa.hndahesudintocctmsdriver.event.RefreshCarListEvent;
import com.arpa.hndahesudintocctmsdriver.event.VehicleEvent;
import com.arpa.hndahesudintocctmsdriver.util.alert.ToastUtil;
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);
if (bb.getCode()==200) {
Toast.makeText(con,"删除成功",Toast.LENGTH_SHORT).show();
VehicleEvent ve = new VehicleEvent("");
RefreshCarListEvent ve = new RefreshCarListEvent("");
EventBus.getDefault().post(ve);
finish();
}else{

View File

@ -18,6 +18,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.arpa.hndahesudintocctmsdriver.event.PersonEvent;
import com.arpa.hndahesudintocctmsdriver.event.RefreshCarListEvent;
import com.arpa.hndahesudintocctmsdriver.event.VehicleEvent;
import com.arpa.hndahesudintocctmsdriver.parts.ConfigParts;
import com.arpa.hndahesudintocctmsdriver.parts.StartOrderParts;
@ -63,32 +64,32 @@ public class MyFragment extends BaseFragment {
private UserBean userBean;
private StartOrderBean sob;
private CarListBean clb;
private Gson gson=new Gson();
private Gson gson = new Gson();
private UserRequset ur;
@Override
public void msgMethod(Message m) {
super.msgMethod(m);
switch (m.what){
switch (m.what) {
case 200:
refreshLayout.finishRefresh();
if(CacheGroup.cacheList.get(WoDeFragment.VEHICLE_LIST)!=null){
clb=gson.fromJson(CacheGroup.cacheList.get(WoDeFragment.VEHICLE_LIST),CarListBean.class);
if(clb.getCode()==200){
if (CacheGroup.cacheList.get(WoDeFragment.VEHICLE_LIST) != null) {
clb = gson.fromJson(CacheGroup.cacheList.get(WoDeFragment.VEHICLE_LIST), CarListBean.class);
if (clb.getCode() == 200) {
initVehicleList(true);
}else{
Toast.makeText(con,clb.getRes(),Toast.LENGTH_LONG).show();
} else {
Toast.makeText(con, clb.getRes(), Toast.LENGTH_LONG).show();
initVehicleList(false);
}
CacheGroup.cacheList.remove(WoDeFragment.VEHICLE_LIST);
}
if (CacheGroup.cacheList.get("userdata")!=null){
userBean=gson.fromJson(CacheGroup.cacheList.get("userdata"), UserBean.class);
if(userBean.getCode()==200 ){
SPUtil.insSP(con,"data","userdata",CacheGroup.cacheList.get("userdata"));
if (CacheGroup.cacheList.get("userdata") != null) {
userBean = gson.fromJson(CacheGroup.cacheList.get("userdata"), UserBean.class);
if (userBean.getCode() == 200) {
SPUtil.insSP(con, "data", "userdata", CacheGroup.cacheList.get("userdata"));
initAuth();
}else{
Toast.makeText(con,userBean.getMsg(),Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(con, userBean.getMsg(), Toast.LENGTH_SHORT).show();
}
CacheGroup.cacheList.remove("userdata");
}
@ -100,12 +101,12 @@ public class MyFragment extends BaseFragment {
@org.jetbrains.annotations.Nullable
@Override
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);
con=root.getContext();
brv=root.findViewById(R.id.rv);
root = inflater.inflate(R.layout.fragment_my, container, false);
con = root.getContext();
brv = root.findViewById(R.id.rv);
EventBus.getDefault().register(this);
userBean= UserParts.getUser(con);
ur=new UserRequset(con,hd);
userBean = UserParts.getUser(con);
ur = new UserRequset(con, hd);
getRequest();
initId();
initRefreshLoad();
@ -114,7 +115,7 @@ public class MyFragment extends BaseFragment {
}
public void initRefreshLoad() {
refreshLayout =root.findViewById(R.id.srl);
refreshLayout = root.findViewById(R.id.srl);
refreshLayout.setOnRefreshListener(refreshLayout -> {
getRequest();
});
@ -123,7 +124,7 @@ public class MyFragment extends BaseFragment {
@Override
public void initView(Object obj) {
super.initView(obj);
brv_vehicle=root.findViewById(R.id.brv_vehicle);
brv_vehicle = root.findViewById(R.id.brv_vehicle);
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()) {
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){
list_vehicle.add(new ManyBean(new Model(),R.layout.my_item_vehicle_null));
if (list_vehicle.size() == 0) {
list_vehicle.add(new ManyBean(new Model(), R.layout.my_item_vehicle_null));
}
brv_vehicle.creates(con,list_vehicle).setOnItemViewListener((position, o, v, layout) -> {
switch (layout){
brv_vehicle.creates(con, list_vehicle).setOnItemViewListener((position, o, v, layout) -> {
switch (layout) {
case R.layout.my_item_vehicle:
CarListBean.DataDTO cd= (CarListBean.DataDTO) o;
View br=v.findViewById(R.id.br);
if(position==(clb.getData().size()-1) && position!=2){
LinearLayout add_box=v.findViewById(R.id.add_box);
TextView add_no=v.findViewById(R.id.add_no);
CarListBean.DataDTO cd = (CarListBean.DataDTO) o;
View br = v.findViewById(R.id.br);
if (position == (clb.getData().size() - 1) && position != 2) {
LinearLayout add_box = v.findViewById(R.id.add_box);
TextView add_no = v.findViewById(R.id.add_no);
add_no.setVisibility(View.GONE);
add_box.setVisibility(View.VISIBLE);
br.setVisibility(View.GONE);
add_box.setOnClickListener(v1 -> {
Intent in=new Intent(con, VehicleAuthActivity.class);
in.putExtra("carId","");
Intent in = new Intent(con, VehicleAuthActivity.class);
in.putExtra("carId", "");
startActivity(in);
});
}
v.setOnClickListener(v1 -> {
Intent in=new Intent(con, VehicleAuthActivity.class);
in.putExtra("carId",cd.getCarId());
Intent in = new Intent(con, VehicleAuthActivity.class);
in.putExtra("carId", cd.getCarId());
startActivity(in);
});
break;
case R.layout.my_item_vehicle_null:
v.setOnClickListener(v12 -> {
Intent in=new Intent(con, VehicleAuthActivity.class);
in.putExtra("carId","");
Intent in = new Intent(con, VehicleAuthActivity.class);
in.putExtra("carId", "");
startActivity(in);
});
break;
default:break;
default:
break;
}
});
}
class Model{ }
class Model {
}
public void getRequest(){
sob= StartOrderParts.getStartOrder(con);
public void getRequest() {
sob = StartOrderParts.getStartOrder(con);
ur.User();
ur.vehicleList("1");
}
private LinearLayout onGetUser,onAllOrder,onAuth,onDriverHome;
private ImageView onContact,onOpinion,onUpdate,onSetUp;
private TextView name,phone;
private ImageView dang_auth,no_auth,name_auth;
private LinearLayout onGetUser, onAllOrder, onAuth, onDriverHome;
private ImageView onContact, onOpinion, onUpdate, onSetUp;
private TextView name, phone;
private ImageView dang_auth, no_auth, name_auth;
private LinearLayout auth_box;
private ImageView img_head;
public void initId(){
public void initId() {
//
name=root.findViewById(R.id.name);
phone=root.findViewById(R.id.phone);
dang_auth=root.findViewById(R.id.dang_auth);
no_auth=root.findViewById(R.id.no_auth);
name_auth=root.findViewById(R.id.name_auth);
auth_box=root.findViewById(R.id.auth_box);
name = root.findViewById(R.id.name);
phone = root.findViewById(R.id.phone);
dang_auth = root.findViewById(R.id.dang_auth);
no_auth = root.findViewById(R.id.no_auth);
name_auth = root.findViewById(R.id.name_auth);
auth_box = root.findViewById(R.id.auth_box);
//
onGetUser=root.findViewById(R.id.onGetUser);
onAllOrder=root.findViewById(R.id.onAllOrder);
onAuth=root.findViewById(R.id.onAuth);
onDriverHome=root.findViewById(R.id.onDriverHome);
onContact=root.findViewById(R.id.onContact);
onOpinion=root.findViewById(R.id.onOpinion);
onUpdate=root.findViewById(R.id.onUpdate);
onSetUp=root.findViewById(R.id.onSetUp);
img_head=root.findViewById(R.id.img_head);
onGetUser = root.findViewById(R.id.onGetUser);
onAllOrder = root.findViewById(R.id.onAllOrder);
onAuth = root.findViewById(R.id.onAuth);
onDriverHome = root.findViewById(R.id.onDriverHome);
onContact = root.findViewById(R.id.onContact);
onOpinion = root.findViewById(R.id.onOpinion);
onUpdate = root.findViewById(R.id.onUpdate);
onSetUp = root.findViewById(R.id.onSetUp);
img_head = root.findViewById(R.id.img_head);
//认证
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)
.request((allGranted, grantedList, deniedList) -> {
if (allGranted) {
Intent in=new Intent(con, BusinessActivity.class);
in.putExtra("type","餐饮");
Intent in = new Intent(con, BusinessActivity.class);
in.putExtra("type", "餐饮");
startActivity(in);
} else {
Toast.makeText(getContext(),"请先开启定位权限",Toast.LENGTH_LONG).show();
Toast.makeText(getContext(), "请先开启定位权限", Toast.LENGTH_LONG).show();
}
});
});
//联系我们
onContact.setOnClickListener(v -> {
String serviceMobile="";
if(ConfigParts.getConfigParts(con)!=null){
serviceMobile=ConfigParts.getConfigParts(con).getData().getServiceMobile();
serviceMobile=StringUtil.isNull(serviceMobile,"");
String serviceMobile = "";
if (ConfigParts.getConfigParts(con) != null) {
serviceMobile = ConfigParts.getConfigParts(con).getData().getServiceMobile();
serviceMobile = StringUtil.isNull(serviceMobile, "");
}
String[] title={"平台客服:"+serviceMobile};
String[] value={serviceMobile};
String[] title = {"平台客服:" + serviceMobile};
String[] value = {serviceMobile};
new XPopup.Builder(con)
.isDarkTheme(false)
.isDestroyOnDismiss(true) //对于只使用一次的弹窗推荐设置这个
.asCenterList("请选择",title,
.asCenterList("请选择", title,
(position1, text) -> {
Intent intent = new Intent(Intent.ACTION_DIAL);
Uri data = Uri.parse("tel:" + value[position1]);
@ -253,36 +256,36 @@ public class MyFragment extends BaseFragment {
});
//咨询建议
onOpinion.setOnClickListener(v -> {
Intent in=new Intent(con, WebActivity.class);
in.putExtra("title","咨询建议");
in.putExtra("url","");
Intent in = new Intent(con, WebActivity.class);
in.putExtra("title", "咨询建议");
in.putExtra("url", "");
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)));
}
public void initAuth(){
if(userBean.getData()!=null){
name.setText(StringUtil.isNull(userBean.getData().getUname(),"未实名"));
phone.setText(StringUtil.isNull(userBean.getData().getRname(),""));
if(2==userBean.getData().getPartyMemberStatus()){
public void initAuth() {
if (userBean.getData() != null) {
name.setText(StringUtil.isNull(userBean.getData().getUname(), "未实名"));
phone.setText(StringUtil.isNull(userBean.getData().getRname(), ""));
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);
}
if(userBean!=null && 100003==userBean.getData().getAuditStatus()){
if (userBean != null && 100003 == userBean.getData().getAuditStatus()) {
auth_box.setVisibility(View.GONE);
no_auth.setVisibility(View.GONE);
}else{
} else {
auth_box.setVisibility(View.GONE);
no_auth.setVisibility(View.VISIBLE);
}
@ -290,12 +293,19 @@ public class MyFragment extends BaseFragment {
}
@Subscribe
public void processResult(VehicleEvent event) {
Log.e("-msg-",event.getMessage());
if(!"".equals(event.getMessage())) {
public void processResult(VehicleEvent event) {
Log.e("-msg-", event.getMessage());
if (!"".equals(event.getMessage())) {
ur.vehicleList("1");
}
}
@Subscribe
public void refreshCarListEvent(RefreshCarListEvent event) {
Log.e("-msg-", event.getMessage());
ur.vehicleList("1");
}
@Subscribe
public void personResult(PersonEvent home) {
Log.e("-res-", home.getMessage());