Em có 2 đoạn code như sau:
btn_start.setOnClickListener(view -> {
if (txt_cms_address.getText() != null) {
cmsAddress = txt_cms_address.getText().toString();
Log.d(TAG, "CMS" + cmsAddress);
APIRegisterDisplay();
// APISchedule();
// APIGetRequiredFile();
if (checkConnect) {
// APIGetRequiredFile();
// APISchedule();
Log.d(TAG, "check ok");
} else {
Log.d(TAG, "check k ok");
}
} else {
Toast.makeText(this, "Address must not be empty!!", Toast.LENGTH_SHORT).show();
}
});
Với các hàm APIRegisterDisplay(), APIGetRequiredFile(), APISchedule() là các asynchronous để dùng restful api bằng Retrofit2.
checkConnect == true thì tiếp tục chạy 2 hàm APIGetRequiredFile() và APISchedule()
if(checkConnect)if (display != null) ở đoạn code 2, thì hình như nó không chạy.
Mọi người có cách hay keyword nào về xử lí cái này có thể giúp em với ạ.
Em xin cảm ơn.