java.lang.IllegalArgumentException: View = DecorView @ ff5fb5d [MainActivity] не присоединен к оконному менеджеру - PullRequest
0 голосов
/ 26 декабря 2018

Я занимаюсь разработкой нового приложения, и когда я вошел в систему, используя электронную почту и пароль, он падает, выдавая ошибку ниже

java.lang.IllegalArgumentException: View = DecorView @ ff5fb5d [MainActivity] не присоединенв диспетчер окон по адресу.app.Dialog.dismissDialog (Dialog.java:610) на android.app.Dialog.dismiss (Dialog.java:593) на com.empowered.healo.ui.views.CustomAlertDialog.access $ dismiss $ s-1404601997 (CustomAlertDialog.kt: 23) at com.empowered.healo.ui.views.CustomAlertDialog $ dismiss $$ inlined $ let $ lambda $ 1.onAnimationEnd (CustomAlertDialog.kt: 107) в android.animation.ValueAnimator.endAnimation (ValueAnimator.java:1149)) в android.animation.ValueAnimator.doAnimationFrame (ValueAnimator.java:1309) в android.animation.AnimationHandler.doAnimationFrame (AnimationHandler.java:146) в android.animation.AnimationHandler.-wrap2 (AnimationHandler.java) в android.animation.AnimationHandler $ 1.doFrame (AnimationHandler.java:54) в android.view.Choreographer $ CallbackRecordr..java: 925) в android.view.Choreographer.doCallbacks (Choreographer.java:702) в android.view.Choreographer.doFrame (Choreographer.java:635) в android.view.Choreographer $ FrameDisplayEventReceiver.rapher (Choreogog:913) на android.os.Handler.handleCallback (Handler.java:751) на android.os.Handler.dispatchMessage (Handler.java:95) на android.os.Looper.loop (Looper.java:154) android.app.ActivityThread.main (ActivityThread.java:6682) в java.lang.reflect.Method.invoke (собственный метод) в com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:1520) в com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)

Я перешел по этой ссылке

Просмотр не привязан к аварийному завершению менеджера окон

нижемой CustomAlertDialog.kt

class CustomAlertDialog(context: Context) : AlertDialog(context, R.style.AppTheme_FullScreenDialogStyle), CustomAlertDialogBuilder.CustomDialogInterface {
    var dismissListener: CustomAlertDialogBuilder.OnDismissListener? = null
    private var cancelableDialog = true
    var alertDialogInfo = CustomAlertDialogBuilder.AlertDialogInfo()


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.custom_dialog)
        if (cancelableDialog) {
            rootDialogLayout.setOnClickListener { dismiss() }
        }

        btnPositive.visibility = if (alertDialogInfo.positiveText != null) View.VISIBLE else View.GONE
        btnPositive.text = alertDialogInfo.positiveText

        btnNegative.visibility = if (alertDialogInfo.negativeText != null) View.VISIBLE else View.GONE
        btnNegative.text = alertDialogInfo.negativeText

        btnNeutral.visibility = if (alertDialogInfo.neutralText != null) View.VISIBLE else View.GONE
        btnNeutral.text = alertDialogInfo.neutralText

        dialogTitle.visibility = if (alertDialogInfo.titleText != null) View.VISIBLE else View.GONE
        dialogTitle.text = alertDialogInfo.titleText

        alertDialogInfo.textColor?.let {
            btnPositive.setTextColor(it)
            btnNegative.setTextColor(it)
            btnNeutral.setTextColor(it)
            message?.setTextColor(it)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                buttonsControl?.dividerDrawable?.colorFilter = PorterDuffColorFilter(it, PorterDuff.Mode.MULTIPLY)
            }
        }

        message?.text = this.alertDialogInfo.message

        alertDialogInfo.background?.let {
            backgroundImage.setImageResource(it)
        }
        btnPositive.setOnClickListener { alertDialogInfo.onPositiveClickListener?.onClick(this) }
        btnNeutral.setOnClickListener { alertDialogInfo.onNeutralClickListener?.onClick(this) }
        btnNegative.setOnClickListener { alertDialogInfo.onNegativeClickListener?.onClick(this) }
    }

    override fun setCancelable(flag: Boolean) {
        super.setCancelable(flag)
        cancelableDialog = flag
    }


    override fun onStart() {
        super.onStart()
        val animationSet = AnimatorSet()
        val decorView = this
                .window
                .decorView
        decorView.setBackgroundColor(Color.TRANSPARENT)
        backgroundImage?.let {
            val titleAnimation = ObjectAnimator.ofFloat(dialogTitle, View.TRANSLATION_Y, -50.dp.toFloat(), 0f)
            val imageAnimation = ObjectAnimator.ofFloat(it, View.SCALE_X, 0f, 1f)
            val startAnimation = ObjectAnimator.ofFloat(decorView, View.ALPHA, 0f, 1f)
            animationSet.playTogether(titleAnimation, imageAnimation, startAnimation)
        }

        animationSet.duration = 350
        animationSet.interpolator = LinearInterpolator()
        animationSet.start()

    }

    override fun dismiss() {
        val animationSet = AnimatorSet()
        val decorView = this
                .window
                .decorView

        backgroundImage?.let {
            val imageAnimation = ObjectAnimator.ofFloat(it, View.SCALE_X, 1f, 0f)
            val titleAnimation = ObjectAnimator.ofFloat(dialogTitle, View.TRANSLATION_Y, 0f, -50.dp.toFloat())
            val endAnimation = ObjectAnimator.ofFloat(decorView, View.ALPHA, 1.0f, 0.0f)

            val listeners = object : AnimationListener() {
                override fun onAnimationEnd(animation: Animator?) {
                    super@CustomAlertDialog.dismiss()
                    dismissListener?.onDismiss()
                }
            }
            imageAnimation.addListener(listeners)
            animationSet.playTogether(titleAnimation, endAnimation, imageAnimation)
        }

        animationSet.duration = 350
        animationSet.interpolator = LinearInterpolator()
        animationSet.start()
    }

    override fun dismiss(callDismissListener: Boolean) {
        if (!callDismissListener)
            setOnDismissListener { }
        dismiss()
    }

    override fun dismiss(onDismissListener: CustomAlertDialogBuilder.OnDismissListener) {
        dismissListener = onDismissListener
        dismiss()
    } }
...