<commit_before># Snackbar
[![Build Status](https://travis-ci.org/nispok/snackbar.svg?branch=master)](https://travis-ci.org/nispok/snackbar) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Snackbar-brightgreen.svg)](https://android-arsenal.com/details/1/1160)

Library that implements <a href="http://www.google.com/design/spec/components/snackbars-and-toasts.html">Snackbars</a> from Google's <a href="http://www.google.com/design/spec/material-design/introduction.html">Material Design documentation</a>.
Works on API levels >= 8

<img src="./art/home.png" alt="Example App" style="width: 200px; height: 355px" />
<img src="./art/home-1line.png" alt="Example App" style="width: 200px; height: 355px" />
<img src="./art/home-2line.png" alt="Example App" style="width: 200px; height: 355px" />
<img src="./art/home-colored.png" alt="Example App" style="width: 200px; height: 355px" />
<img src="./art/list-1line.png" alt="Example App" style="width: 200px; height: 355px" />

## Installation
You can import the library from source as a module or grab via Gradle:
 <br />
 ```groovy
 compile 'com.nispok:snackbar:2.5.2'
 ```
## Usage
<br />
Using the <code>Snackbar</code> class is easy, this is how you would display it on an <code>Activity</code>:
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .text("Single-line snackbar") // text to display
    .show(this); // activity where it is displayed
```
If you want an action button to be displayed, just assign a label and an <code>ActionClickListener</code>:
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .text("Item deleted") // text to display
    .actionLabel("Undo") // action button label
    .actionListener(new ActionClickListener() {
        @Override
        public void onActionClicked() {
            Log.d(TAG, "Undoing something");
        }
     }) // action button's ActionClickListener
     .show(this); // activity where it is displayed
```
If you need to know when the <code>Snackbar</code> is shown or dismissed, assign a <code>EventListener</code> to it. This is useful if you need to move other objects while the <code>Snackbar</code> is displayed. For instance, you can move a Floating Action Button up while the <code>Snackbar</code> is on screen:
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .text("This will do something when dismissed") // text to display
    .eventListener(new EventListener() {
        @Override
        public void onShow(Snackbar snackbar) {
            myFloatingActionButton.moveUp(snackbar.getHeight());
        }
        @Override
        public void onShown(Snackbar snackbar) {
            Log.i(TAG, String.format("Snackbar shown. Width: %d Height: %d Offset: %d",
                    snackbar.getWidth(), snackbar.getHeight(),
                    snackbar.getOffset()));
        }
        @Override
        public void onDismiss(Snackbar snackbar) {
            myFloatingActionButton.moveDown(snackbar.getHeight());
        }
        @Override
        public void onDismissed(Snackbar snackbar) {
            Log.i(TAG, String.format("Snackbar dismissed. Width: %d Height: %d Offset: %d",
                                snackbar.getWidth(), snackbar.getHeight(),
                                snackbar.getOffset()));
        }
    }) // Snackbar's EventListener
    .show(this); // activity where it is displayed
```
There are two <code>Snackbar</code> types: single-line (default) and multi-line (2 lines max). You can also set the duration of the <code>Snackbar</code> similar to a <a href="http://developer.android.com/reference/android/widget/Toast.html"><code>Toast</code></a>. Animation disabling is also possible.
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .type(Snackbar.SnackbarType.MULTI_LINE) // Set is as a multi-line snackbar
    .text("This is a multi-line snackbar. Keep in mind that snackbars are " +
        "meant for VERY short messages") // text to be displayed
    .duration(Snackbar.SnackbarDuration.LENGTH_SHORT) // make it shorter
    .animation(false) // don't animate it
    .show(this); // where it is displayed
```
You can also change the <code>Snackbar</code>'s colors.
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .text("Different colors this time") // text to be displayed
    .textColor(Color.GREEN) // change the text color
    .color(Color.BLUE) // change the background color
    .actionLabel("Action") // action button label
    .actionColor(Color.RED) // action button label color
    .actionListener(new ActionClickListener() {
        @Override
        public void onActionClicked() {
            Log.d(TAG, "Doing something");
        }
     }) // action button's ActionClickListener    
    .show(this); // activity where it is displayed
```
Finally, you can attach the <code>Snackbar</code> to a AbsListView (ListView, GridView) or a RecyclerView.
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .type(Snackbar.SnackbarType.MULTI_LINE) // Set is as a multi-line snackbar
    .text(R.string.message) // text to be displayed
    .duration(Snackbar.SnackbarDuration.LENGTH_LONG) // make it shorter
    .animation(false) // don't animate it
    .attachToAbsListView(listView) // Attach to ListView - attachToRecyclerView() is for RecyclerViews
    .show(this); // where it is displayed
```
It uses [R<NAME>ik's SwipeToDismiss sample code](https://github.com/romannurik/android-swipetodismiss) to implement the swipe-to-dismiss functionality. This is enabled by default. You can disable this if you don't want this functionality:<br />
**NOTE:** This has no effect on apps running on APIs < 11; swiping will always be disabled
<br />
```java
Snackbar.with(SnackbarSampleActivity.this) // context
    .text("Can't swipe this") // text to be displayed
    .swipeToDismiss(false) // disable swipe-to-dismiss functionality
    .show(this); // activity where it is displayed
```
<commit_msg>Update Sample Code<commit_after># Snackbar
[![Build Status](https://travis-ci.org/nispok/snackbar.svg?branch=master)](https://travis-ci.org/nispok/snackbar) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Snackbar-brightgreen.svg)](https://android-arsenal.com/details/1/1160)

Library that implements <a href="http://www.google.com/design/spec/components/snackbars-and-toasts.html">Snackbars</a> from Google's <a href="http://www.google.com/design/spec/material-design/introduction.html">Material Design documentation</a>.
Works on API levels >= 8

<img src="./art/home.png" alt="Example App" style="width: 200px; height: 355px" />
<img src="./art/home-1line.png" alt="Example App" style="width: 200px; height: 355px" />
<img src="./art/home-2line.png" alt="Example App" style="width: 200px; height: 355px" />
<img src="./art/home-colored.png" alt="Example App" style="width: 200px; height: 355px" />
<img src="./art/list-1line.png" alt="Example App" style="width: 200px; height: 355px" />

## Installation
You can import the library from source as a module or grab via Gradle:
 <br />
 ```groovy
 compile 'com.nispok:snackbar:2.5.2'
 ```
## Usage
<br />
Using the <code>Snackbar</code> class is easy, this is how you would display it on an <code>Activity</code>:
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .text("Single-line snackbar") // text to display
    .show(this); // activity where it is displayed
```
If you want an action button to be displayed, just assign a label and an <code>ActionClickListener</code>:
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .text("Item deleted") // text to display
    .actionLabel("Undo") // action button label
    .actionListener(new ActionClickListener() {
        @Override
        public void onActionClicked(Snackbar snackbar) {
            Log.d(TAG, "Undoing something");
        }
     }) // action button's ActionClickListener
     .show(this); // activity where it is displayed
```
If you need to know when the <code>Snackbar</code> is shown or dismissed, assign a <code>EventListener</code> to it. This is useful if you need to move other objects while the <code>Snackbar</code> is displayed. For instance, you can move a Floating Action Button up while the <code>Snackbar</code> is on screen:
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .text("This will do something when dismissed") // text to display
    .eventListener(new EventListener() {
        @Override
        public void onShow(Snackbar snackbar) {
            myFloatingActionButton.moveUp(snackbar.getHeight());
        }
        @Override
        public void onShown(Snackbar snackbar) {
            Log.i(TAG, String.format("Snackbar shown. Width: %d Height: %d Offset: %d",
                    snackbar.getWidth(), snackbar.getHeight(),
                    snackbar.getOffset()));
        }
        @Override
        public void onDismiss(Snackbar snackbar) {
            myFloatingActionButton.moveDown(snackbar.getHeight());
        }
        @Override
        public void onDismissed(Snackbar snackbar) {
            Log.i(TAG, String.format("Snackbar dismissed. Width: %d Height: %d Offset: %d",
                                snackbar.getWidth(), snackbar.getHeight(),
                                snackbar.getOffset()));
        }
    }) // Snackbar's EventListener
    .show(this); // activity where it is displayed
```
There are two <code>Snackbar</code> types: single-line (default) and multi-line (2 lines max). You can also set the duration of the <code>Snackbar</code> similar to a <a href="http://developer.android.com/reference/android/widget/Toast.html"><code>Toast</code></a>. Animation disabling is also possible.
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .type(Snackbar.SnackbarType.MULTI_LINE) // Set is as a multi-line snackbar
    .text("This is a multi-line snackbar. Keep in mind that snackbars are " +
        "meant for VERY short messages") // text to be displayed
    .duration(Snackbar.SnackbarDuration.LENGTH_SHORT) // make it shorter
    .animation(false) // don't animate it
    .show(this); // where it is displayed
```
You can also change the <code>Snackbar</code>'s colors.
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .text("Different colors this time") // text to be displayed
    .textColor(Color.GREEN) // change the text color
    .color(Color.BLUE) // change the background color
    .actionLabel("Action") // action button label
    .actionColor(Color.RED) // action button label color
    .actionListener(new ActionClickListener() {
        @Override
        public void onActionClicked(Snackbar snackbar) {
            Log.d(TAG, "Doing something");
        }
     }) // action button's ActionClickListener    
    .show(this); // activity where it is displayed
```
Finally, you can attach the <code>Snackbar</code> to a AbsListView (ListView, GridView) or a RecyclerView.
<br />
```java
Snackbar.with(getApplicationContext()) // context
    .type(Snackbar.SnackbarType.MULTI_LINE) // Set is as a multi-line snackbar
    .text(R.string.message) // text to be displayed
    .duration(Snackbar.SnackbarDuration.LENGTH_LONG) // make it shorter
    .animation(false) // don't animate it
    .attachToAbsListView(listView) // Attach to ListView - attachToRecyclerView() is for RecyclerViews
    .show(this); // where it is displayed
```
It uses [R<NAME>'s SwipeToDismiss sample code](https://github.com/romannurik/android-swipetodismiss) to implement the swipe-to-dismiss functionality. This is enabled by default. You can disable this if you don't want this functionality:<br />
**NOTE:** This has no effect on apps running on APIs < 11; swiping will always be disabled
<br />
```java
Snackbar.with(SnackbarSampleActivity.this) // context
    .text("Can't swipe this") // text to be displayed
    .swipeToDismiss(false) // disable swipe-to-dismiss functionality
    .show(this); // activity where it is displayed
```

{'fraction_non_alphanumeric': 0.13354425110315543, 'fraction_numerical': 0.007826159353925569, 'mean_word_length': 3.3791469194312795, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 97, 'https://': 10, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4272795', 'n_tokens_mistral': 3751, 'n_tokens_neox': 3541, 'n_words': 1050}