Snacky


Source link: https://github.com/matecode/Snacky

Snacky

Snacky is a small library to help you adding a Snackbar to your layout with ease. It was created because of my own needs and is inspired by Toasty. Snacky uses an easy builder pattern to build a Snackbar and gives you some template designs like ERROR, WARNING, INFO and SUCCESS as well as some customization options. See code samples below

Screenshots

Usage

Using Snacky is really simple.

Initialisation

Start with Snacky.builder() to get a Builder.

It is necessary to set an activity or View for the snackbar.

.setView(View view) will use the view for the snackbar to show, or you choose

.setActivity(Activity activity) which will automatically find the root view of the activity

Customization

most of them are self-explaining

.setBackgroundColor() Color or ColorStateList

.setText() Charset or IntRes for text

.setTextColor() Color int of text

.setTextSize() size in SP or with ComplexUnit

.setTextTypefaceStyle() NORMAL, BOLD, ITALIC, BOLD_ITALIC from Typeface

.setMaxLines() max lines of Snackbar, off by default

.centerText() centers the text

.setActionText()

.setActionTextColor()

.setActionTextSize()

.setActionTextTypefaceStyle() like .setTextTypefaceStyle()

.setActionClickListener(View.OnClickListener)

.setDuration(Snacky.DURATION) SHORT, LONG, INDEFINITE

.setIcon() Drawable to be shown, in my opinion ist best to use small drawables with 24dp size

Building

.build() gives you the Snackbar, but you can also use some predefined templates:

.success()

.error()

.info()

.warning()

All give you a snackbar object, but some set predefined values if you didn't customize them before.

Using the snackbar

After that you can handle the snackbar as you know it:

.addCallback(SnackBar.Callback) adds a callback to the snackbar

.show() shows the snackbar

Example

See ExampleActivity.java for a list of examples as shown in Screenshots.

There you can also the see the right use of CoordinatorLayout and FloatingActionButton. For Snacky Builder just use the view from OnClickListener in FAB to animate it on click.

Installation

Snacky is published via Jitpack. Add this in your root build.gradle file ( not your module build.gradle file):

allprojects {

  repositories {

...

maven {
 url "https://jitpack.io" 
}

  
}
 
}

Add this to your module's build.gradle file (make sure the version matches the JitPack badge above):

dependencies {

  ...
  compile 'com.github.matecode:Snacky:1.0.2' 
}

Licence

Copyright 2017 Mate Siede  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. 

Resources

OneKey Android Studio generate proguard codes.

Facade modules for dealing with complicated MediaStore in a simple way.

Intercom for Android, for integrating Intercom into your Android application.

An android app that can be used by any conference to display information like sessions, speakers, etc.

Electra for android is simple persistence framework with compile time processing.

Primary design goals:

  • Easy to use and configure
  • Easy integrate with existing code
  • Compile time processing, no reflection
  • Simple beans
  • Expression builder
  • RxJava support
  • No Dependencies

WhatsappFormatter repo helps to perform formatting just like whatsapp does it on its EditText and TextView.

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