Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit abea29b

Browse files
committed
refactor : using method isNegativ
1 parent 800491b commit abea29b

File tree

1 file changed

+12
-14
lines changed
  • library/src/main/java/com/codetroopers/betterpickers/hmspicker

1 file changed

+12
-14
lines changed

library/src/main/java/com/codetroopers/betterpickers/hmspicker/HmsPicker.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public HmsPicker(Context context) {
5858
* Instantiates an HmsPicker object
5959
*
6060
* @param context the Context required for creation
61-
* @param attrs additional attributes that define custom colors, selectors, and backgrounds.
61+
* @param attrs additional attributes that define custom colors, selectors, and backgrounds.
6262
*/
6363
public HmsPicker(Context context, AttributeSet attrs) {
6464
super(context, attrs);
@@ -130,7 +130,7 @@ private void restyleViews() {
130130
if (mEnteredHms != null) {
131131
mEnteredHms.setTheme(mTheme);
132132
}
133-
if(mLeft != null){
133+
if (mLeft != null) {
134134
mLeft.setTextColor(mTextColor);
135135
mLeft.setBackgroundResource(mKeyBackgroundResId);
136136
}
@@ -176,8 +176,6 @@ protected void onFinishInflate() {
176176
Resources res = mContext.getResources();
177177
mLeft.setText(res.getString(R.string.number_picker_plus_minus));
178178
mLeft.setOnClickListener(this);
179-
// mLabel = (TextView) findViewById(R.id.label);
180-
// mSign = SIGN_POSITIVE;
181179

182180
mHoursLabel = (TextView) findViewById(R.id.hours_label);
183181
mMinutesLabel = (TextView) findViewById(R.id.minutes_label);
@@ -218,17 +216,17 @@ protected void doOnClick(View v) {
218216
mInput[mInputPointer] = 0;
219217
mInputPointer--;
220218
}
221-
} else if(v == mLeft){
219+
} else if (v == mLeft) {
222220
onLeftClicked();
223221
}
224222
updateKeypad();
225223
}
226224

227225
private void onLeftClicked() {
228-
if (mSign == SIGN_POSITIVE) {
229-
mSign = SIGN_NEGATIVE;
230-
} else {
226+
if (isNegative()) {
231227
mSign = SIGN_POSITIVE;
228+
} else {
229+
mSign = SIGN_NEGATIVE;
232230
}
233231
}
234232

@@ -268,13 +266,13 @@ private void updateKeypad() {
268266

269267
/**
270268
* Update the time displayed in the picker:
271-
*
269+
* <p/>
272270
* Put "-" in digits that was not entered by passing -1
273-
*
271+
* <p/>
274272
* Hide digit by passing -2 (for highest hours digit only);
275273
*/
276274
protected void updateHms() {
277-
mEnteredHms.setTime(mSign == SIGN_NEGATIVE, mInput[4], mInput[3], mInput[2], mInput[1], mInput[0]);
275+
mEnteredHms.setTime(isNegative(), mInput[4], mInput[3], mInput[2], mInput[1], mInput[0]);
278276
}
279277

280278
private void addClickedNumber(int val) {
@@ -356,7 +354,7 @@ public void setPlusMinusVisibility(int visibility) {
356354
/**
357355
* Set the current hours, minutes, and seconds on the picker.
358356
*
359-
* @param hours the input hours value
357+
* @param hours the input hours value
360358
* @param minutes the input minutes value
361359
* @param seconds the input seconds value
362360
*/
@@ -367,7 +365,7 @@ public void setTime(int hours, int minutes, int seconds) {
367365
mInput[1] = seconds / 10;
368366
mInput[0] = seconds % 10;
369367

370-
for (int i=4; i>=0; i--) {
368+
for (int i = 4; i >= 0; i--) {
371369
if (mInput[i] > 0) {
372370
mInputPointer = i;
373371
break;
@@ -476,7 +474,7 @@ protected void setRightEnabled(boolean enabled) {
476474
}
477475
}
478476

479-
public boolean isNegative(){
477+
public boolean isNegative() {
480478
return mSign == SIGN_NEGATIVE;
481479
}
482480
}

0 commit comments

Comments
 (0)