Android Question What is CSBuilder ?

Semen Matusovskiy

Well-Known Member
Licensed User
Relative @Erel's post: https://www.b4x.com/android/forum/threads/save-and-load-csbuilders.98257/

What I can't understand, why Erel writes "Using this class you can build CharSequences (the output of CSBuilder)".
Earlier, when I read https://www.b4x.com/android/forum/threads/charsequence-csbuilder-tutorial.76226/, I thought that CSBuilder = CharSequence.
But now I see that this is a wrong conclusion.

As I understood, CSBuild implements SpannableStringBuilder. SpannableStringBuilder holds different types, CharSequence is one of them only. Or I am wrong ?

Why I talk about this ...
Personally I want to use CSBuilder with EditText, where user can change a text and formatting.

It seems to me in this case it's necessary to divide SpannableStringBuilder per separate elements. I understand that in general it's not possible to serialize SpannableStringBuilder.
But, for example, CharSequence exactly is serializeable and maybe main spans also. What do you think about this approach ?
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Relative @Erel's post: https://www.b4x.com/android/forum/threads/save-and-load-csbuilders.98257/

What I can't understand, why Erel writes "Using this class you can build CharSequences (the output of CSBuilder)".
Earlier, when I read https://www.b4x.com/android/forum/threads/charsequence-csbuilder-tutorial.76226/, I thought that CSBuilder = CharSequence.
But now I see that this is a wrong conclusion.

As I understood, CSBuild implements SpannableStringBuilder. SpannableStringBuilder holds different types, CharSequence is one of them only. Or I am wrong ?

Why I talk about this ...
Personally I want to use CSBuilder with EditText, where user can change a text and formatting.

It seems to me in this case it's necessary to divide SpannableStringBuilder per separate elements. I understand that in general it's not possible to serialize SpannableStringBuilder.
But, for example, CharSequence exactly is serializeable and maybe main spans also. What do you think about this approach ?

Is CSBuilder serializeable when it involves an EditText holding clickable CSBuilder strings?
I tried withPCSBuilderPlus to serialize to byte array but sofar no success as posted earlier.

RBS
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
CSBuilder holds ClickableSpan. Doubt that it's possible to serialize it, but this is not necessary.
We can save CSBuilder in own format, we only need to understand, which zone is Clickable.
For example, we save as Text1 <Clickable> Text2 <End Of Clickable> Text3. In run-time we can restore formatting.

But to be able to do so, it's necessary to understand internal structure of CSBuild.
I looked https://developer.android.com/reference/android/text/SpannableStringBuilder a little. There are such methods as getSpans, which allow to retrieve a set of spans. Guess, it's possible to do, what we want. But a code will be enough large.
 
Last edited:
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
CSBuilder holds ClickableSpan. Doubt that it's possible to serialize it, but this is not necessary.
We can save CSBuilder in own format, we only need to understand, which zone is Clickable.
For example, we save as Text1 <Clickable> Text2 <End Of Clickable> Text3. In run-time we can restore formatting.

But to be able to do so, it's necessary to understand internal structure of CSBuild.

OK, if I can't serialize my troublesome CSBuilder then I will have to setup a little project that demonstrates the problem.

RBS
 
Upvote 0
Top