public DropDownWarning(Builder builder){ super(builder.context); warningMessage = builder.warningMessage; backgroundColor = builder.backgroundColor; foregroundColor = builder.foregroundColor; height = builder.height; interpolatorIn = builder.interpolatorIn; interpolatorOut = builder.interpolatorOut; animationLength = builder.animationLength; parent = builder.parent; addWarningView(); setUpLayoutParams(); initializeAnimation(); }
public DropDownWarning build(){ return new DropDownWarning(this); }
@Override public void onClick(View v) { if(on){ dropDownWarning.hide(); on = false; }else{ dropDownWarning.show(); dropDownWarning.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(getApplicationContext(),"DropDownWarning pressed", Toast.LENGTH_LONG).show(); } }); on = true; } } });
dropDownWarning = new DropDownWarning.Builder(getApplicationContext(),rootView).message("My Message").backgroundColor(0xff1976D2).foregroundColor(0xffffffff).interpolatorIn(new BounceInterpolator()).interpolatorOut(new AnticipateOvershootInterpolator()).textHeight(80).build(); assert button != null; button.setOnClickListener(new View.OnClickListener() {
private void addWarningView(){ textView = new TextView(getContext()); textView.setText(warningMessage); textView.setBackgroundColor(backgroundColor); textView.setGravity(Gravity.CENTER); textView.setPadding(0,12,0,12); textView.setVisibility(INVISIBLE); textView.setTextColor(foregroundColor); LayoutParams l = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height); textView.setLayoutParams(l); addView(textView); }
private void setUpLayoutParams(){ LayoutParams l = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); setLayoutParams(l); parent.addView(this); }