Slide 58
Slide 58 text
public class UndoToast {
public interface OnDismissListener {
void onDismiss(View view, Parcelable token);
}
private final Context mContext;
private final View mView;
private final TextView mTextView;
private Style mStyle;
private OnDismissListener mOnDismissListener;
public UndoToast(@NonNull Context context) {
this.mContext = context;
this.mStyle = new Style();
this.mStyle.type = Style.TYPE_STANDARD;
final LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.mView = onCreateView(context, layoutInflater, Style.TYPE_STANDARD);
this.mTextView = (TextView) this.mView.findViewById(R.id.message);
}
protected UndoToast(@NonNull Context context, @Style.Type int type) {
this.mContext = context;
this.mStyle = new Style();
this.mStyle.type = type;
final LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.mView = onCreateView(context, layoutInflater, type);
this.mTextView = (TextView) this.mView.findViewById(R.id.message);
}
protected UndoToast(@NonNull Context context, @NonNull Style style, @Style.Type int type) {
this.mContext = context;
this.mStyle = style;
this.mStyle.type = type;
final LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.mView = onCreateView(context, layoutInflater, type);
this.mTextView = (TextView) this.mView.findViewById(R.id.message);
}
protected UndoToast(@NonNull Context context, @NonNull Style style, @Style.Type int type, @IdRes int viewGroupID) {
this.mContext = context;
this.mStyle = style;
this.mStyle.type = type;
// TYPE_BUTTON styles are the only ones that look different from the styles set by the Style() constructor
if (type == Style.TYPE_BUTTON) {
this.mStyle.yOffset = BackgroundUtils.convertToDIP(24);
this.mStyle.width = FrameLayout.LayoutParams.MATCH_PARENT;
}
final LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.mView = onCreateView(context, layoutInflater, type);
this.mTextView = (TextView) this.mView.findViewById(R.id.message);