@@ -53,29 +53,29 @@ public abstract class FormulaBrick extends BrickBaseType implements View.OnClick
53
53
@ XStreamAlias ("formulaList" )
54
54
ConcurrentFormulaHashMap formulaMap = new ConcurrentFormulaHashMap ();
55
55
56
- public transient BiMap <BrickField , Integer > brickFieldToTextViewIdMap = HashBiMap .create (2 );
56
+ public transient BiMap <FormulaField , Integer > brickFieldToTextViewIdMap = HashBiMap .create (2 );
57
57
58
- public Formula getFormulaWithBrickField (BrickField brickField ) throws IllegalArgumentException {
59
- if (formulaMap .containsKey (brickField )) {
60
- return formulaMap .get (brickField );
58
+ public Formula getFormulaWithBrickField (FormulaField formulaField ) throws IllegalArgumentException {
59
+ if (formulaMap .containsKey (formulaField )) {
60
+ return formulaMap .get (formulaField );
61
61
} else {
62
62
throw new IllegalArgumentException ("Incompatible Brick Field: " + this .getClass ().getSimpleName ()
63
- + " does have BrickField." + brickField .toString ());
63
+ + " does not have BrickField." + formulaField .toString ());
64
64
}
65
65
}
66
66
67
- public void setFormulaWithBrickField (BrickField brickField , Formula formula ) throws IllegalArgumentException {
68
- if (formulaMap .containsKey (brickField )) {
69
- formulaMap .replace (brickField , formula );
67
+ public void setFormulaWithBrickField (FormulaField formulaField , Formula formula ) throws IllegalArgumentException {
68
+ if (formulaMap .containsKey (formulaField )) {
69
+ formulaMap .replace (formulaField , formula );
70
70
} else {
71
71
throw new IllegalArgumentException ("Incompatible Brick Field: Cannot set BrickField."
72
- + brickField .toString () + " fot " + this .getClass ().getSimpleName ());
72
+ + formulaField .toString () + " for " + this .getClass ().getSimpleName ());
73
73
}
74
74
}
75
75
76
- protected void addAllowedBrickField (BrickField brickField , int textViewResourceId ) {
77
- formulaMap .putIfAbsent (brickField , new Formula (0 ));
78
- brickFieldToTextViewIdMap .put (brickField , textViewResourceId );
76
+ protected void addAllowedBrickField (FormulaField formulaField , int textViewResourceId ) {
77
+ formulaMap .putIfAbsent (formulaField , new Formula (0 ));
78
+ brickFieldToTextViewIdMap .put (formulaField , textViewResourceId );
79
79
}
80
80
81
81
@ Override
@@ -86,11 +86,11 @@ public void addRequiredResources(final ResourcesSet requiredResourcesSet) {
86
86
}
87
87
}
88
88
89
- public void replaceFormulaBrickField (BrickField oldBrickField , BrickField newBrickField ) {
90
- if (formulaMap .containsKey (oldBrickField )) {
91
- Formula brickFormula = formulaMap .get (oldBrickField );
92
- formulaMap .remove (oldBrickField );
93
- formulaMap .put (newBrickField , brickFormula );
89
+ public void replaceFormulaBrickField (FormulaField oldFormulaField , FormulaField newFormulaField ) {
90
+ if (formulaMap .containsKey (oldFormulaField )) {
91
+ Formula brickFormula = formulaMap .get (oldFormulaField );
92
+ formulaMap .remove (oldFormulaField );
93
+ formulaMap .put (newFormulaField , brickFormula );
94
94
}
95
95
}
96
96
@@ -104,17 +104,17 @@ public Brick clone() throws CloneNotSupportedException {
104
104
@ Override
105
105
public View getView (Context context ) {
106
106
super .getView (context );
107
- for (BiMap .Entry <BrickField , Integer > entry : brickFieldToTextViewIdMap .entrySet ()) {
108
- TextView brickFieldView = view .findViewById (entry .getValue ());
109
- brickFieldView .setText (getFormulaWithBrickField (entry .getKey ()).getTrimmedFormulaString (context ));
107
+ for (BiMap .Entry <FormulaField , Integer > entry : brickFieldToTextViewIdMap .entrySet ()) {
108
+ TextView formulaFieldView = view .findViewById (entry .getValue ());
109
+ formulaFieldView .setText (getFormulaWithBrickField (entry .getKey ()).getTrimmedFormulaString (context ));
110
110
}
111
111
return view ;
112
112
}
113
113
114
114
public void setClickListeners () {
115
- for (BiMap .Entry <BrickField , Integer > entry : brickFieldToTextViewIdMap .entrySet ()) {
116
- TextView brickFieldView = view .findViewById (entry .getValue ());
117
- brickFieldView .setOnClickListener (this );
115
+ for (BiMap .Entry <FormulaField , Integer > entry : brickFieldToTextViewIdMap .entrySet ()) {
116
+ TextView formulaFieldView = view .findViewById (entry .getValue ());
117
+ formulaFieldView .setOnClickListener (this );
118
118
}
119
119
}
120
120
@@ -127,12 +127,12 @@ public ConcurrentFormulaHashMap getFormulaMap() {
127
127
return formulaMap ;
128
128
}
129
129
130
- public TextView getTextView (BrickField brickField ) {
131
- return view .findViewById (brickFieldToTextViewIdMap .get (brickField ));
130
+ public TextView getTextView (FormulaField formulaField ) {
131
+ return view .findViewById (brickFieldToTextViewIdMap .get (formulaField ));
132
132
}
133
133
134
- public void highlightTextView (BrickField brickField ) {
135
- TextView formulaTextField = view . findViewById ( brickFieldToTextViewIdMap . get ( brickField ) );
134
+ public void highlightTextView (FormulaField formulaField ) {
135
+ TextView formulaTextField = getTextView ( formulaField );
136
136
137
137
formulaTextField .getBackground ().mutate ()
138
138
.setColorFilter (view .getContext ().getResources ()
@@ -152,30 +152,30 @@ public void showFormulaEditorToEditFormula(View view) {
152
152
}
153
153
}
154
154
155
- public BrickField getDefaultBrickField () {
155
+ public FormulaField getDefaultBrickField () {
156
156
return formulaMap .keys ().nextElement ();
157
157
}
158
158
159
- boolean isBrickFieldANumber (BrickField brickField ) {
160
- return getFormulaWithBrickField (brickField ).isNumber ();
159
+ boolean isBrickFieldANumber (FormulaField formulaField ) {
160
+ return getFormulaWithBrickField (formulaField ).isNumber ();
161
161
}
162
162
163
163
public View getCustomView (Context context ) {
164
164
throw new IllegalStateException ("There is no custom view for the " + getClass ().getSimpleName () + "." );
165
165
}
166
166
167
- public Brick . BrickField getBrickFieldFromTextViewId (int textViewId ) {
167
+ public FormulaField getBrickFieldFromTextViewId (int textViewId ) {
168
168
return brickFieldToTextViewIdMap .inverse ().get (textViewId );
169
169
}
170
170
171
- protected void setSecondsLabel (View view , BrickField brickField ) {
171
+ protected void setSecondsLabel (View view , FormulaField formulaField ) {
172
172
TextView textView = view .findViewById (R .id .brick_seconds_label );
173
173
Context context = textView .getContext ();
174
174
175
- if (getFormulaWithBrickField (brickField ).isNumber ()) {
175
+ if (getFormulaWithBrickField (formulaField ).isNumber ()) {
176
176
try {
177
177
Sprite sprite = ProjectManager .getInstance ().getCurrentSprite ();
178
- Double formulaValue = formulaMap .get (brickField ).interpretDouble (sprite );
178
+ Double formulaValue = formulaMap .get (formulaField ).interpretDouble (sprite );
179
179
textView .setText (context .getResources ().getQuantityString (R .plurals .second_plural ,
180
180
Utils .convertDoubleToPluralInteger (formulaValue )));
181
181
return ;
0 commit comments