本文整理汇总了Java中org.jdeferred.android.AndroidDeferredManager类的典型用法代码示例。如果您正苦于以下问题:Java AndroidDeferredManager类的具体用法?Java AndroidDeferredManager怎么用?Java AndroidDeferredManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AndroidDeferredManager类属于org.jdeferred.android包,在下文中一共展示了AndroidDeferredManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createProfile
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void createProfile() {
AndroidDeferredManager manager = new AndroidDeferredManager();
manager.when(new DeferredAsyncTask<Void, Object, CreateProfileResponse>() {
@Override
protected CreateProfileResponse doInBackgroundSafe(Void... voids) throws Exception {
// Support en-us or zh-CN.
return client.createProfile("en-US");
}
}).done(response -> {
Log.d(TAG, "Succeeded to create profile. IdentificationProfileId:" + response.verificationProfileId);
fetchProfiles();
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable throwable) {
Log.e(TAG, "Failed to fetch user profiles.", throwable);
Toast.makeText(getContext(), "Failed.", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:27,代码来源:ProfileListFragment.java
示例2: createProfile
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void createProfile() {
AndroidDeferredManager manager = new AndroidDeferredManager();
manager.when(new DeferredAsyncTask<Void, Object, CreateProfileResponse>() {
@Override
protected CreateProfileResponse doInBackgroundSafe(Void... voids) throws Exception {
// Support en-us or zh-CN.
return client.createProfile("en-us");
}
}).done(response -> {
Log.d(TAG, "Succeeded to create profile. IdentificationProfileId:" + response.identificationProfileId);
fetchProfiles();
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable throwable) {
Log.e(TAG, "Failed to fetch user profiles.", throwable);
Toast.makeText(getContext(), "Failed.", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:27,代码来源:ProfileListFragment.java
示例3: onActivityCreated
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getActivity().setTitle(getString(R.string.title_register_audio));
remainingEnrollmentsTextView.setText("Remaining enrollments count: " + String.valueOf(remainingEnrollmentsCount));
AndroidDeferredManager manager = new AndroidDeferredManager();
manager.when(new DeferredAsyncTask<Void, Object, List<VerificationPhrase>>() {
@Override
protected List<VerificationPhrase> doInBackgroundSafe(Void... voids) throws Exception {
return client.getPhrases("en-US");
}
}).done(results -> {
StringBuilder builder = new StringBuilder();
builder.append("Phrases is below. You must speech one of the phrases.");
builder.append("\n\n");
for (VerificationPhrase result : results) {
builder.append(result.phrase);
builder.append("\n\n");
}
phraseTextView.setText(builder.toString());
Log.d(TAG, builder.toString());
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable e) {
Log.e(TAG, "Failed to fetch phrase.", e);
Toast.makeText(getContext(), "Failed.", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:40,代码来源:AudioRegisterFragment.java
示例4: registerAudio
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void registerAudio() {
String filePath = FileHelper.getFilename(verificationProfileId);
AndroidDeferredManager manager = new AndroidDeferredManager();
manager
.when(new DeferredAsyncTask<Void, Object, Enrollment>() {
@Override
protected Enrollment doInBackgroundSafe(Void... voids) throws Exception {
InputStream inputStream = new FileInputStream(filePath);
return client.enroll(inputStream, UUID.fromString(verificationProfileId));
}
})
.done(enrollment -> {
Log.d(TAG, "remainingEnrollments: " + enrollment.remainingEnrollments);
Log.d(TAG, "phrase: " + enrollment.phrase);
if (enrollment.remainingEnrollments <= 0) {
Toast.makeText(getContext(), "Success.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getContext(), "Remaining enrollments are " + enrollment.remainingEnrollments, Toast.LENGTH_SHORT).show();
}
})
.fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable throwable) {
Log.e(TAG, "Failed to register audio.", throwable);
Toast.makeText(getContext(), "Failed", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:38,代码来源:AudioRegisterFragment.java
示例5: removeProfile
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void removeProfile() {
AndroidDeferredManager deferredManager = new AndroidDeferredManager();
deferredManager.when(new DeferredAsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackgroundSafe(Void... voids) throws Exception {
client.deleteProfile(UUID.fromString(verificationProfileId));
return null;
}
}).done(result -> {
Log.d(TAG, "Success");
Toast.makeText(getContext(), "Success", Toast.LENGTH_SHORT).show();
getActivity().getSupportFragmentManager().popBackStack();
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable e) {
Log.e(TAG, "Failed to remove user profile.", e);
Toast.makeText(getContext(), "Failed", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:28,代码来源:AudioRegisterFragment.java
示例6: fetchProfiles
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void fetchProfiles() {
// jdeferred
// See https://github.com/jdeferred/jdeferred
new AndroidDeferredManager().when(new DeferredAsyncTask<Void, Object, List<Profile>>() {
@Override
protected List<Profile> doInBackgroundSafe(Void... voids) throws Exception {
List<Profile> profiles = client.getProfiles();
// Sort by createdDateTime.
Collections.sort(profiles, (p1, p2) -> p2.createdDateTime.compareTo(p1.createdDateTime));
return profiles;
}
}).done(profiles -> {
for (Profile profile : profiles) {
Log.d(TAG, "verificationProfileId: " + profile.verificationProfileId);
Log.d(TAG, "remainingEnrollmentsCount: " + profile.remainingEnrollmentsCount);
Log.d(TAG, "enrollmentsCount: " + profile.enrollmentsCount);
Log.d(TAG, "locale: " + profile.locale);
Log.d(TAG, "createdDateTime: " + profile.createdDateTime);
Log.d(TAG, "lastActionDateTime: " + profile.lastActionDateTime);
Log.d(TAG, "enrollmentStatus: " + profile.enrollmentStatus);
}
viewModels.clear();
viewModels.addAll(profiles);
recyclerView.getAdapter().notifyDataSetChanged();
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable throwable) {
Log.e(TAG, "Failed to fetch user profiles.", throwable);
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:41,代码来源:ProfileListFragment.java
示例7: fetchPhases
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void fetchPhases() {
new AndroidDeferredManager().when(new DeferredAsyncTask<Void, Object, List<VerificationPhrase>>() {
@Override
protected List<VerificationPhrase> doInBackgroundSafe(Void... voids) throws Exception {
return client.getPhrases("en-US");
}
}).done(results -> {
StringBuilder builder = new StringBuilder();
builder.append("Phrases is below. You must speech one of the phrases.");
builder.append("\n\n");
for (VerificationPhrase result : results) {
builder.append(result.phrase);
builder.append("\n\n");
}
phraseTextView.setText(builder.toString());
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable e) {
Log.e(TAG, "Failed to fetch phrase.", e);
Toast.makeText(getContext(), "Failed.", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:31,代码来源:VerificationFragment.java
示例8: identification
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void identification(List<UUID> identificationProfileIds) {
String path = FileHelper.getFilename("xxx");
AndroidDeferredManager manager = new AndroidDeferredManager();
manager.when(new DeferredAsyncTask<Void, Object, OperationLocation>() {
@Override
protected OperationLocation doInBackgroundSafe(Void... voids) throws Exception {
InputStream inputStream = new FileInputStream(path);
return client.identify(inputStream, identificationProfileIds, true);
}
}).done(location -> {
// Recognition processing does not end immediately, so keep operation location here.
Log.d(TAG, "OperationLocation: " + location.Url);
operationLocation = location;
checkResultButton.setEnabled(true);
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable e) {
Log.e(TAG, "Failed to identify.", e);
Toast.makeText(getContext(), "Failed.", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:30,代码来源:IdentificationFragment.java
示例9: checkResult
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void checkResult() {
AndroidDeferredManager manager = new AndroidDeferredManager();
manager.when(new DeferredAsyncTask<Void, Object, IdentificationOperation>() {
@Override
protected IdentificationOperation doInBackgroundSafe(Void... voids) throws Exception {
return client.checkIdentificationStatus(operationLocation);
}
}).done(operation -> {
Log.d(TAG, "Status: " + operation.status);
if (Status.SUCCEEDED == operation.status) {
Identification identification = operation.processingResult;
Log.d(TAG, "identifiedProfileId: " + identification.identifiedProfileId);
Log.d(TAG, "confidence: " + identification.confidence);
Toast.makeText(getContext(), "You are " + identification.identifiedProfileId, Toast.LENGTH_SHORT).show();
} else {
Log.d(TAG, "Not enrolled yet. Message: " + operation.message);
Toast.makeText(getContext(), operation.message, Toast.LENGTH_SHORT).show();
}
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable e) {
Log.e(TAG, "Failed.", e);
Toast.makeText(getContext(), "Failed.", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:35,代码来源:IdentificationFragment.java
示例10: registerAudio
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void registerAudio(String filePath) {
AndroidDeferredManager manager = new AndroidDeferredManager();
manager
.when(new DeferredAsyncTask<Void, Object, OperationLocation>() {
@Override
protected OperationLocation doInBackgroundSafe(Void... voids) throws Exception {
InputStream inputStream = new FileInputStream(filePath);
return client.enroll(inputStream, UUID.fromString(identificationProfileId), true);
}
})
.done(location -> {
Log.d(TAG, "EnrollmentStatus: " + location.Url);
Toast.makeText(getContext(), "Success.", Toast.LENGTH_SHORT).show();
})
.fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable throwable) {
Log.e(TAG, "Failed to register audio.", throwable);
Toast.makeText(getContext(), "Failed", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:30,代码来源:AudioRegisterFragment.java
示例11: removeProfile
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void removeProfile() {
AndroidDeferredManager deferredManager = new AndroidDeferredManager();
deferredManager.when(new DeferredAsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackgroundSafe(Void... voids) throws Exception {
client.deleteProfile(UUID.fromString(identificationProfileId));
return null;
}
}).done(result -> {
Log.d(TAG, "Success");
Toast.makeText(getContext(), "Success", Toast.LENGTH_SHORT).show();
getActivity().getSupportFragmentManager().popBackStack();
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable e) {
Log.e(TAG, "Failed to remove user profile.", e);
Toast.makeText(getContext(), "Failed", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:28,代码来源:AudioRegisterFragment.java
示例12: fetchProfiles
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void fetchProfiles() {
// jdeferred
// See https://github.com/jdeferred/jdeferred
new AndroidDeferredManager().when(new DeferredAsyncTask<Void, Object, List<Profile>>() {
@Override
protected List<Profile> doInBackgroundSafe(Void... voids) throws Exception {
List<Profile> profiles = client.getProfiles();
// Sort by createdDateTime.
Collections.sort(profiles, (p1, p2) -> p2.createdDateTime.compareTo(p1.createdDateTime));
return profiles;
}
}).done(profiles -> {
for (Profile profile : profiles) {
Log.d(TAG, "identificationProfileId: " + profile.identificationProfileId);
Log.d(TAG, "enrollmentSpeechTime: " + profile.enrollmentSpeechTime);
Log.d(TAG, "remainingEnrollmentSpeechTime: " + profile.remainingEnrollmentSpeechTime);
Log.d(TAG, "locale: " + profile.locale);
Log.d(TAG, "createdDateTime: " + profile.createdDateTime);
Log.d(TAG, "lastActionDateTime: " + profile.lastActionDateTime);
Log.d(TAG, "enrollmentStatus: " + profile.enrollmentStatus);
}
viewModels.clear();
viewModels.addAll(profiles);
recyclerView.getAdapter().notifyDataSetChanged();
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable throwable) {
Log.e(TAG, "Failed to fetch user profiles.", throwable);
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:40,代码来源:ProfileListFragment.java
示例13: execute
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private <T> Promise<T, BletiaException, Void> execute(Action<T, ?> action) {
if(action instanceof CharacteristicAction) {
BluetoothGattCharacteristic characteristic = ((CharacteristicAction) action).getCharacteristic();
if(characteristic != null) return new AndroidDeferredManager().when(mBletia.execute(action));
else return new AndroidDeferredManager().when(action.getDeferred().reject(new BletiaException(action, KonashiErrorType.UNSUPPORTED_OPERATION)).promise());
} else {
return new AndroidDeferredManager().when(mBletia.execute(action));
}
}
开发者ID:YUKAI,项目名称:konashi-android-sdk,代码行数:10,代码来源:KonashiManager.java
示例14: UnivScheduleAppContext
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
public UnivScheduleAppContext()
{
this._deferredManager = new AndroidDeferredManager();
this._client = new UniversityScheduleClient( "testing123" );
this._classesMap = new HashMap<>();
}
开发者ID:mntone,项目名称:UniversityScheduleClient,代码行数:8,代码来源:UnivScheduleAppContext.java
示例15: defer
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
public static AndroidDeferredManager defer() {
return gDM;
}
开发者ID:7763sea,项目名称:VirtualHook,代码行数:4,代码来源:VUiKit.java
示例16: defer
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
protected AndroidDeferredManager defer() {
return VUiKit.defer();
}
开发者ID:7763sea,项目名称:VirtualHook,代码行数:4,代码来源:VActivity.java
示例17: defer
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
protected AndroidDeferredManager defer() {
return VUiKit.defer();
}
开发者ID:7763sea,项目名称:VirtualHook,代码行数:4,代码来源:VFragment.java
示例18: onActivityCreated
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getActivity().setTitle(getString(R.string.title_verification));
new AndroidDeferredManager().when(new DeferredAsyncTask<Void, Object, List<Profile>>() {
@Override
protected List<Profile> doInBackgroundSafe(Void... voids) throws Exception {
List<Profile> profiles = client.getProfiles();
// Sort by createdDateTime.
Collections.sort(profiles, (p1, p2) -> p2.createdDateTime.compareTo(p1.createdDateTime));
return profiles;
}
}).done(profiles -> {
if (profiles == null || profiles.size() == 0) {
Toast.makeText(getContext(), "Please register audio first.", Toast.LENGTH_SHORT).show();
return;
}
List<UUID> ids = new ArrayList<>(profiles.size());
for (Profile profile : profiles) {
ids.add(profile.verificationProfileId);
}
new MaterialDialog.Builder(getContext())
.title("Select speaker")
.content("Select speaker id for verification.")
.items(ids)
.cancelable(false)
.itemsCallbackSingleChoice(-1, (dialog1, itemView, which, text) -> {
verificationProfileId = (String) text;
return true;
})
.show();
fetchPhases();
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable throwable) {
Log.e(TAG, "Failed to fetch user profiles.", throwable);
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:50,代码来源:VerificationFragment.java
示例19: verification
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void verification() {
String path = FileHelper.getFilename(filePath);
AndroidDeferredManager manager = new AndroidDeferredManager();
manager.when(new DeferredAsyncTask<Void, Object, Verification>() {
@Override
protected Verification doInBackgroundSafe(Void... voids) throws Exception {
InputStream inputStream = new FileInputStream(path);
return client.verify(inputStream, UUID.fromString(verificationProfileId));
}
}).done(verification -> {
Result result = verification.result;
if (Result.ACCEPT == result) {
Log.d(TAG, "Verification result: Accept");
Log.d(TAG, "confidence: " + verification.confidence);
Log.d(TAG, "phrase: " + verification.phrase);
Toast.makeText(getContext(), "Accept.", Toast.LENGTH_SHORT).show();
} else {
Log.d(TAG, "Verification result: Reject");
Toast.makeText(getContext(), "Reject.", Toast.LENGTH_SHORT).show();
}
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable e) {
Log.e(TAG, "Failed to identify.", e);
if (e instanceof VerificationException) {
VerificationException exception = (VerificationException) e;
String message = exception.getMessage();
if ("IncompleteEnrollment".equals(message)) {
Toast.makeText(getContext(), "Not enrolled yet. Please register audio.", Toast.LENGTH_SHORT).show();
((MainActivity) getActivity()).showProfileListFragment();
return;
}
}
Toast.makeText(getContext(), "Failed.", Toast.LENGTH_SHORT).show();
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:47,代码来源:VerificationFragment.java
示例20: doIdentification
import org.jdeferred.android.AndroidDeferredManager; //导入依赖的package包/类
private void doIdentification() {
// Fetch enrolled identificationProfileIds.
AndroidDeferredManager manager = new AndroidDeferredManager();
manager.when(new DeferredAsyncTask<Void, Object, List<Profile>>() {
@Override
protected List<Profile> doInBackgroundSafe(Void... voids) throws Exception {
return client.getProfiles();
}
}).done(profiles -> {
List<UUID> identificationProfileIds = new ArrayList<>(profiles.size());
for (Profile profile : profiles) {
Log.d(TAG, "identificationProfileId: " + profile.identificationProfileId);
Log.d(TAG, "enrollmentSpeechTime: " + profile.enrollmentSpeechTime);
Log.d(TAG, "remainingEnrollmentSpeechTime: " + profile.remainingEnrollmentSpeechTime);
Log.d(TAG, "locale: " + profile.locale);
Log.d(TAG, "createdDateTime: " + profile.createdDateTime);
Log.d(TAG, "lastActionDateTime: " + profile.lastActionDateTime);
Log.d(TAG, "enrollmentStatus: " + profile.enrollmentStatus);
if (EnrollmentStatus.ENROLLED == profile.enrollmentStatus) {
identificationProfileIds.add(profile.identificationProfileId);
}
}
if (0 == identificationProfileIds.size()) {
Toast.makeText(getContext(), "Not enrolled profiles.", Toast.LENGTH_SHORT).show();
return;
}
if (10 < identificationProfileIds.size()) {
Log.e(TAG, "A maximum of 10 identificationProfileIds can be included in the request parameter. Please remove profiles.");
Toast.makeText(getContext(), "The identificationProfileIds of the request parameter exceeds 10.", Toast.LENGTH_SHORT).show();
return;
}
// Identification.
identification(identificationProfileIds);
}).fail(new AndroidFailCallback<Throwable>() {
@Override
public void onFail(Throwable throwable) {
Log.e(TAG, "Failed to fetch user profiles.", throwable);
}
@Override
public AndroidExecutionScope getExecutionScope() {
return null;
}
});
}
开发者ID:lakeel-altla,项目名称:samples-cognitive-services-android,代码行数:50,代码来源:IdentificationFragment.java
注:本文中的org.jdeferred.android.AndroidDeferredManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论