/** * 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); } }