KeepSafe / TapTargetView

An implementation of tap targets from the Material Design guidelines for feature discovery.
Apache License 2.0
5.35k stars 587 forks source link

TapTargetSequence doesn't work after the first launch #358

Closed Minipomme closed 4 years ago

Minipomme commented 4 years ago

Version used: 1.12.0

Android version: 9

Hi,

Thanks for your library, it's very nice ! I am currently trying to create a button to launch a "tutorial". Everything works fine for the first launch. Once the sequence is finished, I can no longer restart the same sequence from the beginning. An animation is launched beforehand and it works as well as a Toast for every launch but the sequence does not work. Did I miss something?

Declaration of TapTargetSequence : TapTargetSequence tapTargetSequence = new TapTargetSequence(this)

Declaration of Help Button : final ImageButton helpButton = findViewById(R.id.helpButton);

For each target :

tapTargetSequence.target(TapTarget.forView(view, mode, description)
                        .cancelable(false)
                        .tintTarget(true)
                        .transparentTarget(true)
                        .outerCircleColorInt(color)
                        .textColor(R.color.white)
                    );

Help button onClick :

helpButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        menu.open(true);
                        Handler handler = new Handler();
                        handler.postDelayed(new Runnable() {
                            public void run() {
                                Toast.makeText(ConnectBluetoothActivity.this, "Tutorial start !", Toast.LENGTH_SHORT).show();
                                tapTargetSequence.start();
                            }
                        }, menu.getDurationOpen());

                    }
                });

Minipomme

Minipomme commented 4 years ago

Okay it's working but I don't know if it's the good practice

TapTargetSequence tapTargetSequence;
List<TapTarget> tapTargets = new ArrayList<>();
tapTargets.add(TapTarget.forView(view, mode, description)
    .cancelable(false)
    .transparentTarget(true)
    .outerCircleColorInt(color)
    .textColor(R.color.white)
);
helpButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        tapTargetSequence = new TapTargetSequence(ConnectBluetoothActivity.this);

        for (TapTarget tapTarget : tapTargets) {
            tapTargetSequence.target(tapTarget);
        }
        menu.open(true);
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            public void run() {
                tapTargetSequence.start();
            }
        }, menu.getDurationOpen());

    }
});