Skip to content

Commit

Permalink
Merge branch 'master' into release_merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalniski committed Sep 22, 2022
2 parents a9febe1 + a4a3acf commit 33eda9e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 27 deletions.
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
<p align="center">
🚧🚧🚧🚧🏗️👷🚧🚧👨‍💻🚧🚧👷🏗️🚧🚧🚧🚧<br>
<b>
THIS REPOSITORY IS IN BETA, FEEDBACK WANTED.<br>
EXPECT HEAVY CHANGES AND SUBOPTIMAL VISUAL QUALITY
</b>
<br>
🚧🚧🚧🚧🏗️👷🚧🚧👨‍💻🚧🚧👷🏗️🚧🚧🚧🚧<br>
<br>
<sup>Please create a new issue https://github.com/contentful/rich-text-renderer.java/issues/new for requests.</sup>
</p>

[![](https://jitpack.io/v/contentful/rich-text-renderer-java.svg)](https://jitpack.io/#contentful/rich-text-renderer-java)

Contentful Rich Text Rendering SDK for Java
===========================================
Contentful Rich Text Rendering Library for Java
===============================================

> Java SDK for [Rich Text API](https://www.contentful.com/developers/docs/tutorials/general/rich-text-field-type-alpha/) . It helps in easily rendering rich text stored in Contentful using Java.
> Java library for [Rich Text API](https://www.contentful.com/developers/docs/tutorials/general/rich-text-field-type-alpha/) . It helps in easily rendering rich text stored in Contentful using Java.

What is Contentful?
Expand All @@ -37,7 +27,7 @@ What is Contentful?
Core Features
=============

Take rich text elements from the [BaseSdk](https://github.com/contentful/contentful.java) and render them in a representation easy to use and understand and even easier to use in own projects, due to these submodules:
Take rich text elements from the [base library](https://github.com/contentful/contentful.java) and render them in a representation easy to use and understand and even easier to use in own projects, due to these submodules:

Html
====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public EmbeddedLinkRenderer(@Nonnull AndroidProcessor<CharSequence> processor, @

if (title != null) {
builder.insert(0, title);
builder.setSpan(new ForegroundColorSpan(Color.argb(1.0f, 1.0f, 0.5f, 1.0f)), 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new ForegroundColorSpan(Color.argb(255, 255, 255, 255)), 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
} else if (data instanceof CDAAsset) {
final CDAAsset asset = (CDAAsset) data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -144,10 +143,15 @@ public ListRenderer(@Nonnull AndroidProcessor<CharSequence> processor, @Nonnull
* @return the number of lists of the supported type.
*/
private long getListOfTypeCount(@Nonnull AndroidContext context, CDARichList list) {
return (context.getPath().stream().filter(new Predicate<CDARichNode>() {
@Override public boolean test(CDARichNode x) {
return x instanceof CDARichList && ((CDARichList) x).getDecoration().equals(list.getDecoration());
if (context.getPath() == null) {
return 0;
}
int count = 0;
for (CDARichNode node: context.getPath()) {
if (node instanceof CDARichList && ((CDARichList) node).getDecoration().equals(list.getDecoration())) {
count++;
}
}).count() - 1);
}
return count;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -109,12 +108,24 @@ protected void provideDecoration(@Nonnull AndroidContext context, @Nonnull ViewG
decoration.setText(currentDecorator.decorate(childIndex + 1));
}

/**
* Count lists on the path.
*
* @param context where is the path stored in? The context!
* @param list the list to be listed.
* @return the number of lists of the supported type.
*/
private long getListOfTypeCount(@Nonnull AndroidContext context, CDARichList list) {
return (context.getPath().stream().filter(new Predicate<CDARichNode>() {
@Override public boolean test(CDARichNode x) {
return x instanceof CDARichList && ((CDARichList) x).getDecoration().equals(list.getDecoration());
if (context.getPath() == null) {
return 0;
}
int count = 0;
for (CDARichNode node: context.getPath()) {
if (node instanceof CDARichList && ((CDARichList) node).getDecoration().equals(list.getDecoration())) {
count++;
}
}).count() - 1);
}
return count;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void provide(@Nonnull Processor<HtmlContext, String> processor) {
// needs to be last but one
processor.addRenderer(
(context, node) -> node instanceof CDARichParagraph,
new TagRenderer(processor, "div")
new TagRenderer(processor, "p")
);
}
}

0 comments on commit 33eda9e

Please sign in to comment.