package org.ligi.snackengage.snacks;

import android.support.annotation.StringRes;
import android.support.design.widget.Snackbar;
import android.view.View;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.ligi.snackengage.SnackContext;
import org.ligi.snackengage.conditions.SnackCondition;

public abstract class BaseSnack implements Snack {

    protected SnackContext snackContext;
    protected List<SnackCondition> conditionList = new ArrayList<>();

    @Override
    public boolean opportunity(final SnackContext snackContext) {
        this.snackContext = snackContext;

        for (final SnackCondition snackCondition : conditionList) {
            if (!snackCondition.isAppropriate(snackContext,this)) {
                return false;
            }
        }

        Snackbar.make(snackContext.getRootView(), getText(), Snackbar.LENGTH_LONG).setAction(getActionText(), new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                snackContext.getStats().registerSnackClick(BaseSnack.this);
                engage();
            }
        }).show();
        return true;
    }

    public abstract void engage();

    @StringRes
    public abstract int getText();

    @StringRes
    public abstract int getActionText();

    public Snack withConditions(SnackCondition... conditions) {
        Collections.addAll(conditionList, conditions);
        return this;
    }
}

@@ -31,16 +31,58 @@
 nacks;%0A%0A
+import android.support.annotation.IntDef;%0A
 import a
@@ -191,16 +191,100 @@
 w.View;%0A
+import java.lang.annotation.Retention;%0Aimport java.lang.annotation.RetentionPolicy;%0A
 import j
@@ -506,16 +506,379 @@
 nack %7B%0A%0A
+    public static final int DURATION_INDEFINITE = -2;%0A    public static final int DURATION_SHORT = -1;%0A    public static final int DURATION_LONG = 0;%0A%0A    @IntDef(%7BDURATION_INDEFINITE, DURATION_SHORT, DURATION_LONG%7D)%0A    @Retention(RetentionPolicy.SOURCE)%0A    public @interface SnackDuration %7B%0A    %7D%0A%0A    @SnackDuration%0A    private int duration = DURATION_LONG;%0A%0A
     prot
@@ -1231,16 +1231,17 @@
 Context,
+ 
 this)) %7B
@@ -1361,28 +1361,16 @@
 (), 
-Snackbar.LENGTH_LONG
+duration
 ).se
@@ -1796,24 +1796,147 @@
 ionText();%0A%0A
+    public Snack withDuration(@SnackDuration int duration) %7B%0A        this.duration = duration;%0A        return this;%0A    %7D%0A%0A
     public S

Add option to add duration