All Projects → ChathuraHettiarachchi → Csnackbar

ChathuraHettiarachchi / Csnackbar

Licence: apache-2.0
This is a wrapper for android Snackbar. Which giving support to change Snackbar color, duration, message or even it's content view with a custom view.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Csnackbar

Alertift
Swifty, modern UIAlertController wrapper.
Stars: ✭ 242 (+218.42%)
Mutual labels:  wrapper, alert
Livesmashbar
An elegant looking and easy to use informative library with LiveData integration for Android.
Stars: ✭ 107 (+40.79%)
Mutual labels:  duration, snackbar
Microservices Example
Example of a microservices architecture on the modern stack of Java technologies
Stars: ✭ 66 (-13.16%)
Mutual labels:  gradle
Sample Boot Micro
Spring Cloud + Gradle Multi Project + Java8
Stars: ✭ 72 (-5.26%)
Mutual labels:  gradle
Cas Gradle Overlay Template
CAS Gradle Overlay: Generic CAS gradle war overlay to exercise the latest versions of CAS
Stars: ✭ 69 (-9.21%)
Mutual labels:  gradle
Domonit
A Deadly Simple Docker Monitoring Wrapper For Docker API
Stars: ✭ 67 (-11.84%)
Mutual labels:  wrapper
Hentai
Implements a wrapper class around nhentai's RESTful API.
Stars: ✭ 68 (-10.53%)
Mutual labels:  wrapper
Habito
Simple habit tracker app for Android
Stars: ✭ 65 (-14.47%)
Mutual labels:  gradle
Okta Blog Archive
Okta Developer Blog
Stars: ✭ 74 (-2.63%)
Mutual labels:  gradle
React Native Alert Pro
The Pro Version of React Native Alert (Android & iOS)
Stars: ✭ 69 (-9.21%)
Mutual labels:  alert
Swifttwitch
👾 The New Twitch API for iOS; wrapped in Swift goodness 👾
Stars: ✭ 72 (-5.26%)
Mutual labels:  wrapper
Videosniffer
视频嗅探服务(VideoSniffer API Service On Android)
Stars: ✭ 68 (-10.53%)
Mutual labels:  gradle
D2sqlite3
A small wrapper around SQLite for the D programming language
Stars: ✭ 67 (-11.84%)
Mutual labels:  wrapper
Snackbarbuilder
[ARCHIVED] Builder pattern for support library Snackbars, that makes them easier to customise and use
Stars: ✭ 71 (-6.58%)
Mutual labels:  snackbar
Android Camera2 Library
Library to use Android Camera2 api easily.
Stars: ✭ 66 (-13.16%)
Mutual labels:  gradle
Materialchipview
Material Chip view. Can be used as tags for categories, contacts or creating text clouds
Stars: ✭ 1,181 (+1453.95%)
Mutual labels:  gradle
Materialstyleddialogs
A library that shows a beautiful and customizable Material-based dialog with header. API 14+ required.
Stars: ✭ 1,139 (+1398.68%)
Mutual labels:  gradle
Android Container
Run E2E Android Testing with Docker Container
Stars: ✭ 68 (-10.53%)
Mutual labels:  gradle
Gradle Semantic Build Versioning
Gradle plugin to generate version-numbers and tags using semantic versioning
Stars: ✭ 69 (-9.21%)
Mutual labels:  gradle
Greenbeanpods
A plugin that replaces external module dependencies with project dependencies.
Stars: ✭ 75 (-1.32%)
Mutual labels:  gradle

CSnackBar Download

This is a wrapper for android Snackbar. Which giving support to change Snackbar color, duration, message or even it's content view with a custom view.

csnackbar

This library contain following functions,

  • Snackbar - alert type
  • Snackbar - set custom duration
  • Snackbar - custom contentview
  • Snackbar - binding views
  • Snackbar - custom message
  • Snackbar - alignment (Text Align feature will support only after API 17)
  • Snackbar - fillParent

####Let's take a look how to add this to your project

For the android project just include the following dependency inside you build.gradle's depedency list.

Gradle

repositories {
  jcenter()
}

dependencies {
    ...
    compile 'com.chootdev:csnackbar:1.4.2'
}

if you using maven use following Maven

<dependency>
  <groupId>com.chootdev</groupId>
  <artifactId>csnackbar</artifactId>
  <version>1.4.2</version>
  <type>pom</type>
</dependency>

After setup installing lib to your project you just need only to call it using just few lines of code. It will return you a string with the results.

Usage

To show sample Snackbar

Snackbar.with(this,null)
        .type(Type.SUCCESS)
        .message("Profile updated successfully!")
        .duration(Duration.SHORT)
        .fillParent(true)
        .textAlign(Align.LEFT)
        .show();

This contain multiple pre-defined types as alert view background.

Type.SUCCESS  // Green color alert to show ok, success, approved type functions
Type.ERROR    // Red color alert to show error, failer type functions
Type.UPDATE   // Grey color alert to show update take place, working type functions
Type.WARNING  // Orange color alert to show alert type functions

Type.CUSTOM   // This can use to set custom color as background

If you need to change Text alignment, you can use

Align.RIGHT   // align right
Align.LEFT    // align left
Align.CENTER  // align center

You can use fillParent to match full width, when using Snackbar on Tablet devices ezgif com-video-to-gif

Let's take a look, how to set custom color as background

Snackbar.with(this,null)
        .type(Type.CUSTOM, 0xff00A7A5)
        .message("This is custom color!")
        .duration(Duration.LONG)
        .show();

We can use either pre-defined durations or custom duration as follow,

Duration.SHORT      // Show period of time
Duration.LONG       // Long time ( not more than 10 sec )
Duration.INFINITE   // Snackbar stay until we call dismiss

Duration.CUSTOM     // Use to set custom duration

Let's see how to a custom view to the Snackbar view

View view = getLayoutInflater().inflate(R.layout.custom_view, null);

Snackbar.with(this,null)
        .type(Type.UPDATE)
        .contentView(view, 76)
        .duration(Duration.SHORT)
        .show();
        
// since this is a wrapper lib, we need to send your custom view (layout resource) height in "dp", when setting view to the Snackbar.

When you are using custom view, you can/need to, change any view's settings before you set it as custom view to the Snackbar.

Currently there is a limitation. Custom layout need to contain parent layout as a RelativeLayout and add another ReletiveLayout with match_parent attribute. Inside the second RelativeLayout, add what you need to add, then it will fill the parent. If you need to align text in the custom layout, you need to do that change in the custom layout itself.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:orientation="vertical">
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
      
        
      
    </RelativeLayout>
</RelativeLayout>

i.e :

View view = getLayoutInflater().inflate(R.layout.custom_view, null);

TextView tv = (TextView) view.findViewById(R.id.sample);

Limitations

  • Currently min SDK is set to 16
  • Text Align feature will support only after API 17
  • Custom layout need to contain parent layout as a RelativeLayout, then it will fill the parent. If you need to align text in the custom layout, you need to do that change in the custom layout itself.

Output Generated

ezgif com-video-to-gif

Changelog

  • 1.4.1/1.4.2
    • Fixed Align.CENTER issue on Android devices below Android.M
  • 1.4.0
    • Add fill Snacbar view to full width. You can use "fillParent"
    • Text alignment added with "textAlign" and "Align" enum
  • 1.3.2
  • 1.3.1
    • Add max lines upto 10
  • 1.1.0
    • Fixed snackbar long value
  • 1.0.0
    • Stable the release with sample code
  • 0.0.1
    • Initial release

Author

Chathura Hettiarachchi, [email protected]

Checkout my other contributions, https://github.com/ChathuraHettiarachchi?tab=repositories

License

Copyright 2016 Chathura Hettiarachchi

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].