本文整理汇总了Java中org.jdeferred.Deferred.resolve方法的典型用法代码示例。如果您正苦于以下问题:Java Deferred.resolve方法的具体用法?Java Deferred.resolve怎么用?Java Deferred.resolve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdeferred.Deferred
的用法示例。
在下文中一共展示了Deferred.resolve方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changePassword
import org.jdeferred.Deferred; //导入方法依赖的package包/类
@Override
public Promise<Void, BError, Void> changePassword(String email, String oldPassword, String newPassword){
final Deferred<Void, BError, Void> deferred = new DeferredObject<>();
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
OnCompleteListener<Void> resultHandler = new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
deferred.resolve(null);
} else {
deferred.reject(getFirebaseError(DatabaseError.fromException(task.getException())));
}
}
};
user.updatePassword(newPassword).addOnCompleteListener(resultHandler);
return deferred.promise();
}
示例2: sendPasswordResetMail
import org.jdeferred.Deferred; //导入方法依赖的package包/类
@Override
public Promise<Void, BError, Void> sendPasswordResetMail(String email){
final Deferred<Void, BError, Void> deferred = new DeferredObject<>();
OnCompleteListener<Void> resultHandler = new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
if(DEBUG) Timber.v("Email sent");
deferred.resolve(null);
} else {
deferred.reject(getFirebaseError(DatabaseError.fromException(task.getException())));
}
}
};
FirebaseAuth.getInstance().sendPasswordResetEmail(email).addOnCompleteListener(resultHandler);
return deferred.promise();
}
示例3: handleMessage
import org.jdeferred.Deferred; //导入方法依赖的package包/类
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what){
case 1:
MessageObj obj = (MessageObj) msg.obj;
if (obj.listener instanceof Deferred)
{
Deferred<Object, BError, Void> deferred= ((DeferredObject) obj.listener);
if (msg.arg1 == ERROR)
deferred.reject((BError) obj.data);
else deferred.resolve(obj.data);
}
}
}
示例4: resolveAll
import org.jdeferred.Deferred; //导入方法依赖的package包/类
public static <R> void resolveAll(List<R> result, List<Deferred> deferreds) {
Preconditions.checkArgument(result.size() == deferreds.size());
for (int i = 0; i < result.size(); i++) {
Deferred deferred = deferreds.get(i);
R ret = result.get(i);
deferred.resolve(ret);
}
}