| | |
| | | package com.dayu.pipirrapp.activity; |
| | | |
| | | import android.app.NotificationManager; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | |
| | | import androidx.activity.result.ActivityResultLauncher; |
| | | import androidx.activity.result.contract.ActivityResultContracts; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.core.content.res.ResourcesCompat; |
| | | import androidx.recyclerview.widget.GridLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import androidx.recyclerview.widget.SimpleItemAnimator; |
| | |
| | | import com.dayu.pipirrapp.MyApplication; |
| | | import com.dayu.pipirrapp.R; |
| | | import com.dayu.pipirrapp.adapter.ImageAdapter; |
| | | import com.dayu.pipirrapp.bean.ImageBean; |
| | | import com.dayu.pipirrapp.bean.net.DealDetailResult; |
| | | import com.dayu.pipirrapp.bean.net.ImageResult; |
| | | import com.dayu.pipirrapp.bean.net.OrderDetailResult; |
| | | import com.dayu.pipirrapp.bean.net.UplodFileState; |
| | | import com.dayu.pipirrapp.databinding.ActivityOrderDetailBinding; |
| | | import com.dayu.pipirrapp.fragment.OrderFragment; |
| | | import com.dayu.pipirrapp.net.ApiManager; |
| | | import com.dayu.pipirrapp.net.BaseResponse; |
| | | import com.dayu.pipirrapp.net.Constants; |
| | | import com.dayu.pipirrapp.net.subscribers.SubscriberListener; |
| | | import com.dayu.pipirrapp.tool.BigimageUtils; |
| | | import com.dayu.pipirrapp.tool.FullyGridLayoutManager; |
| | | import com.dayu.pipirrapp.utils.CommonKeyName; |
| | | import com.dayu.pipirrapp.utils.ToastUtil; |
| | | import com.dayu.pipirrapp.view.ConfirmDialog; |
| | | import com.dayu.pipirrapp.view.TitleBar; |
| | | import com.jeremyliao.liveeventbus.LiveEventBus; |
| | | import com.luck.picture.lib.decoration.GridSpacingItemDecoration; |
| | | import com.luck.picture.lib.utils.DensityUtil; |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import cc.shinichi.library.ImagePreview; |
| | | import cc.shinichi.library.bean.ImageInfo; |
| | | import cc.shinichi.library.bean.Type; |
| | | |
| | | /** |
| | | * OrderDetailActivity - |
| | |
| | | String workOrderId; |
| | | String proResultId; |
| | | ImageAdapter mAdapter; |
| | | List<ImageResult> images = new ArrayList<>(); |
| | | List<ImageBean> images = new ArrayList<>(); |
| | | RecyclerView mRecyclerView; |
| | | final List<String> imageInfoList = new ArrayList<>(); |
| | | List<ImageInfo> imageInfoList = new ArrayList<>(); |
| | | int ProResultStateId; |
| | | private ActivityResultLauncher<Intent> activityResultLauncher = |
| | | registerForActivityResult( |
| | |
| | | super.onCreate(savedInstanceState); |
| | | binding = ActivityOrderDetailBinding.inflate(LayoutInflater.from(this)); |
| | | setContentView(binding.getRoot()); |
| | | |
| | | new TitleBar(this).setTitleText("工单详情").setLeftIco().setLeftIcoListening(v -> OrderDetailActivity.this.finish()); |
| | | initView(); |
| | | getData(this.getIntent()); |
| | | } |
| | | |
| | | void initView() { |
| | | workOrderId = this.getIntent().getStringExtra("workOrderId"); |
| | | @Override |
| | | protected void onNewIntent(Intent intent) { |
| | | super.onNewIntent(intent); |
| | | getData(intent); |
| | | } |
| | | |
| | | private void getData(Intent intent) { |
| | | |
| | | workOrderId = intent.getStringExtra("workOrderId"); |
| | | NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); |
| | | notificationManager.cancel(workOrderId.hashCode()); |
| | | if (this.getIntent().hasExtra("proResultId")) { |
| | | binding.orderDealLL.setVisibility(View.VISIBLE); |
| | | proResultId = this.getIntent().getStringExtra("proResultId"); |
| | |
| | | this.finish(); |
| | | ToastUtil.showToastLong(this, "当前workOrderId为空"); |
| | | } |
| | | } |
| | | |
| | | |
| | | void initView() { |
| | | binding.setItemclidk(OrderDetailActivity.this); |
| | | |
| | | mRecyclerView = binding.recyclerView; |
| | | FullyGridLayoutManager manager = new FullyGridLayoutManager(this, 4, GridLayoutManager.VERTICAL, false); |
| | | mRecyclerView.setLayoutManager(manager); |
| | |
| | | // 添加间距装饰,确保图片有合适的间隔 |
| | | mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(4, DensityUtil.dip2px(this, 8), false)); |
| | | mAdapter = new ImageAdapter(this, images, (v, position) -> { |
| | | ImagePreview.getInstance().setContext(OrderDetailActivity.this).setImageList(imageInfoList).start(); |
| | | BigimageUtils.showImages(this, position, imageInfoList); |
| | | |
| | | }); |
| | | mRecyclerView.setAdapter(mAdapter); |
| | |
| | | @Override |
| | | public void onNext(BaseResponse<OrderDetailResult> t) { |
| | | if (t.isSuccess()) { |
| | | if (t.isSuccess()) { |
| | | if (t.getContent() != null) { |
| | | OrderDetailResult orderDetailResult = t.getContent(); |
| | | binding.setData(orderDetailResult); |
| | | if (!TextUtils.isEmpty(t.getContent().getProResultId()) && TextUtils.isEmpty(proResultId)) { |
| | | getHandleData(orderDetailResult.getProResultId()); |
| | | } |
| | | ProResultStateId = orderDetailResult.getProResultStateId(); |
| | | switch (ProResultStateId) { |
| | | case 0://未上报 |
| | | binding.stateText.setTextColor(OrderDetailActivity.this.getResources().getColor(R.color.black)); |
| | | binding.stateText.setBackground(OrderDetailActivity.this.getResources().getDrawable(R.drawable.order_state_no_bg)); |
| | | binding.dealButton.setBackgroundColor(getResources().getColor(R.color.title_color)); |
| | | binding.dealButton.setVisibility(View.VISIBLE); |
| | | break; |
| | | case 1://已上报 |
| | | binding.stateText.setTextColor(OrderDetailActivity.this.getResources().getColor(R.color.white)); |
| | | binding.stateText.setBackground(OrderDetailActivity.this.getResources().getDrawable(R.drawable.order_state_wait_bg)); |
| | | binding.dealButton.setBackgroundColor(getResources().getColor(R.color.delete_color)); |
| | | binding.dealButton.setVisibility(View.VISIBLE); |
| | | binding.dealButton.setText("删除处理结果"); |
| | | break; |
| | | case 2://已完成 |
| | | binding.stateText.setTextColor(OrderDetailActivity.this.getResources().getColor(R.color.white)); |
| | | binding.stateText.setBackground(OrderDetailActivity.this.getResources().getDrawable(R.drawable.order_state_finish_bg)); |
| | | binding.dealButton.setVisibility(View.GONE); |
| | | break; |
| | | case 3://被驳回 |
| | | binding.stateText.setTextColor(OrderDetailActivity.this.getResources().getColor(R.color.white)); |
| | | binding.stateText.setBackground(OrderDetailActivity.this.getResources().getDrawable(R.drawable.order_state_reject_bg)); |
| | | binding.dealButton.setBackgroundColor(getResources().getColor(R.color.title_color)); |
| | | binding.dealButton.setVisibility(View.VISIBLE); |
| | | break; |
| | | |
| | | } |
| | | } else { |
| | | ToastUtil.showToast(OrderDetailActivity.this, t.getMsg()); |
| | | LiveEventBus.get(CommonKeyName.RedLotRefresh).post(workOrderId); |
| | | if (t.getContent() != null) { |
| | | OrderDetailResult orderDetailResult = t.getContent(); |
| | | binding.setData(orderDetailResult); |
| | | if (!TextUtils.isEmpty(t.getContent().getProResultId()) && TextUtils.isEmpty(proResultId)) { |
| | | getHandleData(orderDetailResult.getProResultId()); |
| | | } |
| | | ProResultStateId = orderDetailResult.getProResultStateId(); |
| | | switch (ProResultStateId) { |
| | | case 0://未上报 |
| | | binding.stateText.setTextColor(OrderDetailActivity.this.getResources().getColor(R.color.black, null)); |
| | | binding.stateText.setBackground(ResourcesCompat.getDrawable(OrderDetailActivity.this.getResources(), R.drawable.order_state_no_bg, null)); |
| | | binding.dealButton.setBackgroundColor(getResources().getColor(R.color.title_color, null)); |
| | | binding.dealButton.setVisibility(View.VISIBLE); |
| | | break; |
| | | case 1://已上报 |
| | | binding.stateText.setTextColor(OrderDetailActivity.this.getResources().getColor(R.color.white, null)); |
| | | binding.stateText.setBackground(ResourcesCompat.getDrawable(OrderDetailActivity.this.getResources(), R.drawable.order_state_wait_bg, null)); |
| | | binding.dealButton.setBackgroundColor(getResources().getColor(R.color.delete_color, null)); |
| | | binding.dealButton.setVisibility(View.VISIBLE); |
| | | binding.dealButton.setText("删除处理结果"); |
| | | break; |
| | | case 2://已完成 |
| | | binding.stateText.setTextColor(OrderDetailActivity.this.getResources().getColor(R.color.white, null)); |
| | | binding.stateText.setBackground(ResourcesCompat.getDrawable(OrderDetailActivity.this.getResources(), R.drawable.order_state_finish_bg, null)); |
| | | binding.dealButton.setVisibility(View.GONE); |
| | | break; |
| | | case 3://被驳回 |
| | | binding.stateText.setTextColor(OrderDetailActivity.this.getResources().getColor(R.color.white, null)); |
| | | binding.stateText.setBackground(ResourcesCompat.getDrawable(OrderDetailActivity.this.getResources(), R.drawable.order_state_reject_bg, null)); |
| | | binding.dealButton.setBackgroundColor(getResources().getColor(R.color.title_color)); |
| | | binding.dealButton.setVisibility(View.VISIBLE); |
| | | break; |
| | | |
| | | } |
| | | } else { |
| | | ToastUtil.showToast(OrderDetailActivity.this, t.getMsg()); |
| | | } |
| | | } else if (t.DATA_NULL.equals(t.getCode())) { |
| | | //工单已被删除 |
| | | ToastUtil.showToast(OrderDetailActivity.this, "订单已被删除!"); |
| | | setResult(OrderFragment.RESULT_REFRESH); |
| | | OrderDetailActivity.this.finish(); |
| | | |
| | | } else { |
| | | |
| | | ToastUtil.showToast(OrderDetailActivity.this, t.getMsg()); |
| | | OrderDetailActivity.this.finish(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | super.onCloose(); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(Throwable e) { |
| | | super.onError(e); |
| | | ToastUtil.showToastLong(OrderDetailActivity.this, "获取详情失败,请稍后再试"); |
| | | OrderDetailActivity.this.finish(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | if (t.getContent() != null) { |
| | | binding.orderDealLL.setVisibility(View.VISIBLE); |
| | | binding.setDealData(t.getContent()); |
| | | images.addAll(t.getContent().getImages()); |
| | | for (ImageResult imageResult : images) { |
| | | imageInfoList.add(imageResult.getWebPath()); |
| | | |
| | | if (!t.getContent().getImages().isEmpty()){ |
| | | for (ImageResult imageResult:t.getContent().getImages()){ |
| | | ImageBean imageBean = new ImageBean(); |
| | | imageBean.setId(imageResult.getId()); |
| | | imageBean.setWebPath(imageResult.getWebPathZip()); |
| | | imageBean.setType(UplodFileState.IMG_TYPE); |
| | | images.add(imageBean); |
| | | ImageInfo info = new ImageInfo(); |
| | | info.setOriginUrl(imageResult.getWebPath()); |
| | | info.setType(Type.IMAGE); |
| | | if (imageResult.getWebPathZip()!=null){ |
| | | info.setThumbnailUrl(imageResult.getWebPathZip()); |
| | | } |
| | | |
| | | imageInfoList.add(info); |
| | | } |
| | | } |
| | | if (!t.getContent().getVideos().isEmpty()){ |
| | | for (ImageResult imageResult:t.getContent().getVideos()){ |
| | | ImageBean imageBean = new ImageBean(); |
| | | imageBean.setId(imageResult.getId()); |
| | | imageBean.setWebPath(imageResult.getWebPathZip()); |
| | | imageBean.setType(UplodFileState.VIDEO_TYPE); |
| | | images.add(imageBean); |
| | | ImageInfo info = new ImageInfo(); |
| | | info.setOriginUrl(imageResult.getWebPath()); |
| | | info.setThumbnailUrl(imageResult.getWebPath()); |
| | | if (imageResult.getWebPathZip()!=null){ |
| | | info.setThumbnailUrl(imageResult.getWebPathZip()); |
| | | } |
| | | info.setType(Type.VIDEO); |
| | | imageInfoList.add(info); |
| | | } |
| | | } |
| | | mAdapter.notifyDataSetChanged(); |
| | | } else { |