|
| 1 | +package cn.byhieg.designpatterntutorial.builder; |
| 2 | + |
| 3 | +/** |
| 4 | + * Created by shiqifeng on 2017/5/7. |
| 5 | + * Mail byhieg@gmail.com |
| 6 | + */ |
| 7 | +public class SimpleDialogController { |
| 8 | + |
| 9 | + private String icon; |
| 10 | + private String title; |
| 11 | + private String message; |
| 12 | + private String positiveButton; |
| 13 | + private String negativeButton; |
| 14 | + |
| 15 | + public void setIcon(String icon) { |
| 16 | + this.icon = icon; |
| 17 | + } |
| 18 | + |
| 19 | + public void setTitle(String title) { |
| 20 | + this.title = title; |
| 21 | + } |
| 22 | + |
| 23 | + public void setMessage(String message) { |
| 24 | + this.message = message; |
| 25 | + } |
| 26 | + |
| 27 | + public void setPositiveButton(String positiveButton) { |
| 28 | + this.positiveButton = positiveButton; |
| 29 | + } |
| 30 | + |
| 31 | + public void setNegativeButton(String negativeButton) { |
| 32 | + this.negativeButton = negativeButton; |
| 33 | + } |
| 34 | + |
| 35 | + public String getIcon() { |
| 36 | + return icon; |
| 37 | + } |
| 38 | + |
| 39 | + public String getTitle() { |
| 40 | + return title; |
| 41 | + } |
| 42 | + |
| 43 | + public String getMessage() { |
| 44 | + return message; |
| 45 | + } |
| 46 | + |
| 47 | + public String getPositiveButton() { |
| 48 | + return positiveButton; |
| 49 | + } |
| 50 | + |
| 51 | + public String getNegativeButton() { |
| 52 | + return negativeButton; |
| 53 | + } |
| 54 | + |
| 55 | + public static class DialogParams{ |
| 56 | + public String icon; |
| 57 | + public String title; |
| 58 | + public String message; |
| 59 | + public String positiveButton; |
| 60 | + public String negativeButton; |
| 61 | + |
| 62 | + public void apply(SimpleDialogController controller) { |
| 63 | + if (icon != null) { |
| 64 | + controller.setIcon(icon); |
| 65 | + } |
| 66 | + if (title != null) { |
| 67 | + controller.setTitle(title); |
| 68 | + } |
| 69 | + if (message != null) { |
| 70 | + controller.setMessage(message); |
| 71 | + } |
| 72 | + if (positiveButton != null) { |
| 73 | + controller.setPositiveButton(positiveButton); |
| 74 | + } |
| 75 | + if (negativeButton != null) { |
| 76 | + controller.setNegativeButton(negativeButton); |
| 77 | + } |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | +} |
0 commit comments