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

Infinite Crouton in Android only appears once #207

Closed
AnirudhaAgashe opened this issue Sep 3, 2014 · 3 comments
Closed

Infinite Crouton in Android only appears once #207

AnirudhaAgashe opened this issue Sep 3, 2014 · 3 comments

Comments

@AnirudhaAgashe
Copy link

I am displaying crouton using the following code. At first run of the application the Crouton appears. But if I hit back button and reopen the application from launcher or recent list Crouton doesn't appear.

public class MainActivity extends ActionBarActivity{
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
 }

@Override
protected void onResume() {
    super.onResume();
    Style infinite = new Style.Builder().setBackgroundColorValue(
            Style.holoBlueLight).build();

    Configuration configuration = new Configuration.Builder().setDuration(
            Configuration.DURATION_INFINITE).build();

    Crouton crouton = Crouton.makeText(this, "Hello world", infinite);
    crouton.setConfiguration(configuration);
    crouton.show();
} 

}

@keyboardsurfer
Copy link
Owner

You'll probably need to call Crouton.clearCroutonsForActivity(this); within onDestroy(...) of your Activity. See #24 for more info.

@AnirudhaAgashe
Copy link
Author

Thanks for the response. Sorry for the late reply. I was able to make it work by holding a reference to the displayed crouton and cancel it in onPause method of the activity. I was also able to achieve the desired behavior using Crouton.clearCroutonForActivity(this). Also when I was looking to add documentation I found Important! on the project page itself.
Calling Crouton.cancelAllCroutons(); also results in desired behavior.
Which will do you recommend ?

Also I experimented with different duration for configuration. This issue is occurring only when the duration is set to infinite.

@keyboardsurfer
Copy link
Owner

Both get the job done. Nonetheless if at some point in the future multiple Croutons might be supported, cancelAllCroutons() might remove more Croutons than you wanted to be removed.

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

No branches or pull requests

2 participants