hanks-zyh / hanks-zyh/HTextView
Working bad with Fragments
- Dominant language
- Java
- Stars
- 5.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
I really like this library but it works really bad with fragments, especially with fragments inside ViewPager.
For instance, we must use handler and postDelayed to delay animation until fragment transition is completed, but it constantly fails with error
**java.lang.NullPointerException: Attempt to invoke virtual method 'float android.text.Layout.getLineLeft(int)' on a null object reference**
**java.lang.IllegalStateException: Fragment SomeFragment{xxxxx} not attached to a context.**
due to fragment lifecycle and missing activity context.
I tried to use Handler as instance variable and remove handler callbacks when fragment is detached but same thing happens every time.
It looks like impossible mission to use it properly without destabilizing the whole app.
Any idea how to use it in smart way inside fragments?
Imagining that we need postDelayed to use something provided in library is really bad approach. You should handle that inside of library and not force users to handle manually.
It works good in activities.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.