29jitender / Spotlight

Spotlight is an Android library used to onboard users by showcasing specific features in the app.
Apache License 2.0
1.27k stars 163 forks source link

How to know tour is closed/complete #62

Open Ankur008 opened 7 years ago

Ankur008 commented 7 years ago

I want to run a function when the tour is complete. How would I do it?

zacharee commented 7 years ago

For some reason, there doesn't seem to be an actual sequence listener, but you can sort of reconstruct the sequence like this:

    SpotlightView slideOne = new SpotlightView.Builder(activity)
            .target(firstView)
            .setConfiguration(mConfig)
            .headingTvText("Example")
            .subHeadingTvText("Example")
            .usageId(ID_STRING_1)
            .show();

    final SpotlightView.Builder menu = new SpotlightView.Builder(activity)
            .target(secondView)
            .setConfiguration(mConfig)
            .headingTvText("Example")
            .subHeadingTvText("Example")
            .usageId(ID_STRING_2);

    SpotlightListener listener = new SpotlightListener()
    {
        @Override
        public void onUserClicked(String s)
        {
            switch (s) {
                case ID_STRING_1:
                    menu.show();
                    break;
                case ID_STRING_2:
                    break;
            }
        }
    };

    drawer.setListener(listener);
    menu.setListener(listener);

The onUserClicked() function will execute whe the slide is disappearing. To set an action for the end of the tutorial, just add a case in the switch for the ID of your last slide.

Ankur008 commented 7 years ago

In my case, I am showing multiple screen using the SpotlightSequence,

SpotlightSequence.getInstance(MainActivity.this, null) .addSpotlight(profile_pic, "Edit Profile", "Change your profile pic & Edit profile info", INTRO_PROFILE + randomChar) .addSpotlight(bpBlock.leftImage, "Add BP reading ", "You can add BP readings here", INTRO_ADDBP + randomChar) .startSequence();

here how can I add the listener in the sequence?

dhavalwooplr commented 7 years ago

@Ankur008 , @zacharee , Added a listener for that. Please check the fix here #71 .