本文整理汇总了Java中com.contentful.java.cda.CDACallback类的典型用法代码示例。如果您正苦于以下问题:Java CDACallback类的具体用法?Java CDACallback怎么用?Java CDACallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CDACallback类属于com.contentful.java.cda包,在下文中一共展示了CDACallback类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cancel
import com.contentful.java.cda.CDACallback; //导入依赖的package包/类
public void cancel(String tag) {
synchronized (lock) {
HashSet<CDACallback> set = tags.get(tag);
if (set != null) {
for (CDACallback callback : set) {
callback.cancel();
}
data.removeAll(set);
set.clear();
}
tags.remove(tag);
}
}
示例2: loadData
import com.contentful.java.cda.CDACallback; //导入依赖的package包/类
private void loadData() {
emptyView.setVisibility(View.VISIBLE);
callbacks.add(CFDiscoveryClient.getClient()
.fetch(CDAEntry.class)
.one(getString(R.string.discovery_space_entry_id), new CDACallback<CDAEntry>() {
@Override
@SuppressWarnings("unchecked")
protected void onSuccess(CDAEntry entry) {
insertTitle((String) entry.getField("title"));
//noinspection unchecked
for (CDAResource helpItem : (List<CDAResource>) entry.getField("helpItems")) {
insertHelpItem((CDAEntry) helpItem);
}
emptyView.setVisibility(View.GONE);
container.setVisibility(View.VISIBLE);
}
}));
}
示例3: fetchNyancatEntryAsync
import com.contentful.java.cda.CDACallback; //导入依赖的package包/类
@Test
public void fetchNyancatEntryAsync() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final CDAEntry[] result = {null};
client.fetch(CDAEntry.class).one("nyancat", new CDACallback<CDAEntry>() {
@Override protected void onSuccess(CDAEntry entry) {
result[0] = entry;
latch.countDown();
}
@Override protected void onFailure(Throwable error) {
latch.countDown();
}
});
latch.await(1, TimeUnit.SECONDS);
assertThat(result[0]).isNotNull();
assertNyanCat(result[0]);
}
示例4: add
import com.contentful.java.cda.CDACallback; //导入依赖的package包/类
public <T extends CDACallback> T add(T callback) {
synchronized (lock) {
data.add(callback);
}
return callback;
}
示例5: cancelAndClear
import com.contentful.java.cda.CDACallback; //导入依赖的package包/类
public void cancelAndClear() {
synchronized (lock) {
for (CDACallback cb : data) {
cb.cancel();
}
data.clear();
tags.clear();
}
}
示例6: login
import com.contentful.java.cda.CDACallback; //导入依赖的package包/类
/**
* Attempts to log in to {@code Space}, given a set of {@code Credentials}.
*
* @param credentials {@code Credentials} instance.
*/
private void login(final Credentials credentials) {
// ProgressDialog to be displayed while the request is carried.
final ProgressDialog loginDialog = ProgressDialog.show(this, getString(R.string.pd_login_title),
getString(R.string.pd_login_message), true, true, new DialogInterface.OnCancelListener() {
@Override public void onCancel(DialogInterface dialog) {
callbacks.cancelAndClear();
}
});
// Initialize client singleton & test our credentials while attempting to fetch
// their corresponding {@link Space}.
// Note that we're adding the CDACallback instance to our callbacks set, case we
// would need to cancel the request in the future (i.e. onDestroy).
CFClient.init(credentials.getSpace(), credentials.getAccessToken());
callbacks.add(CFClient.getClient().fetchSpace(new CDACallback<CDASpace>() {
@Override protected void onSuccess(CDASpace space) {
loginDialog.dismiss();
handleLoginSuccess(space, credentials);
}
@Override protected void onFailure(Throwable error) {
loginDialog.dismiss();
handleLoginFailure(error, credentials);
}
}));
}