jitendra7020 / SnackBar

SnackBar messages for Android Applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SnackBar

Android Arsenal

#Designed after the docs at Google Material Design

Gif imgone

#Features

  • Customization including message, action message, action color, action click handle, and animation duration
  • Tablet support
  • Callbacks for the different SnackBar states (started, actionClicked, finished)
  • One Message at a time
  • Support for Api version 14+

#Using SnackBar

Using SnackBar is simple, just one line of code is needed!

SnackBar.show(getActivity(), R.string.hello_world);

Or if you want to set an action

SnackBar.show(getActivity(), R.string.hello_world, R.string.undo,onClickListener);

#Customization

SnackBars can be customizedby creating a SnackBarItem with the Builder factory

SnackBarItem sbi = new SnackBarItem.Builder().setMessage("Message")
.setActionMessage("Action")
.setObject(myObject)
.setActionClickListener(myClickListener)
.setActionMessageColor(getResources().getColor(R.color.my_red))
.setActionMessagePressedColor(getResources().getColor(R.color.my_blue))
.setDuration(5000)
.setSnackBarListener(myListener)
.build();

SnackBar.show(getActivity(),sbi);

Receive callbacks from SnackBars with an Object

// Called when the SnackBar begins to animate
@Override
publc void onSnackBarStarted(Object object){
}

// Called when the action button is pressed
@Override
public void onSnackBarAction(Object object){
}

// Called when the SnackBar finishes with its animation
// Will be called if the action button is pressed
@Override
public void onSnackBarFinished(Object object){
}

Canceling SnackBars

When your activity goes into a Paused or Destroyed state, remove the SnackBars from the queue

SnackBar.cancelSnackBars(getActivity());

#Contribution Pull requests are welcomed and encouraged. If you experience any bugs, please file an issue

About

SnackBar messages for Android Applications

License:Apache License 2.0