|  | @@ -36,6 +36,7 @@ class FragmentOrderList private constructor(private val pumpId: Int) : FragmentB
 | 
	
		
			
				|  |  |      private val orderList = arrayListOf<DeviceClass>()
 | 
	
		
			
				|  |  |      private val orderListAfterFilter = arrayListOf<DeviceClass>()
 | 
	
		
			
				|  |  |      private val orderListAdapter = OrderListAdapter(if (pumpId != -1) orderList else orderListAfterFilter, this::selectOrder)
 | 
	
		
			
				|  |  | +    private var selectedPosition: Int? = null
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private var selectedName = ""
 | 
	
		
			
				|  |  |      private val oilNameList = FusionManager.pumpList.map { it.oilName }.filter { it.isNotBlank() }
 | 
	
	
		
			
				|  | @@ -71,22 +72,40 @@ class FragmentOrderList private constructor(private val pumpId: Int) : FragmentB
 | 
	
		
			
				|  |  |              setToolBar(binding.fragmentToolbar)
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        // Adapter has to update if dc is changed in FragmentPayType and route back.
 | 
	
		
			
				|  |  | +        selectedPosition?.let { orderListAdapter.notifyItemChanged(it) }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          return binding.root
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private fun selectOrder(dc: DeviceClass) {
 | 
	
		
			
				|  |  | +    private fun selectOrder(dc: DeviceClass, type: Int, position: Int) {
 | 
	
		
			
				|  |  |          lifecycleScope.launch {
 | 
	
		
			
				|  |  |              when {
 | 
	
		
			
				|  |  |                  dc.releaseTokenElement == null || dc.releaseTokenAttribute == null -> {
 | 
	
		
			
				|  |  |                      DFSToastUtil.fail(R.string.wrong_order_info)
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                else -> {
 | 
	
		
			
				|  |  | +                type == 0 -> {
 | 
	
		
			
				|  |  |                      if (dc.isLock && !SPUtil.isLockByThis(dc)) {
 | 
	
		
			
				|  |  |                          DFSToastUtil.warn(R.string.order_lock_by_other)
 | 
	
		
			
				|  |  |                      } else {
 | 
	
		
			
				|  |  | +                        selectedPosition = position
 | 
	
		
			
				|  |  |                          (activity as MainActivity).setFragment(FragmentPayType.build(dc), true)
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | +                type == 1 && dc.isLock -> {
 | 
	
		
			
				|  |  | +                    if (SPUtil.isLockByThis(dc)) {
 | 
	
		
			
				|  |  | +                        val result = FusionManager.lockOrder(dc, false)
 | 
	
		
			
				|  |  | +                        if (result.success) {
 | 
	
		
			
				|  |  | +                            dc.state = "Payable"
 | 
	
		
			
				|  |  | +                            orderListAdapter.notifyItemChanged(position)
 | 
	
		
			
				|  |  | +                            DFSToastUtil.success(R.string.unlock_order_success)
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            DFSToastUtil.fail(R.string.fail_unlock_order)
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        DFSToastUtil.warn(R.string.cant_unlock_others)
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 |