-
Notifications
You must be signed in to change notification settings - Fork 3
ToastView
This step is optional, but if you want you can configure some ToastView parameters. Place this anywhere in your app:
ToastView.Config.getInstance()
.tintIcon(boolean tintIcon) // optional (apply textColor also to the icon)
.setToastTypeface(@NonNull Typeface typeface) // optional
.setTextSize(int sizeInSp) // optional
.allowQueue(boolean allowQueue) // optional (prevents several Toastys from queuing)
.apply(); // required
You can reset the configuration by using reset()
method:
ToastView.Config.reset();
Each method always returns a Toast
object, so you can customize the Toast much more. DON'T FORGET THE show()
METHOD!
To display an error Toast:
ToastView.error(mContext, "This is an error toast.", Toast.LENGTH_SHORT, true).show();
To display a success Toast:
ToastView.success(mContext, "Success!", Toast.LENGTH_SHORT, true).show();
To display an info Toast:
ToastView.info(mContext, "Here is some info for you.", Toast.LENGTH_SHORT, true).show();
To display a warning Toast:
ToastView.warning(mContext, "Beware of the dog.", Toast.LENGTH_SHORT, true).show();
To display the usual Toast:
ToastView.normal(mContext, "Normal toast w/o icon").show();
To display the usual Toast with icon:
ToastView.normal(mContext, "Normal toast w/ icon", yourIconDrawable).show();
You can also create your custom Toasts with the custom()
method:
ToastView.custom(mContext, "I'm a custom Toast", yourIconDrawable, tintColor, duration, withIcon,
shouldTint).show();
Copyright (C) 2019 DV Infosys
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.