KSnack

Additional

Language
Java
Version
1.1.2 (Apr 19, 2020)
Created
Oct 29, 2018
Updated
Oct 7, 2020 (Retired)
Owner
Onur Kağan ALDEMİR (onurkagan)
Contributors
Onur Kağan ALDEMİR (onurkagan)
qijaz (qijaz221)
Tanishq (Tanishq777)
3
Activity
Badge
Generate
Download
Source code

Show card

KSnack

You can create customized Snackbar with KSnack. KSnack has 2 view type; KSnack and Minimal KSnack.

Minimal KSnack

  1. Initialize Minimal KSnack.
MinimalKSnack minimalKSnack = new MinimalKSnack(MainActivity.this);
  1. Set Features. Styles; STYLE_DEFAULT, STYLE_INFO, STYLE_SUCCESS, STYLE_ERROR, STYLE_WARNING
minimalKSnack
    .setMessage("This is minimal KSnack !") // message
    .setStyle(MinimalKSnackStyle.STYLE_SUCCESS) // style
    .setBackgroundColor(R.color.colorGray) // background color
    .setBackgrounDrawable(R.drawable.background_ex_one) // background drawable
    .setAnimation(Fade.In.getAnimation(), Fade.Out.getAnimation()) // show and hide animations
    .setDuration(4000) // you can use for auto close.
    .alignBottom() // bottom align option.
    .show(); 
  1. Close Minimal KSnack.
minimalKSnack.dismiss();

KSnack

  1. Initialize KSnack.
KSnack kSnack = new KSnack(MainActivity.this);
  1. Set Features.
kSnack
  .setListener(new KSnackBarEventListener() { // listener
      @Override
      public void showedSnackBar() {
          System.out.println("Showed");
      }

      @Override
      public void stoppedSnackBar() {
          System.out.println("Stopped");
      }
  })
  .setAction("Text", new View.OnClickListener() { // name and clicklistener
      @Override
      public void onClick(View v) {
          System.out.println("Your action !");
      }
  })
  .setMessage("Your message.") // message
  .setTextColor(R.color.white) // message text color
  .setBackColor(R.color.colorGray) // background color
  .setButtonTextColor(R.color.white) // action button text color
  .setBackgrounDrawable(R.drawable.background_ex_one) // background drawable
  .setAnimation(Slide.Up.getAnimation(kSnack.getSnackView()), Slide.Down.getAnimation(kSnack.getSnackView()))
  .setDuration(4000) // you can use for auto close.
  .show(); 
  1. Close Minimal KSnack.
kSnack.dismiss();

Animations

1. Fade

kSnack.setAnimation(Fade.In.getAnimation(), Fade.Out.getAnimation()) // show and hide animations

2. Slide

minimalKSnack.setAnimation(Slide.Down.getAnimation(minimalKSnack.getSnackView()), Slide.Up.getAnimation(minimalKSnack.getSnackView()))   

Slide animations need KSnack or MinimalKSnack view. You should use getSnackView() or getMinimalSnackView() functions for correct view object.

Installation

Step 1. Add the JitPack repository to your build file.

allprojects {
    repositories {
      maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency.

dependencies {
  implementation 'com.github.onurkagan:KSnack:1.1.2'
}