| | |
| | | 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.net.Constants; |
| | | import com.dayu.pipirrapp.net.subscribers.SubscriberListener; |
| | | 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; |
| | | |
| | |
| | | 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); |
| | |
| | | @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(); |
| | | } |
| | | }); |
| | | } |
| | | |