/** * Public constructor for a SuperActivityToast. * * @param context An Activity Context */ public SuperActivityToast(@NonNull Context context) { super(context); if (!(context instanceof Activity)) { throw new IllegalArgumentException("SuperActivityToast Context must be an Activity."); } this.mContext = context; this.mStyle = this.getStyle(); // Style is created in the super(context) call // Set the default ViewGroup as the Activity's content this.mViewGroup = (ViewGroup) ((Activity) context).findViewById(android.R.id.content); }
/** * Public constructor for a SuperActivityToast. * * @param context An Activity Context * @param type The desired SuperActivityToast type */ public SuperActivityToast(@NonNull Context context, @Style.Type int type) { super(context, type); if (!(context instanceof Activity)) { throw new IllegalArgumentException("SuperActivityToast Context must be an Activity."); } this.mContext = context; this.mStyle = this.getStyle(); // Style is created in the super(context) call // Set the default ViewGroup as the Activity's content this.mViewGroup = (ViewGroup) ((Activity) context).findViewById(android.R.id.content); }
/** * Public constructor for a SuperActivityToast. * * @param context An Activity Context * @param style The desired Style * @param type The desired SuperActivityToast type */ public SuperActivityToast(@NonNull Context context, @NonNull Style style, @Style.Type int type) { super(context, style, type); if (!(context instanceof Activity)) { throw new IllegalArgumentException("SuperActivityToast Context must be an Activity."); } this.mContext = context; this.mStyle = this.getStyle(); // Style is created in the super(context) call // Set the default ViewGroup as the Activity's content this.mViewGroup = (ViewGroup) ((Activity) context).findViewById(android.R.id.content); }
/** * Public constructor for a SuperActivityToast. * * @param context An Activity Context * @param style The desired Style * @param type The desired SuperActivityToast type * @param viewGroupId The id of the ViewGroup to attach the SuperActivityToast to */ public SuperActivityToast(@NonNull Context context, @NonNull Style style, @Style.Type int type, @IdRes int viewGroupId) { super(context, style, type, viewGroupId); if (!(context instanceof Activity)) { throw new IllegalArgumentException("SuperActivityToast Context must be an Activity."); } this.mContext = context; this.mStyle = this.getStyle(); // Style is created in the super(context) call // Try to find the ViewGroup id in the layout this.mViewGroup = (ViewGroup) ((Activity) context).findViewById(viewGroupId); if (this.mViewGroup == null) { Log.e(getClass().getName(), "Could not find a ViewGroup with id " + String.valueOf(viewGroupId)); this.mViewGroup = (ViewGroup) ((Activity) context).findViewById(android.R.id.content); } }