You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mall/com.example.mall.MainActivity}: java.lang.ClassCastException: com.example.mall.MainActivity cannot be cast to me.yokeyword.fragmentation.SupportActivity
abstract class ProxyActivity :
AppCompatActivity(), ISupportActivity {
private lateinit var mDelegate: SupportActivityDelegate
abstract fun setRootFragment(): MallFragment
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mDelegate = SupportActivityDelegate(this)
mDelegate.onCreate(savedInstanceState)
initContainer(savedInstanceState)
}
private fun initContainer(savedInstanceState: Bundle?) {
val container = FrameLayout(this)
container.id = R.id.fragment_container
setContentView(container)
if (savedInstanceState == null) {
mDelegate.loadRootFragment(
R.id.fragment_container,
setRootFragment()
)
}
}
override fun onDestroy() {
mDelegate.onDestroy()
super.onDestroy()
System.gc()
System.runFinalization()
}
override fun getSupportDelegate(): SupportActivityDelegate {
return mDelegate
}
override fun post(runnable: Runnable?) {
mDelegate.post(runnable)
}
override fun extraTransaction(): ExtraTransaction {
return mDelegate.extraTransaction()
}
override fun getFragmentAnimator(): FragmentAnimator {
return mDelegate.fragmentAnimator
}
override fun setFragmentAnimator(fragmentAnimator: FragmentAnimator) {
mDelegate.fragmentAnimator = DefaultHorizontalAnimator()
}
override fun onCreateFragmentAnimator(): FragmentAnimator {
return mDelegate.onCreateFragmentAnimator()
}
override fun onBackPressedSupport() {
mDelegate.onBackPressedSupport()
}
override fun onBackPressed() {
mDelegate.onBackPressed()
}
}
`class MainActivity : ProxyActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportActionBar?.hide()
}
override fun setRootFragment(): MallFragment {
return TestFragment()
}
}`
`abstract class BaseFragment : SupportFragment() {
private lateinit var mRootView: View
abstract fun setLayout(): Any
abstract fun onBindView(savedInstanceState: Bundle?, rootView: View)
fun <T : View> findView(@IdRes viewId: Int): T {
return mRootView.findViewById(viewId)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val rootView: View = when {
setLayout() is Int -> inflater.inflate(setLayout() as Int, container, false)
setLayout() is View -> setLayout() as View
else -> throw ClassCastException("type of setLayout() must be int or view")
}
mRootView = rootView
onBindView(savedInstanceState, rootView)
return rootView
}
}`
`abstract class MallFragment : BaseFragment() {
private var mTouchTime: Long = 0
companion object {
private const val WAIT_TIME = 2000L
}
protected fun exitWithDoubleClick(): Boolean {
if (System.currentTimeMillis() - mTouchTime < WAIT_TIME) {
_mActivity.finish()
} else {
mTouchTime = System.currentTimeMillis()
Toast.makeText(_mActivity, "双击退出", Toast.LENGTH_SHORT).show()
}
return true
}
//关于文件或者Camera权限的内容
}`
The text was updated successfully, but these errors were encountered:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mall/com.example.mall.MainActivity}: java.lang.ClassCastException: com.example.mall.MainActivity cannot be cast to me.yokeyword.fragmentation.SupportActivity
`class MainActivity : ProxyActivity() {
}`
`abstract class BaseFragment : SupportFragment() {
}`
`abstract class MallFragment : BaseFragment() {
}`
The text was updated successfully, but these errors were encountered: