@@ -147,156 +147,64 @@ void removeSpans(Editable e, Class<? extends CharacterStyle> type) {
147
147
});
148
148
149
149
}
150
-
151
-
152
-
153
- //the user will be able to change color of the view as he wishes
154
- public void setBgColor (String color ) throws Error {
155
-
150
+ //check string's type is color
151
+ public void checkColor (String color )throws Error {
156
152
color = color .trim ();
157
153
158
154
if (!color .contains ("#" )) {
159
155
throw new Error ("SyntaxView Error : Invalid Color" );
160
156
}
161
157
if (TextUtils .isEmpty (color )) {
162
158
throw new Error ("SyntaxView Error : Empty Color String" );
163
-
164
159
}
165
160
if (color .length () != 7 ) {
166
161
throw new Error ("SyntaxView Error : Unknown Color" );
167
-
168
162
}
169
- code .setBackgroundColor (Color .parseColor (color ));
170
163
}
171
164
172
- public void setKeywordsColor (String color ) throws Error {
173
- color = color .trim ();
174
-
175
- if (!color .contains ("#" )) {
176
- throw new Error ("SyntaxView Error : Invalid Color" );
177
- }
178
- if (TextUtils .isEmpty (color )) {
179
- throw new Error ("SyntaxView Error : Empty Color String" );
180
-
181
- }
182
- if (color .length () != 7 ) {
183
- throw new Error ("SyntaxView Error : Unknown Color" );
165
+ //the user will be able to change color of the view as he wishes
166
+ public void setBgColor (String color ) {
167
+ checkColor (color );
168
+ code .setBackgroundColor (Color .parseColor (color ));
169
+ }
184
170
185
- }
171
+ public void setKeywordsColor (String color ) {
172
+ checkColor (color );
186
173
keywords .setColor (color );
187
174
}
188
175
189
- public void setNumbersColor (String color ) throws Error {
190
- color = color .trim ();
191
-
192
- if (!color .contains ("#" )) {
193
- throw new Error ("SyntaxView Error : Invalid Color" );
194
- }
195
- if (TextUtils .isEmpty (color )) {
196
- throw new Error ("SyntaxView Error : Empty Color String" );
197
-
198
- }
199
- if (color .length () != 7 ) {
200
- throw new Error ("SyntaxView Error : Unknown Color" );
201
-
202
- }
176
+ public void setNumbersColor (String color ) {
177
+ checkColor (color );
203
178
numbers .setColor (color );
204
179
}
205
180
206
- public void setSpecialCharsColor (String color ) throws Error {
207
- color = color .trim ();
208
-
209
- if (!color .contains ("#" )) {
210
- throw new Error ("SyntaxView Error : Invalid Color" );
211
- }
212
- if (TextUtils .isEmpty (color )) {
213
- throw new Error ("SyntaxView Error : Empty Color String" );
214
-
215
- }
216
- if (color .length () != 7 ) {
217
- throw new Error ("SyntaxView Error : Unknown Color" );
218
- }
181
+ public void setSpecialCharsColor (String color ) {
182
+ checkColor (color );
219
183
special .setColor (color );
220
184
}
221
185
222
- public void setCodeTextColor (String color ) throws Error {
223
- color = color .trim ();
224
-
225
- if (!color .contains ("#" )) {
226
- throw new Error ("SyntaxView Error : Invalid Color" );
227
- }
228
- if (TextUtils .isEmpty (color )) {
229
- throw new Error ("SyntaxView Error : Empty Color String" );
230
-
231
- }
232
- if (color .length () != 7 ) {
233
- throw new Error ("SyntaxView Error : Unknown Color" );
234
- }
186
+ public void setCodeTextColor (String color ) {
187
+ checkColor (color );
235
188
code .setTextColor (Color .parseColor (color ));
236
189
}
237
190
238
- public void setAnnotationsColor (String color ) throws Error {
239
- color = color .trim ();
240
-
241
- if (!color .contains ("#" )) {
242
- throw new Error ("SyntaxView Error : Invalid Color" );
243
- }
244
- if (TextUtils .isEmpty (color )) {
245
- throw new Error ("SyntaxView Error : Empty Color String" );
246
-
247
- }
248
- if (color .length () != 7 ) {
249
- throw new Error ("SyntaxView Error : Unknown Color" );
250
- }
191
+ public void setAnnotationsColor (String color ) {
192
+ checkColor (color );
251
193
annotations .setColor (color );
252
-
253
194
}
254
195
255
- public void setPrintStatmentsColor (String color ) throws Error {
256
- color = color .trim ();
257
-
258
- if (!color .contains ("#" )) {
259
- throw new Error ("SyntaxView Error : Invalid Color" );
260
- }
261
- if (TextUtils .isEmpty (color )) {
262
- throw new Error ("SyntaxView Error : Empty Color String" );
263
-
264
- }
265
- if (color .length () != 7 ) {
266
- throw new Error ("SyntaxView Error : Unknown Color" );
267
- }
196
+ public void setPrintStatmentsColor (String color ) {
197
+ checkColor (color );
268
198
printStatments .setColor (color );
269
199
}
270
200
271
- public void setRowNumbersColor (String color ) throws Error {
272
- color = color .trim ();
273
-
274
- if (!color .contains ("#" )) {
275
- throw new Error ("SyntaxView Error : Invalid Color" );
276
- }
277
- if (TextUtils .isEmpty (color )) {
278
- throw new Error ("SyntaxView Error : Empty Color String" );
279
-
280
- }
281
- if (color .length () != 7 ) {
282
- throw new Error ("SyntaxView Error : Unknown Color" );
283
- }
201
+ public void setRowNumbersColor (String color ) {
202
+ checkColor (color );
284
203
rows .setTextColor (Color .parseColor (color ));
285
204
}
286
205
287
- public void setRowNumbersBgColor (String color ) throws Error {
288
- color = color .trim ();
289
-
290
- if (!color .contains ("#" )) {
291
- throw new Error ("SyntaxView Error : Invalid Color" );
292
- }
293
- if (TextUtils .isEmpty (color )) {
294
- throw new Error ("SyntaxView Error : Empty Color String" );
295
-
296
- }
297
- if (color .length () != 7 ) {
298
- throw new Error ("SyntaxView Error : Unknown Color" );
299
- }
206
+ public void setRowNumbersBgColor (String color ) {
207
+ checkColor (color );
300
208
rows .setBackgroundColor (Color .parseColor (color ));
301
209
}
302
210
0 commit comments