-
Notifications
You must be signed in to change notification settings - Fork 500
SuperActivityToast
SuperActivityToasts are made to replace stock Android Toasts that are used in an Activity Context. SuperActivityToasts can NOT be used in a non-Activity Context.
SuperActivityToasts should be used wherever an Activity Context is available. SuperActivityToasts attach themselves to the Activity's content meaning that the SuperActivityToast will not linger from screen to screen. When the Activity's content gets destroyed the SuperActivityToast gets destroyed along with it, eliminating out of Context messages. There are four types of SuperActivityToasts: STANDARD, BUTTON, PROGRESS, and PROGRESS_HORIZONTAL.
- Customization options such as background color, font, text size, etc.
- Duration can be any millisecond value.
- Developers can choose between any animation.
- An Image can be displayed along with the SuperActivityToast.
- SuperActivityToasts can have an OnClickListener attached to them.
- Touch to dismiss function.
- SuperActivityToasts are attached to the Activity's content, not the WindowManager.
- Four variations.
To create a simple SuperActivityToast developers can create a new object.
SuperActivityToast superActivityToast = new SuperActivityToast(this);
superActivityToast.setDuration(SuperToast.DURATION_LONG);
superActivityToast.setText("Hello world!");
superActivityToast.show();
Developers can also use a static method.
SuperActivityToast.createDarkSuperActivityToast(this, "Hello world!", SuperToast.DURATION_LONG).show();
To style a SuperActivityToast developers will have to create a new object.
SuperActivityToast superActivityToast = new SuperActivityToast(this, SuperToast.Type.STANDARD);
superActivityToast.setDuration(SuperToast.DURATION_LONG);
superActivityToast.setShowAnimation(mShowAnimation);
superActivityToast.setDismissAnimation(mDismissAnimation);
superActivityToast.setBackgroundResource(SuperToast.BACKGROUND_BLUETRANSLUCENT);
superActivityToast.setTextColor(Color.WHITE);
superActivityToast.setTextSize(SuperToast.TEXTSIZE_MEDIUM);
superActivityToast.setText("Hello world!");
superActivityToast.setIconResource(R.drawable.image, SuperToast.IconPosition.LEFT);
superActivityToast.setTouchToDismiss(true);
superActivityToast.show();
If a SuperActivityToast is showing when an Intent to another Activity is started the SuperActivityToast may linger upon return to the previous Activity. To remedy this developers have two options.
Developers may call this in the Activity that calls the Intent.
@Override
public void onPause() {
super.onPause();
/* Don't let the SuperActivityToast linger */
SuperActivityToast.cancelAllSuperActivityToasts();
}
Or call the same method before starting the Intent.
/* Don't let the SuperActivityToast linger */
SuperActivityToast.cancelAllSuperActivityToasts();
startActivity(new Intent(ActivityOne.this, ActivityTwo.class));