sangcomz / FishBun

:blowfish:FishBun is Image Picker for android.
Apache License 2.0
671 stars 144 forks source link

[BUG] lateinit property imageAdapter crash when using fish bun in fragment #253

Closed Moony-H closed 1 year ago

Moony-H commented 2 years ago

version 1.0.0-beta01 im getting crashes when fishbun started in fragment.


here's log


kotlin.UninitializedPropertyAccessException: lateinit property imageAdapter has not been initialized
        at com.sangcomz.fishbun.Fishton.getImageAdapter(Fishton.kt:15)
        at com.sangcomz.fishbun.datasource.FishBunDataSourceImpl.getImageAdapter(FishBunDataSourceImpl.kt:27)
        at com.sangcomz.fishbun.ui.album.model.repository.AlbumRepositoryImpl.getImageAdapter(AlbumRepositoryImpl.kt:40)
        at com.sangcomz.fishbun.ui.album.mvp.AlbumPresenter$loadAlbumList$1$1$onSuccess$1.invoke(AlbumPresenter.kt:33)
        at com.sangcomz.fishbun.ui.album.mvp.AlbumPresenter$loadAlbumList$1$1$onSuccess$1.invoke(AlbumPresenter.kt:28)
        at com.sangcomz.fishbun.util.MainUiHandler.run$lambda-0(MainUiHandler.kt:11)
        at com.sangcomz.fishbun.util.MainUiHandler.$r8$lambda$ESEsIHm4quKOiXRP0dkG-n5rAMY(Unknown Source:0)
        at com.sangcomz.fishbun.util.MainUiHandler$$ExternalSyntheticLambda0.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:205)
        at android.app.ActivityThread.main(ActivityThread.java:6991)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884)


and my code


FishBun.with(this).setImageAdapter(GlideAdapter())
    .startAlbumWithActivityResultCallback(getResultFromFishBun)


but, set the "setIsUseDetailView" false, it works.



//it works
FishBun.with(this).setImageAdapter(GlideAdapter())
                .setIsUseDetailView(false)
                .startAlbumWithActivityResultCallback(getResultFromFishBun)


i dont know why. how can i do?

sangcomz commented 2 years ago

Hi, Moony-H. I can't reproduce this issue. 😢 could you give me the code?

mxalbert1996 commented 1 year ago

This bug is consistently reproducible when using AndroidX Fragment 1.5.0 and above. You can reproduce it by simply adding implementation "androidx.fragment:fragment:1.5.5" to FishBunDemo/build.gradle.

sangcomz commented 1 year ago

please use 1.1.1 version. thanks

BorlandDev commented 1 year ago

This bug is consistently reproducible when using AndroidX Fragment 1.5.0 and above. You can reproduce it by simply adding implementation "androidx.fragment:fragment:1.5.5" to FishBunDemo/build.gradle.

Hi. I have this bug, but i have not this dependends .

My dependensies:

implementation("androidx.core:core-ktx:1.7.0") implementation("androidx.appcompat:appcompat:1.4.1") implementation("com.google.android.material:material:1.6.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4")

implementation('androidx.navigation:navigation-fragment-ktx:2.4.2')
implementation('androidx.navigation:navigation-ui-ktx:2.4.2')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.activity:activity-ktx:1.6.1'
sangcomz commented 1 year ago

Thanks for sharing :) I'm considering solving it through this PR(#262).