mr5 / icarus-android

[DISCONTINUED] Rrich text editor for android platform. 安卓富文本编辑器,暂停维护
MIT License
741 stars 129 forks source link

Get Content Sync...Because Loosing content on Screen Rotate #25

Open AnaxAndrade opened 7 years ago

AnaxAndrade commented 7 years ago

Hi there, first I want to thank you for this project, second is that I am having problems when screen rotates or when I go to another app and come back, mostr of the time the content of the Editor is cleaned (even though it is on a Fragment with setRetainInstance(true) ).

I tried to save the contents on onSaveInstanceState, but since I have to get the content async that isn't a trivial thing to do.

This is an important issue . Thanks in advance

AnaxAndrade commented 7 years ago

@mr5 Any thoughts on this one, please?

mr5 commented 7 years ago

Hi guy, has your problem been resolved? I use webview.loadUrl to execute javascript codes, it can't get the return values from javascript function, so you can't get contents synchronously. You can try to save contents every 500ms. I will research on how to get contents synchronously.

AnaxAndrade commented 7 years ago

Thanks for ansering @mr5 , I can't get it to work yet, and i'm very sad for that since it's really bad for users to rotate the device and loose all progress (this is crucial). But I saw another Editor, the project Wordpress Editor Android (The link takes you to the exact File) they use sort of a CountDownLatch to kind of 'block'the thread for a second and wait for the callback. Look inside the getContent() method. Is that a feasible solution in this project?

mr5 commented 7 years ago

If you approved this way, I think you can try it on onSaveInstanceState: call getContent and await 1 second. But it is unreliable, so I don't want to add a synchronous method in this way.

AnaxAndrade commented 7 years ago

Ok then I didn't study the guts of how this editor works, but I would like to help you fix this. when you have any Ideias on this, tell me!