Я пытаюсь получить доступ к функции класса для моего фрагмента в другом классе, но получил следующую ошибку
07-08 15:22:34.286 13344-13952/com.img.gosuperleauge E/AndroidRuntime: FATAL EXCEPTION: Thread-37
Process: com.img.gosuperleauge, PID: 13344
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6915)
at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1077)
at android.view.View.requestLayout(View.java:19686)
at android.view.ViewGroup.addView(ViewGroup.java:4295)
at android.view.ViewGroup.addView(ViewGroup.java:4237)
at android.view.ViewGroup.addView(ViewGroup.java:4210)
at com.andrognito.flashbar.FlashbarContainerView.show$flashbar_release(FlashbarContainerView.kt:141)
at com.andrognito.flashbar.Flashbar.show(Flashbar.kt:31)
at com.img.gosuperleauge.Extras.AppUtils$Companion.showError(AppUtils.kt:167)
at com.img.gosuperleauge.Fragment.PanValidationFragment$VerifyPanDetails$strRequest$1.parseNetworkError(PanValidationFragment.kt:581)
at com.android.volley.NetworkDispatcher.parseAndDeliverNetworkError(NetworkDispatcher.java:171)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:159)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
ниже приведен код в моем первом классе
Flashbar.Builder(context)
.gravity(Flashbar.Gravity.TOP)
.duration(5000)
.title("Error!!")
.message(mesg)
.icon(R.drawable.logo)
.backgroundDrawable(R.drawable.error_bg)
.titleColorRes(R.color.white)
.messageColorRes(R.color.white)
.enterAnimation(FlashAnim.with(context)
.animateBar()
.duration(750)
.alpha()
.overshoot())
.exitAnimation(FlashAnim.with(context)
.animateBar()
.duration(400)
.accelerateDecelerate())
.build()
ниже, как я звоню выше в моем фрагменте
AppUtils.showError_c(context as VerifyAccountActivity,obj.getString("message"))