Alerter


Source link: https://github.com/Tapadoo/Alerter

Alerter

General

This library aims to overcome the limitations of Toasts and Snackbars, while reducing the complexity of your layouts.

A customisable Alert view is dynamically added to the Decor View of the Window, overlaying all content.

Gradle

dependencies {

  compile 'com.tapadoo.android:alerter:2.0.1' 
}

Usage

With simplicity in mind, the Alerter employs the builder pattern to facilitate easy integration into any app.

From an Activity -

Alerter.create(this)

  .setTitle("Alert Title")

  .setText("Alert text...")

  .show();

Or from a Fragment -

Alerter.create(getActivity())

  .setTitle("Alert Title")

  .setText("Alert text...")

  .show();

To check if an alert is showing -

Alerter.isShowing();

To hide a currently showing Alert -

Alerter.hide();

Customisation

Background Colour

Alerter.create(this)

  .setTitle("Alert Title")

  .setText("Alert text...")

  .setBackgroundColorRes(R.color.colorAccent) // or setBackgroundColorInt(Color.CYAN)

  .show();

Icon

Alerter.create(this)

  .setText("Alert text...")

  .setIcon(R.drawable.alerter_ic_face)

  .show();

On screen duration, in milliseconds

Alerter.create(this)

  .setTitle("Alert Title")

  .setText("Alert text...")

  .setDuration(10000)

  .show();

Without title

Alerter.create(this)

  .setText("Alert text...")

  .show();

Adding an On Click Listener

 Alerter.create(ExampleActivity.this)

.setTitle("Alert Title")

.setText("Alert text...")

.setDuration(10000)

.setOnClickListener(new View.OnClickListener() {

 @Override

 public void onClick(View view) {

  Toast.makeText(ExampleActivity.this, "OnClick Called", Toast.LENGTH_LONG).show();

 
}

}
)

.show();

Verbose text

 Alerter.create(ExampleActivity.this)

.setTitle("Alert Title")

.setText("The alert scales to accommodate larger bodies of text. " +

"The alert scales to accommodate larger bodies of text. " +

"The alert scales to accommodate larger bodies of text.")

.show();

Visibility Callbacks

 Alerter.create(ExampleActivity.this)

.setTitle("Alert Title")

.setOnShowListener(new OnShowAlertListener() {

 @Override

 public void onShow() {

  Toast.makeText(ExampleActivity.this, "Alert Shown", Toast.LENGTH_LONG).show();

 
}

}
)

.setOnHideListener(new OnHideAlertListener() {

 @Override

 public void onHide() {

  Toast.makeText(ExampleActivity.this, "Alert Hidden", Toast.LENGTH_LONG).show();

 
}

 
}
)

.show();

Custom Fonts and Text Appearance

 Alerter.create(ExampleActivity.this)

  .setTitle("Alert Title")

  .setTitleAppearance(R.style.AlertTextAppearance_Title)

  .setTitleTypeface(Typeface.createFromAsset(getAssets(), "Pacifico-Regular.ttf"))

  .setText("Alert text...")

  .setTextAppearance(R.style.AlertTextAppearance_Text)

  .setTextTypeface(Typeface.createFromAsset(getAssets(), "ScopeOne-Regular.ttf"))

  .show();

Swipe to Dismiss

 Alerter.create(ExampleActivity.this)

  .setTitle("Alert Title")

  .setText("Alert text...")

  .enableSwipeToDismiss()

  .show();

Progress Bar

Alerter.create(ExampleActivity.this)

  .setTitle("Alert Title")

  .setText("Alert text...")

  .enableProgress(true)

  .setProgressColorRes(R.color.colorAccent)

  .show();

Sample

Clone this repo and check out the app module.

Licence

See the LICENSE file for license rights and limitations (MIT).

Copyright 2016 Tapadoo, Dublin.

Resources

An indicator like Morning Routine guide.It was originally based on BezierDemo.

Gradle plugin for j2objc (Java to Objective-C translation tool).

Working with Spans is ugly and difficult to manage, it's like working with a goblin of Moria. Don't understand the Spans? With AwesomeText you will only have to work with the classic Adapter Pattern. All the ease and potential of a pattern you already know how to use.

AndroidRandomColor library allows to generate random colors on Android.

IconButton is an Android button widget that allows you to center both the button's text and an icon.

mini-equalizer-library-android is created to let you use an animated equalizer inside your music related apps.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes