我创建了两个在firebase数据库上写入数据的任务
class EventDataAddingTask implements Continuation<User, Task<Boolean>> {
@Override
public Task<Boolean> then(Task<User> task) {
final TaskCompletionSource<Boolean> tcs = new TaskCompletionSource();
mUserEventsRefrence.child(user.getUid()).setValue(addEditEventData)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
tcs.setResult(true);
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception error) {
tcs.setResult(false);
tcs.setException(error);
}
});
return tcs.getTask();
}
}
class UserPaymentAddingTask implements Continuation<User, Task<Boolean>> {
@Override
public Task<Boolean> then(Task<User> task) {
final TaskCompletionSource<Boolean> tcs = new TaskCompletionSource();
mUserPaymentDetailsRefrence.child(user.getUid()).setValue(addEditUserPaymentData)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
tcs.setResult(true);
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception error) {
tcs.setResult(false);
tcs.setException(error);
}
});
return tcs.getTask();
}
}
我不知道如何运行这两项任务,以便在一项任务完成后自动运行并在两项任务成功完成时向用户显示消息