sangcomz / FishBun

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

[BUG] lateinit property imageAdapter has not been initialized #262

Open KoheiMoroi opened 1 year ago

KoheiMoroi commented 1 year ago

Describe the bug Using the latest version 1.1.1, we still face that early crash UninitializedPropertyAccessException by imageAdapter on our production app. For addressing the crash, could you please reconsider this PR?

Similar issues:

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

BorlandDev commented 1 year ago

I bring my code:

private val contentGallery =
    registerForActivityResult(StartActivityForResult()) {
        if (it.resultCode == AppCompatActivity.RESULT_OK) {
            path = it.data?.getParcelableArrayListExtra(FishBun.INTENT_PATH) ?: arrayListOf()
            navigateToUploadPhotosFragment(path)
        }
    }

private fun openGallery() { if (PickVisualMedia.isPhotoPickerAvailable()) contentGalleryWithHigherApi.launch( PickVisualMediaRequest(PickVisualMedia.ImageOnly) ) else { FishBun.with(this) .setImageAdapter(GlideAdapter()) .setAlbumSpanCountOnlyLandscape(1) .setMaxCount(5) .setIsUseDetailView(false) .setActionBarColor( Color.parseColor("#213454"), Color.parseColor("#213454"), false ) .setActionBarTitleColor(Color.parseColor("#FFFFFF")) .textOnImagesSelectionLimitReached(requireContext().resources.getString(R.string.gallery_hint)) .startAlbumWithActivityResultCallback(contentGallery) } }