Minute selection indicator restored on rotate
This commit is contained in:
parent
ee77105a8e
commit
be66d43e4c
@ -28,7 +28,6 @@ public class MinutesGrid extends NumbersGrid {
|
|||||||
int value = getSelection() - 1;
|
int value = getSelection() - 1;
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
value = 59;
|
value = 59;
|
||||||
setIndicator(value); // TODO: Remove when you move this logic to setSelection()
|
|
||||||
setSelection(value);
|
setSelection(value);
|
||||||
mSelectionListener.onNumberSelected(value);
|
mSelectionListener.onNumberSelected(value);
|
||||||
}
|
}
|
||||||
@ -39,13 +38,24 @@ public class MinutesGrid extends NumbersGrid {
|
|||||||
int value = getSelection() + 1;
|
int value = getSelection() + 1;
|
||||||
if (value == 60)
|
if (value == 60)
|
||||||
value = 0;
|
value = 0;
|
||||||
setIndicator(value); // TODO: Remove when you move this logic to setSelection()
|
|
||||||
setSelection(value);
|
setSelection(value);
|
||||||
mSelectionListener.onNumberSelected(value);
|
mSelectionListener.onNumberSelected(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSelection(int value) {
|
||||||
|
super.setSelection(value);
|
||||||
|
if (value % 5 == 0) {
|
||||||
|
// The new value is one of the predetermined minute values
|
||||||
|
int positionOfValue = value / 5;
|
||||||
|
setIndicator(getChildAt(positionOfValue));
|
||||||
|
} else {
|
||||||
|
clearIndicator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int contentLayout() {
|
protected int contentLayout() {
|
||||||
return R.layout.content_minutes_grid;
|
return R.layout.content_minutes_grid;
|
||||||
@ -70,18 +80,4 @@ public class MinutesGrid extends NumbersGrid {
|
|||||||
context, R.drawable.ic_add_circle_24dp, colorActiveLight));
|
context, R.drawable.ic_add_circle_24dp, colorActiveLight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method for minute tuners to set the indicator.
|
|
||||||
* @param value the new value set by the minute tuners
|
|
||||||
*/
|
|
||||||
// TODO: Move this logic to setSelection()
|
|
||||||
private void setIndicator(int value) {
|
|
||||||
clearIndicator(); // TODO: Remove?
|
|
||||||
if (value % 5 == 0) {
|
|
||||||
// The new value is one of the predetermined minute values
|
|
||||||
int positionOfValue = value / 5;
|
|
||||||
setIndicator(getChildAt(positionOfValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -132,6 +132,14 @@ public abstract class NumbersGrid extends GridLayout implements View.OnClickList
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the number held by the button parsed into an integer. The base implementation
|
||||||
|
* assumes the view is of type TextView.
|
||||||
|
*/
|
||||||
|
protected int valueOf(View button) {
|
||||||
|
return Integer.parseInt(((TextView) button).getText().toString());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default implementation sets the appropriate text color on all of the number buttons
|
* The default implementation sets the appropriate text color on all of the number buttons
|
||||||
* as determined by {@link #canRegisterClickListener(View)}.
|
* as determined by {@link #canRegisterClickListener(View)}.
|
||||||
@ -167,11 +175,4 @@ public abstract class NumbersGrid extends GridLayout implements View.OnClickList
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses the number held by the button into an integer.
|
|
||||||
*/
|
|
||||||
private static int valueOf(View button) {
|
|
||||||
return Integer.parseInt(((TextView) button).getText().toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user