public DropDownWarning build(){ return new DropDownWarning(this); }
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(); }
@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; } } });
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); }