本文整理汇总了Java中com.contentful.java.cda.CDAEntry.getField方法的典型用法代码示例。如果您正苦于以下问题:Java CDAEntry.getField方法的具体用法?Java CDAEntry.getField怎么用?Java CDAEntry.getField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.contentful.java.cda.CDAEntry
的用法示例。
在下文中一共展示了CDAEntry.getField方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processArray
import com.contentful.java.cda.CDAEntry; //导入方法依赖的package包/类
private void processArray(CDAEntry entry, AutoEscapeValues values, FieldMeta field) {
if (field.isArrayOfSymbols()) {
List<?> list = entry.getField(field.id());
if (list == null) {
list = Collections.emptyList();
}
saveBlob(entry, values, field, (Serializable) list);
} else {
List<?> links = extractRawFieldValue(entry, field.id());
if (links != null) {
for (int i = 0; i < links.size(); i++) {
processLink(entry, field.id(), (Map<?, ?>) links.get(i), i);
}
}
}
}
示例2: insertHelpItem
import com.contentful.java.cda.CDAEntry; //导入方法依赖的package包/类
private void insertHelpItem(CDAEntry helpItemEntry) {
HelpItemViewHolder vh =
new HelpItemViewHolder(View.inflate(this, R.layout.view_help_item, null));
// Text
vh.tvText.setText((String) helpItemEntry.getField("text"));
// Image
CDAAsset asset = helpItemEntry.getField("image");
Picasso.with(this).load("http:" + asset.url())
.fit()
.centerInside()
.into(vh.ivPhoto);
container.addView(vh.rootView);
}
示例3: sync
import com.contentful.java.cda.CDAEntry; //导入方法依赖的package包/类
@Test
public void sync() throws Exception {
SynchronizedSpace space = client.sync().observe().blockingFirst();
assertInitial(space);
space = client.sync(space).observe().blockingFirst();
assertThat(space.nextSyncUrl()).isNotEmpty();
assertThat(space.items()).hasSize(14);
assertThat(space.deletedEntries()).hasSize(0);
CDAEntry nyanCat = space.entries().get("nyancat");
assertThat(nyanCat).isNotNull();
assertThat(nyanCat.getField("name")).isEqualTo("Nyan vIghro'");
assertThat(nyanCat.getField("color")).isEqualTo("rainbow");
List<String> likes = nyanCat.getField("likes");
assertThat(likes).containsExactly("rainbows", "fish");
}
示例4: assertNyanCat
import com.contentful.java.cda.CDAEntry; //导入方法依赖的package包/类
private void assertNyanCat(CDAEntry entry) {
assertThat(entry.id()).isEqualTo("nyancat");
assertThat(entry.getField("name")).isEqualTo("Nyan Cat");
assertThat(entry.getField("color")).isEqualTo("rainbow");
assertThat(entry.getField("birthday")).isEqualTo("2011-04-04T22:00:00+00:00");
assertThat(entry.getField("lives")).isEqualTo(1337.0);
List<String> likes = entry.getField("likes");
assertThat(likes).containsExactly("rainbows", "fish");
Object bestFriend = entry.getField("bestFriend");
assertThat(bestFriend).isInstanceOf(CDAEntry.class);
assertThat(entry).isSameAs(((CDAEntry) bestFriend).getField("bestFriend"));
// Localization
assertThat(entry.locale()).isEqualTo("en-US");
entry.setLocale("tlh");
assertThat(entry.getField("color")).isEqualTo("rainbow");
assertThat(entry.getField("non-existing-does-not-throw")).isNull();
}
示例5: getTitleForEntry
import com.contentful.java.cda.CDAEntry; //导入方法依赖的package包/类
public static String getTitleForEntry(CDAEntry entry, CDAContentType contentType) {
String displayField = contentType.displayField();
if (!StringUtils.isBlank(displayField)) {
String result = entry.getField(displayField);
if (StringUtils.isNotBlank(result)) {
return result;
}
}
return CFApp.getInstance().getString(R.string.content_type_default_title);
}
示例6: performLoad
import com.contentful.java.cda.CDAEntry; //导入方法依赖的package包/类
@Override protected Tutorial performLoad() {
try {
Tutorial tmp = new Tutorial();
CDAEntry entry = CFDiscoveryClient.getClient().fetch(CDAEntry.class)
.one(CFApp.getInstance().getResources().getString(R.string.discovery_space_tutorial_id));
CDAAsset bgAsset = entry.getField("backgroundImageIPad");
// Background image
tmp.backgroundImageUrl = "http:" + bgAsset.url();
// Pages
tmp.pages = new ArrayList<>();
ArrayList<?> pages = entry.getField("pages");
for (Object p : pages) {
if (p instanceof CDAEntry) {
CDAEntry pageEntry = (CDAEntry) p;
tmp.pages.add(getPageForEntry(pageEntry));
}
}
return tmp;
} catch (RetrofitError e) {
e.printStackTrace();
}
return null;
}
示例7: getPageForEntry
import com.contentful.java.cda.CDAEntry; //导入方法依赖的package包/类
private static Tutorial.Page getPageForEntry(CDAEntry entry) {
Tutorial.Page page = new Tutorial.Page();
page.headline = entry.getField("headline");
page.content = entry.getField("content");
page.asset = entry.getField("asset");
return page;
}