Giter VIP home page Giter VIP logo

Comments (13)

egorikftp avatar egorikftp commented on July 24, 2024 1

@dpeters-ipc Could you please in Fragment try to use viewLifecycleOwner?

from balloon.

skydoves avatar skydoves commented on July 24, 2024 1

@egorikftp
I will check about it more and I will try to fix it in the next release.
Thank you for your issue :)

from balloon.

skydoves avatar skydoves commented on July 24, 2024

Don't use the applicationcontext for building the balloon. Instead, use your activity's context.

from balloon.

dpeters-ipc avatar dpeters-ipc commented on July 24, 2024

I use getContext() of Fragment

from balloon.

skydoves avatar skydoves commented on July 24, 2024

As you can see from the exception, the balloon could not get the activity's context. It should be called in onViewCreated (after onCreateView) and it will be better to check the activity is still alive.

val activity = getActivity() ?: return
showAsDropDown..

from balloon.

dpeters-ipc avatar dpeters-ipc commented on July 24, 2024

Hi, I tried this in a new release, but it wasn't enough. The crash still occurs.
I will add !activity.isDestroyed() && !activity.isFinishing() in the next release.

But it could still happen because you call PopupWindow.showAsDropDown from a Handler. This is asynchronous and the activity-state might have changed. So some checks in the Balloon code would be an improvement for stability I think.

from balloon.

skydoves avatar skydoves commented on July 24, 2024

@dpeters-ipc
Do you use setLifecycleOwner using the activity's lifecycle as a parameter?

from balloon.

dpeters-ipc avatar dpeters-ipc commented on July 24, 2024

I'm using setLifecycleOwner(this) where this is the Fragment instance

from balloon.

skydoves avatar skydoves commented on July 24, 2024

@dpeters-ipc
Hi, I changed the Handler using the main looper in the new version 1.1.6.
If the same issue will happen and if the crashes are serious, the dismissWithDelay functionality will be removed. Thank you :)

from balloon.

skydoves avatar skydoves commented on July 24, 2024

It's included in the new version 1.1.8.
Thank you for your issue :)

from balloon.

egorikftp avatar egorikftp commented on July 24, 2024

@skydoves Looks like with viewLifecycleOwner we have crash in the latest version using by balloon() delegate.

java.lang.IllegalStateException: Can't access the Fragment View's LifecycleOwner when getView() is null i.e., before onCreateView() or after onDestroyView()
at androidx.fragment.app.Fragment.getViewLifecycleOwner(Fragment.java:353)

from balloon.

skydoves avatar skydoves commented on July 24, 2024

Hi, @egorikftp.
As you can see from the log, I think the balloon is used before onCreateView() or after onDestroyView().
Could you please give me more details about your use cases?

from balloon.

egorikftp avatar egorikftp commented on July 24, 2024

I call balloon after onViewCreated(), not reproduced on 1.1.7 version.

Source code:
https://github.com/egorikftp/Lady-happy-Android/blob/5fbfc4c2d43b6a725a26d7c1edb290881de46da4/sources/feature/catalog/src/full/java/com/egoriku/ladyhappy/catalog/subcategory/presentation/fragment/SubCategoryFragment.kt#L37

class SubCategoryFragment : Fragment(R.layout.fragment_catalog) {

    private val binding: FragmentCatalogBinding by viewBinding()

    private val viewHolderBalloon by balloon(ViewHolderBalloonFactory::class)

    private var subcategoryController: SubCategoryController by Delegates.notNull()

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        subcategoryController = SubCategoryController(
                onCatalogItemClick = {
                    
                },
                onTrendingClick = {
                    viewHolderBalloon?.showAlignLeft(it)
                }
        )
    }
}

from balloon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.