当前位置: 首页>>代码示例>>Java>>正文


Java CDACallback类代码示例

本文整理汇总了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);
  }
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:17,代码来源:CallbackSet.java

示例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);
        }
      }));
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:22,代码来源:HelpActivity.java

示例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]);
}
 
开发者ID:contentful,项目名称:contentful.java,代码行数:21,代码来源:Integration.java

示例4: add

import com.contentful.java.cda.CDACallback; //导入依赖的package包/类
public <T extends CDACallback> T add(T callback) {
  synchronized (lock) {
    data.add(callback);
  }

  return callback;
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:8,代码来源:CallbackSet.java

示例5: cancelAndClear

import com.contentful.java.cda.CDACallback; //导入依赖的package包/类
public void cancelAndClear() {
  synchronized (lock) {
    for (CDACallback cb : data) {
      cb.cancel();
    }

    data.clear();
    tags.clear();
  }
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:11,代码来源:CallbackSet.java

示例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);
    }
  }));
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:33,代码来源:CredentialsActivity.java


注:本文中的com.contentful.java.cda.CDACallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。