Commit 7a99f04f by pye52

修复指令无法识别时可能导致的npe

parent 9f24575a
......@@ -274,9 +274,14 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
reset();
runningCommand = command;
runningRequest = commandViewModel.getCommandWorker(command);
if (runningRequest == null) {
LogUtils.w(TAG, "该指令无法识别: " + command.toString());
commandViewModel.commandFinish(command);
return;
}
runningCommand = command;
workManager.beginUniqueWork(WORKER_NAME, ExistingWorkPolicy.REPLACE, runningRequest)
.enqueue();
runningLiveData = workManager.getWorkInfoByIdLiveData(runningRequest.getId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment