• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CDAClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.contentful.java.cda.CDAClient的典型用法代码示例。如果您正苦于以下问题:Java CDAClient类的具体用法?Java CDAClient怎么用?Java CDAClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CDAClient类属于com.contentful.java.cda包,在下文中一共展示了CDAClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: requestModels

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
public void requestModels() {
  final CDAClient client = CDAClient.builder()
      .setSpace(VRSpace.SPACE_ID)
      .setToken(VRSpace.ACCESS_TOKEN)
      .build();

  vault.requestSync(client);

  Vault.observeSyncResults()
      .subscribeOn(Schedulers.io())
      .flatMap(new Func1<SyncResult, Observable<Product>>() {
        @Override public Observable<Product> call(SyncResult syncResult) {
          return vault.observe(Product.class).order(Product$Fields.NAME).all();
        }
      })
      .flatMap(new CreateProtoModelAndRenderSign(applicationContext))
      .flatMap(new DownloadMeshAsset(applicationContext))
      .flatMap(new DownloadTextureAsset(applicationContext))
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(new EnqueueProtoModel());
}
 
开发者ID:contentful-labs,项目名称:contentful-cardboard,代码行数:22,代码来源:ContentfulInteractor.java


示例2: get

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
public static CDAClient get() {
  synchronized (LOCK) {
    if (instance == null) {
      // Extract credentials from SharedPreferences
      String spaceId = defaultIfBlank(Preferences.getSpaceId(), Const.SPACE_ID);

      String accessToken = defaultIfBlank(Preferences.getAccessToken(), Const.ACCESS_TOKEN);

      instance = CDAClient.builder()
          .setSpaceKey(spaceId)
          .setAccessToken(accessToken)
          .nullifyUnresolvedLinks()
          .build();
    }

    return instance;
  }
}
 
开发者ID:contentful,项目名称:gallery-app-android,代码行数:19,代码来源:ClientProvider.java


示例3: get

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
public static CDAClient get() {
  synchronized (LOCK) {
    if (instance == null) {
      // Extract credentials from SharedPreferences
      String spaceId = defaultIfBlank(Preferences.getSpaceId(), Const.SPACE_ID);

      String accessToken = defaultIfBlank(Preferences.getAccessToken(), Const.ACCESS_TOKEN);

      instance = CDAClient.builder()
          .setSpace(spaceId)
          .setToken(accessToken)
          .build();
    }

    return instance;
  }
}
 
开发者ID:contentful,项目名称:product-catalogue-android,代码行数:19,代码来源:ClientProvider.java


示例4: SyncConfig

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
private SyncConfig(Builder builder) {
  this.invalidate = builder.invalidate;

  if (builder.client == null) {
    if (builder.accessToken == null) {
      throw new IllegalStateException("Cannot create a CDA client with no access token. " +
          "Please set it.");
    }

    if (builder.spaceId == null) {
      throw new IllegalStateException("Cannot create a CDA client with no space id. " +
          "Please set it.");
    }

    this.client = CDAClient
        .builder()
        .setToken(builder.accessToken)
        .setSpace(builder.spaceId)
        .setIntegration("Vault", PROJECT_VERSION)
        .build();
  } else {
    this.client = builder.client;
  }
}
 
开发者ID:contentful,项目名称:vault,代码行数:25,代码来源:SyncConfig.java


示例5: setClient

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
public Builder setClient(CDAClient client) {
  if (accessToken != null) {
    throw new IllegalStateException(
        "Do not set a client, when an access token is already set. Use either space id and " +
            "a token or a previously created client."
    );
  }
  if (spaceId != null) {
    throw new IllegalStateException(
        "Do not set a client, when a space id is already set. Use either space id and " +
            "a token or a previously created client."
    );
  }

  this.client = client;
  return this;
}
 
开发者ID:contentful,项目名称:vault,代码行数:18,代码来源:SyncConfig.java


示例6: get

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
public static CDAClient get() {
  synchronized (LOCK) {
    if (instance == null) {
      // Extract credentials from SharedPreferences
      String spaceId = defaultIfBlank(Preferences.getSpaceId(), Const.SPACE_ID);

      String accessToken = defaultIfBlank(Preferences.getAccessToken(), Const.ACCESS_TOKEN);

      instance = CDAClient.builder()
          .setSpace(spaceId)
          .setToken(accessToken)
          .build();
    }

    return instance;
  }
}
 
开发者ID:contentful,项目名称:blog-app-android,代码行数:18,代码来源:ClientProvider.java


示例7: getClient

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
public synchronized static CDAClient getClient() {
  if (sInstance == null) {
    SharedPreferences prefs = CFPrefs.getInstance();

    String space = prefs.getString(CFPrefs.KEY_SPACE, null);
    String token = prefs.getString(CFPrefs.KEY_ACCESS_TOKEN, null);

    if (StringUtils.isBlank(space) || StringUtils.isBlank(token)) {
      throw new IllegalStateException("Uninitialized client.");
    }

    return init(space, token);
  }

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


示例8: performLoad

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
@Override protected ResourceList performLoad(CDAClient client) {
  ResourceList resourceList = new ResourceList();

  FetchQuery<CDAEntry> query =
      client.fetch(CDAEntry.class).where("content_type", contentType.id());

  // Set the locale if non-default locale is currently configured
  String locale = CFClient.getLocale();
  if (locale != null) {
    query.where("locale", locale);
  }

  // Make the request
  CDAArray cdaArray = query.all();
  resourceList.resources = new ArrayList<>();

  // Prepare the result
  resourceList.resources.addAll(cdaArray.entries().values());
  return resourceList;
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:21,代码来源:EntriesByContentTypeLoader.java


示例9: createVault

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
private void createVault() {
  if (vault == null) {
    vault = Vault.with(this, EventSpace.class);
    vault.requestSync(CDAClient
        .builder()
        .setToken(EventSpace.DELIVERY_API_KEY)
        .setSpace(EventSpace.SPACE_ID)
        .setCallFactory(createCustomCallFactory())
        .build());
  }
}
 
开发者ID:gdg-berlin-android,项目名称:gdg-events-app,代码行数:12,代码来源:MainActivity.java


示例10: setupClient

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
@Override protected void setupClient() {
  client = CDAClient.builder()
      .setSpace("space")
      .setToken("token")
      .preview()
      .setEndpoint(getServerUrl())
      .build();
}
 
开发者ID:contentful,项目名称:vault,代码行数:9,代码来源:SyncPreviewTest.java


示例11: setupClient

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
protected void setupClient() {
  client = CDAClient.builder()
      .setSpace("space")
      .setToken("token")
      .setEndpoint(getServerUrl())
      .build();
}
 
开发者ID:contentful,项目名称:vault,代码行数:8,代码来源:BaseTest.java


示例12: createsACustomCDAClient

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
@Test
public void createsACustomCDAClient() {
  final SyncConfig syncConfig = SyncConfig
      .builder()
      .setAccessToken("foo")
      .setSpaceId("bar")
      .build();

  final CDAClient client = syncConfig.client();
  assertThat(client).isNotNull();
}
 
开发者ID:contentful,项目名称:vault,代码行数:12,代码来源:VaultTest.java


示例13: getClient

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
public synchronized static CDAClient getClient(Context context) {
  if (client == null) {
    // Create the client
    HashMap<String, Class<?>> classMap = new HashMap<>();
    classMap.put(context.getString(R.string.cda_place_content_type_id), Place.class);

    client = new CDAClient.Builder().setSpaceKey(context.getString(R.string.cda_space_key))
        .setAccessToken(context.getString(R.string.cda_access_token))
        .setCustomClasses(classMap)
        .build();
  }

  return client;
}
 
开发者ID:contentful-graveyard,项目名称:guide-app-android,代码行数:15,代码来源:CFUtils.java


示例14: cda

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
public synchronized static CDAClient cda() {
  if (sClientCda == null) {
    sClientCda = new CDAClient.Builder()
        .setSpaceKey(CFApp.get().getString(R.string.cf_space_id))
        .setAccessToken(CFApp.get().getString(R.string.cf_token_cda))
        .build();
  }
  return sClientCda;
}
 
开发者ID:contentful-graveyard,项目名称:cma-cookies-demo,代码行数:10,代码来源:Clients.java


示例15: init

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
/**
 * Initialize this client.
 *
 * @param space String representing the Space key.
 * @param token String representing the access token required to log in to the Space.
 * @return {@link com.contentful.java.cda.CDAClient} instance.
 */
public synchronized static CDAClient init(String space, String token) {
  SharedPreferences prefs = CFPrefs.getInstance();

  prefs.edit()
      .putString(CFPrefs.KEY_SPACE, space)
      .putString(CFPrefs.KEY_ACCESS_TOKEN, token)
      .apply();

  sInstance = CDAClient.builder().setSpace(space).setToken(token).build();

  locale = null;

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


示例16: getClient

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
public static CDAClient getClient() {
  if (sInstance == null) {
    Context context = CFApp.getInstance();

    sInstance =
        CDAClient.builder().setSpace(context.getString(R.string.discovery_space_key))
            .setToken(context.getString(R.string.discovery_space_token))
            .build();
  }

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


示例17: performLoad

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
@Override protected ResourceList performLoad() {
  CDAClient client = CFClient.getClient();

  try {
    ResourceList tmp = performLoad(client);
    setContentTypes(client, tmp);
    return tmp;
  } catch (RetrofitError e) {
    e.printStackTrace();
  }

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


示例18: setContentTypes

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
protected void setContentTypes(CDAClient client, ResourceList resourceList) throws RetrofitError {
  HashMap<String, CDAContentType> map = new HashMap<>();
  CDAArray array = client.fetch(CDAContentType.class).all();

  for (CDAResource res : array.items()) {
    map.put(res.id(), (CDAContentType) res);
  }

  resourceList.contentTypes = map;
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:11,代码来源:AbsResourceListLoader.java


示例19: performLoad

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
@Override protected ResourceList performLoad(CDAClient client) {
  ResourceList resourceList = new ResourceList();
  resourceList.resources = new ArrayList<>();

  for (Object obj : resources) {
    // Filter out any unresolved Links
    if (obj instanceof CDAResource) {
      resourceList.resources.add((CDAResource) obj);
    }
  }

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


示例20: performLoad

import com.contentful.java.cda.CDAClient; //导入依赖的package包/类
@Override protected ArrayList<ContentTypeWrapper> performLoad() {
  CDAClient client = CFClient.getClient();

  try {
    List<CDAResource> items = client.fetch(CDAContentType.class).all().items();
    ArrayList<ContentTypeWrapper> tmp = new ArrayList<>();

    if (items.size() > 0) {
      for (CDAResource res : items) {
        CDAContentType cdaContentType = (CDAContentType) res;

        // Entries count
        CDAArray entries = client.fetch(CDAEntry.class)
            .where("content_type", cdaContentType.id())
            .where("limit", "1")
            .all();

        ContentTypeWrapper ct = new ContentTypeWrapper(cdaContentType, entries.total());
        tmp.add(ct);
      }
    }

    return tmp;
  } catch (RetrofitError e) {
    e.printStackTrace();
  }

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SetOwnerRequestProto类代码示例发布时间:2022-05-22
下一篇:
Java LocalFlinkMiniCluster类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap