Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null point exeption when getPack from FilterPack #43

Open
Nuruddin999 opened this issue May 2, 2019 · 0 comments
Open

Null point exeption when getPack from FilterPack #43

Nuruddin999 opened this issue May 2, 2019 · 0 comments

Comments

@Nuruddin999
Copy link

When i open image from gallery:

if (requestCode == PICKIMAGE) {
                data?.data?.let {
                    val bitmap = BitmapUtils.getBitmapFromGallery(this, it, 800, 800)

                    original_filter_bitmap.recycle()
                    final_bitmap.recycle()
                    filtered_bitmap.recycle()
                    original_filter_bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true)
 imageFiltersFragment!!.displayThumbNail(original_filter_bitmap)

and try to display this image in thumbnail

open fun displayThumbNail(bitmap: Bitmap?) {
        var runnable = Runnable {

            var thumbImg: Bitmap?
            if (bitmap == null)
                thumbImg = BitmapUtils.getBitmapFromAsests(activity, MainActivity.pictureName, 100, 100)
            else
                thumbImg = Bitmap.createScaledBitmap(bitmap, 100, 100, false)

            if (thumbImg == null)
                return@Runnable

            ThumbnailsManager.clearThumbs()
            thumbnailList?.clear()
            val thumbnailItem = ThumbnailItem()
            thumbnailItem.image = thumbImg
            thumbnailItem.filterName = "Normal"
            ThumbnailsManager.addThumb(thumbnailItem)
            var filters = FilterPack.getFilterPack(activity!!) as MutableList
            for (f in filters) {
                val item = ThumbnailItem()
                item.image = thumbImg
                item.filter = f
                item.filterName = f.name
                ThumbnailsManager.addThumb(item)
                Log.d("filterpack", f.name)
            }
            thumbnailList!!.addAll(ThumbnailsManager.processThumbs(activity))
            activity!!.runOnUiThread {

                thumbnailAdapter.notifyDataSetChanged()

            }
        }

It throws this exeption
kotlin.KotlinNullPointerException
at com.example.sg772.textonimage.ImageFiltersFragment$displayThumbNail$runnable$1.run(ImageFiltersFragment.kt:110)

line 110: var filters = FilterPack.getFilterPack(activity!!) as MutableList
P.S
When i dont open image from gallery and work with default image , everythings works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant