ViewTooltip icon indicating copy to clipboard operation
ViewTooltip copied to clipboard

Is there any way to auto close the tooltip when navigating away from the fragment in the same activity?

Open kalyandechiraju opened this issue 6 years ago • 4 comments

kalyandechiraju avatar Apr 24 '18 05:04 kalyandechiraju

I added the following to the ViewTooltip class.

public class ViewTooltip {
    private static ArrayList<TooltipView> allToolTips = new ArrayList<>();
    public static void hideAllVisibleToolTips() {
        for (TooltipView tip: allToolTips) {
            tip.removeNow();
        }
    }

then in the Tooltip constructor I added (right above setWithShadow(true);)

**allToolTips.add(TooltipView.this);** You can then call this function ViewTooltip.hideAllVisibleToolTips() when navigating away from your fragment.

It works well for me.

tronious avatar Aug 19 '18 21:08 tronious

Nice! In which version will this be available?

I am currently using 1.1.5 and I solved it in a dirty way by saving the instance of tooltip as a member variable in Fragment instead of local. So that on certain events I can check if it's not null and call closeNow on it.

kalyandechiraju avatar Aug 20 '18 03:08 kalyandechiraju

I didnt have any plans to push the change. Someone is welcome to if they'd like.

What I wrote above is really everything that's needed to make it work.

Whenever I load a new fragment I just call

ViewTooltip.hideAllVisibleTooltips()

In my code and they get removed.

tronious avatar Aug 20 '18 03:08 tronious

If you set tooltip on rootView like this, it'll hide automatically when parent view is not visible. ViewTooltip.on(context, relView, imgDot)...

kashifo avatar Dec 18 '18 13:12 kashifo