Ejemplo n.º 1
0
  public void setTextStatus(String msn, boolean hasError) {
    if (mActivity != null) {
      mSnackbar =
          Snackbar.with(mActivity)
              .type(SnackbarType.MULTI_LINE)
              .text(msn)
              .animation(false)
              .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE);

      if (hasError) {
        mSnackbar
            .actionLabel("Volver a Intenar")
            .actionListener(
                new ActionClickListener() {
                  @Override
                  public void onActionClicked(Snackbar snackbar) {
                    snackbar.dismiss();
                    searchDataInfo(callBack);
                  }
                })
            .color(Color.RED);
      }
      SnackbarManager.show(mSnackbar, mActivity);
    } else {
      Toast.makeText(mContext, msn, Toast.LENGTH_LONG).show();
    }
  }
 private static void show(Activity activity, int msg, Style style, Integer tempo) {
   Snackbar snackbar = Snackbar.with(activity).text(activity.getResources().getText(msg));
   switch (style) {
     case INFO:
       snackbar.color(Color.BLUE);
       break;
     case ALERT:
       snackbar.color(Color.RED);
       break;
     case CONFIRM:
       snackbar.color(Color.GREEN);
       break;
   }
   if (tempo != null) {
     snackbar.duration(tempo);
   }
   snackbar.type(SnackbarType.MULTI_LINE);
   snackbar.actionLabel(activity.getResources().getString(R.string.close));
   snackbar.actionListener(
       new ActionClickListener() {
         @Override
         public void onActionClicked(Snackbar snackbar) {
           SnackbarManager.dismiss();
         }
       });
   SnackbarManager.show(snackbar);
 }