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

Coordinator is a Java library that is used to coordinate various asynchronous actions. Usually we found cases that you need to check if other thread is completed to execute an action, coordinator solves this problem without using flags.

Prime is an Android image loading library.

Simple, pretty and powerful logger for Android.

Load custom fonts easily just via layout parameters or styles. Uses static Typeface objects, load once - memory efficient. No more textView.setTypeface() calls!

Extends StatedFragment and save state in onSaveState(Bundle outState) and restore state in onRestoreState(Bundle savedInstanceState).

An Android Logger with a lot of options for debugging that helps a lot to developers. You can easily add logs everywhere in your APP and manage showing them by limit them by Codes or by their Class name. It also will show you that logs was called from which file and which line, you also can see which class and which line called your current method.

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