jmp-12 / SuperToasts

A library that extends the Android toast framework.
Apache License 2.0
2.67k stars 499 forks source link

disable auto hide #112

Open pishguy opened 7 years ago

pishguy commented 7 years ago

how can i disable auto hide by duration? i want to hide that after finish some process for example:

toast = SuperActivityToast.create(ActivityRegister.this,
        new SuperToastStyle(),
        SuperToastStyle.TYPE_PROGRESS_BAR, 0)
        .setProgressBarColor(Color.WHITE)
        .setHeight(142)
        .setText(AndroidUtilities.getString(R.string.please_try_again, context))
        .setFrame(SuperToastStyle.FRAME_LOLLIPOP)
        .setColor(PaletteUtils.getSolidColor(PaletteUtils.MATERIAL_INDIGO))
        .setIconPosition(SuperToastStyle.ICONPOSITION_RIGHT)
        .setAnimations(SuperToastStyle.ANIMATIONS_FADE);

toast.show();
//get data from server
toast.hide();
ga25 commented 7 years ago

step1: add a flag of keeping show in Style Class: public static final int DURATION_MAX=-1; step2: set duration with the flag: toast.setDuration(Style.DURATION_MAX); step3: compare duration with the flag in displaySuperToast() of Toast Class , if matched do nothing before execute sendDelayedMessage():

private void displaySuperToast(SuperToast superToast) { ... if (duration == Style.DURATION_MAX) return; sendDelayedMessage(superToast, Messages.REMOVE_SUPERTOAST, superToast.getDuration() + AnimationUtils.SHOW_DURATION); ... }

pishguy commented 7 years ago

@ga25 thanks, let me to test that 👍

ga25 commented 7 years ago

Have you solved that?

pishguy commented 7 years ago

@ga25 i'm so sorry sir, i dont have free time now. please let me to test that, thanks

Guiorgy commented 4 years ago

.setIndeterminate(true) and then .dismiss()