-
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.
- Orientation change support
To create a simple SuperActivityToast developers can create a new object.
SuperActivityToast superActivityToast = new SuperActivityToast(Activity.this);
superActivityToast.setDuration(SuperToast.Duration.LONG);
superActivityToast.setText("Hello world!");
superActivityToast.show();
Developers can also use a static method.
SuperActivityToast.createDarkSuperActivityToast(Activity.this, "Hello world!", SuperToast.Duration.LONG).show();
To style a SuperActivityToast developers will have to create a new object.
SuperActivityToast superActivityToast = new SuperActivityToast(Activity.this, SuperToast.Type.STANDARD);
superActivityToast.setDuration(SuperToast.Duration.LONG);
superActivityToast.setShowAnimation(mShowAnimation);
superActivityToast.setDismissAnimation(mDismissAnimation);
superActivityToast.setBackgroundResource(SuperToast.Background.BLUE);
superActivityToast.setTextColor(Color.WHITE);
superActivityToast.setTextSize(SuperToast.TextSize.Medium);
superActivityToast.setText("Hello world!");
superActivityToast.setIconResource(SuperToast.Icon.Dark.INFO, SuperToast.IconPosition.LEFT);
superActivityToast.setTouchToDismiss(true);
superActivityToast.show();
To have SuperActivityToasts retain themselves on orientation change add this code to your Activity
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
SuperActivityToast.onSaveState(outState);
}
And add the restore method to the onCreate of your Activity.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
SuperActivityToast.onRestoreState(savedInstanceState, Activity.this);
}