/**
   * Instantiates a new SuperCardToast with a type. <br>
   *
   * @param context should be Activity
   * @param type choose from SuperToast.Type <br>
   */
  public SuperCardToast(Context context, Type type) {

    if (context instanceof Activity) {

      this.mContext = context;

      final Activity activity = (Activity) context;

      mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      this.mType = type;

      if (activity.findViewById(R.id.card_container) != null) {

        mViewGroup = (LinearLayout) activity.findViewById(R.id.card_container);

        if (type == Type.BUTTON) {

          mToastView = mLayoutInflater.inflate(R.layout.supercardtoast_button, mViewGroup, false);

          mToastButton = (Button) mToastView.findViewById(R.id.button);

          mDividerView = mToastView.findViewById(R.id.divider);

          mToastButton.setOnTouchListener(mTouchDismissListener);

        } else if (type == Type.PROGRESS) {

          mToastView =
              mLayoutInflater.inflate(R.layout.supercardtoast_progresscircle, mViewGroup, false);

          mProgressBar = (ProgressBar) mToastView.findViewById(R.id.progressBar);

        } else if (type == Type.PROGRESS_HORIZONTAL) {

          mToastView =
              mLayoutInflater.inflate(
                  R.layout.supercardtoast_progresshorizontal, mViewGroup, false);

          mProgressBar = (ProgressBar) mToastView.findViewById(R.id.progressBar);

        } else {

          mToastView = mLayoutInflater.inflate(R.layout.supercardtoast, mViewGroup, false);
        }

        mMessageTextView = (TextView) mToastView.findViewById(R.id.message_textView);

        mRootLayout = (LinearLayout) mToastView.findViewById(R.id.root_layout);

      } else {

        throw new IllegalArgumentException(TAG + ERROR_CONTAINERNULL);
      }

    } else {

      throw new IllegalArgumentException(TAG + ERROR_CONTEXTNOTACTIVITY);
    }
  }
  /**
   * Instantiates a new SuperCardToast. <br>
   *
   * @param context should be Activity
   */
  public SuperCardToast(Context context) {

    if (context instanceof Activity) {

      this.mContext = context;

      this.mType = Type.STANDARD;

      final Activity activity = (Activity) context;

      mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      if (activity.findViewById(R.id.card_container) != null) {

        mViewGroup = (LinearLayout) activity.findViewById(R.id.card_container);

        mToastView = mLayoutInflater.inflate(R.layout.supercardtoast, mViewGroup, false);

        mMessageTextView = (TextView) mToastView.findViewById(R.id.message_textView);

        mRootLayout = (LinearLayout) mToastView.findViewById(R.id.root_layout);

      } else {

        throw new IllegalArgumentException(TAG + ERROR_CONTAINERNULL);
      }

    } else {

      throw new IllegalArgumentException(TAG + ERROR_CONTEXTNOTACTIVITY);
    }
  }
  private void init() {
    setVerticalFadingEdgeEnabled(false);

    headerContainer =
        (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.ptr_header, null);
    header = (RelativeLayout) headerContainer.findViewById(R.id.ptr_id_header);
    text = (TextView) header.findViewById(R.id.ptr_id_text);
    lastUpdatedTextView = (TextView) header.findViewById(R.id.ptr_id_last_updated);
    image = (ImageView) header.findViewById(R.id.ptr_id_image);
    spinner = (ProgressBar) header.findViewById(R.id.ptr_id_spinner);

    pullToRefreshText = getContext().getString(R.string.ptr_pull_to_refresh);
    releaseToRefreshText = getContext().getString(R.string.ptr_release_to_refresh);
    refreshingText = getContext().getString(R.string.ptr_refreshing);
    lastUpdatedText = getContext().getString(R.string.ptr_last_updated);

    flipAnimation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    flipAnimation.setInterpolator(new LinearInterpolator());
    flipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION);
    flipAnimation.setFillAfter(true);

    reverseFlipAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseFlipAnimation.setInterpolator(new LinearInterpolator());
    reverseFlipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION);
    reverseFlipAnimation.setFillAfter(true);

    addHeaderView(headerContainer);
    setState(State.PULL_TO_REFRESH);
    scrollbarEnabled = isVerticalScrollBarEnabled();

    ViewTreeObserver vto = header.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new PTROnGlobalLayoutListener());

    super.setOnItemClickListener(new PTROnItemClickListener());
    super.setOnItemLongClickListener(new PTROnItemLongClickListener());
  }