Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SuperActivityToast now showing (and not clickable) occasionally ? #45

Closed
skadavan opened this issue Jul 12, 2014 · 4 comments
Closed

SuperActivityToast now showing (and not clickable) occasionally ? #45

skadavan opened this issue Jul 12, 2014 · 4 comments
Assignees
Labels

Comments

@skadavan
Copy link

I am using SuperActivityToast to show a confirmation with an optional info button (which launches another activity).

Occasionally the toast doesn't come up. Occasionally it comes up but the button is not clickable. Noticed this happens when we try using it frequently. I am using it from a fragment. Any clues ?

Code below:

    subscribeConfirmationToast = new SuperActivityToast(getActivity(), SuperToast.Type.BUTTON);
    subscribeConfirmationToast.setTouchToDismiss(true);
    subscribeConfirmationToast.setText(getResources().getString(R.string.button_subscribe_confirmation));
    subscribeConfirmationToast.setButtonIcon(R.drawable.ic_action_database, 
            getResources().getString(R.string.page_title_subscribed));
    subscribeConfirmationToast.setDuration(SuperToast.Duration.SHORT);
    subscribeConfirmationToast.setOnClickWrapper(new OnClickWrapper(this.getClass().getName(), new OnClickListener() {
        @Override
        public void onClick(View view, Parcelable token) {
            SuperActivityToast.cancelAllSuperActivityToasts();
            EventBus.getDefault().post(new Event.ShowMyShowsClicked(getActivity()));    // This will launch another activity.           
        }
    }));

public void onEventMainThread(Event.ShowSubscribed event) {
    // some other UI updations
    if(subscribeConfirmationToast != null) {
        subscribeConfirmationToast.show();
    }
   }
@skadavan
Copy link
Author

SuperActivityToast.cancelAllSuperActivityToasts();
I tried adding this code later, to see if pending toasts are preventing the new ones.

@JohnPersano
Copy link
Owner

Skadavan,

Sorry for the late reply, I'm absolutely swamped with work! I have used SuperActivityToasts in Fragments with no issues, the demo app even uses Fragments. Have you tried to create it in the onEvent method? I can't imagine why it would be null but try to put a log in there to make sure show() is being called.

Suggestion number two would be to call cancelAllSuperActivityToasts() before you call show() but that's kind of hacky, I'd rather know what the real problem is.

SuperCardToasts are added to your Activity differently than SuperToasts or SuperActivityToasts. SuperCardToasts do not have a Queue. If nothing else works, replace the SuperActivityToast with a SuperCardToast and let me know what happens. If SuperCardToasts work than that would help me narrow down the issue.

Let me know what happens either way and thanks for the report!

-John

@tbruyelle
Copy link

Hey @skadavan

I run into similar issue and for me the problem was because I was reusing the same SuperActivityToast instance multiple times.
The toasts were not designed for that purpose, once they have been displayed, if you want to display again, you must re-instantiate a new one. This is particularly true for the toast with a Button, where the actual implementation set the button non clickable after the first click, so then if you redisplay the toast the button stays non clickable.

Maybe this requires to be mentioned in the documentation, something like The toasts are designed to be on-shot ?

HTH

@JohnPersano
Copy link
Owner

tbruyelle,

You are correct. While the SuperActivityToasts were not specifically designed as a one shot, it is best practice to reuse the same one. I will make this more clear in the documentation.

Thanks,

John

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants