Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Fatal Exception: java.lang.IllegalStateException on ImagePreview #10

@73k05

Description

@73k05

Hi @wangsun6 thank you for the great work and wonderful lib you have been creating here,

I got a crash from my community, I don't know how to reproduce it yet but here is the error I get.

Platform: android 7 & android 10
Device: Galaxy Note10 & ZenFone AR
BG: Not in background task

Crash:

Fatal Exception: java.lang.IllegalStateException: preview_fragment_parent_fl must not be null
       at com.greentoad.turtlebody.imagepreview.ImagePreview$PreviewFragment.show(ImagePreview.java:320)
       at com.greentoad.turtlebody.imagepreview.ImagePreview$PreviewFragment.access$show(ImagePreview.java:211)
       at com.greentoad.turtlebody.imagepreview.ImagePreview$PreviewFragment$initAdapter$2.onViewPagerClick(ImagePreview.java:379)
       at com.greentoad.turtlebody.imagepreview.ui.components.ViewPagerAdapter$getItem$1.onImageClick(ViewPagerAdapter.java:28)
       at com.greentoad.turtlebody.imagepreview.ui.components.ImageFragmentViewer$onViewCreated$1.onClick(ImageFragmentViewer.java:50)
       at android.view.View.performClick(View.java:7865)
       at com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView$2.onSingleTapConfirmed(SubsamplingScaleImageView.java:565)
       at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:345)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:237)
       at android.app.ActivityThread.main(ActivityThread.java:8034)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)

Here is the peace of code that is producing the error:

        private fun show() {
            mUiVisibilityFlag?.let {
                preview_fragment_parent_fl.systemUiVisibility = it

                if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
                    preview_fragment_app_bar.setPadding(0,getStatusBarHeight(),0,0)
                    preview_fragment_bottom_ll.setPadding(0,0,0,getNavigationBarSize(context!!).y)
                }

                preview_fragment_activity_toolbar.visibility = View.VISIBLE

                if(mPreviewConfig.mUriList.size>1) {
                    preview_fragment_bottom_ll.visibility = View.VISIBLE
                }
            }
        }

It seems to be the line preview_fragment_parent_fl.systemUiVisibility = it. Shall we wrap it in null test and exit in that case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions