YoKeyword / Fragmentation

[DEPRECATED] A powerful library that manage Fragment for Android
Apache License 2.0
9.72k stars 2.11k forks source link

1.3.7版本之后使用自定义Activity实现ISupportActivity问题 #1199

Open jeonhei opened 5 years ago

jeonhei commented 5 years ago

最近更新到了1.3.7的版本 之前使用开的继承了自定义SupportActivity的页面通通报 java.lang.ClassCastException: xxx cannot be cast to me.yokeyword.fragmentation.SupportActivity

看了下源码发现是SupportFragment的onAttach里加上了强制转换语句报错的 @Override public void onAttach(Activity activity) { super.onAttach(activity); mDelegate.onAttach(activity); _mActivity = (SupportActivity) mDelegate.getActivity(); }

不明白作者为什么这么做 求解决

cocowobo commented 5 years ago

因为好多逻辑都是配合SupportActivity才可以完成,并且确实本库的activity 的基类扩展性差了点,作者也好久不管这个了,如果谁有精力,其实可以吧SupportActivity的逻辑封装扩展,让使用者不必去继承SupportActivity,这是本库确实存在的不足

JantHsueh commented 4 years ago

解决方法,详见 https://github.com/JantHsueh/Fragmentation/issues/1