Skip to content

Commit

Permalink
Extract constant values
Browse files Browse the repository at this point in the history
  • Loading branch information
phansier authored Jan 29, 2018
1 parent 9a3f483 commit 7043b70
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public class MilestoneFragment extends DialogFragment {
private ProgressBar milestoneProgress;
private TextView milestoneProgressPercentage;
private TextView milestoneTime;

private final static int MS_TIME_PAST_DAYS = -100;
private final static int MS_TIME_OK_DAYS = 100;


@Override
public void onAttach(Context context) {
Expand Down Expand Up @@ -124,7 +128,7 @@ private void updateMilestone(final Milestone milestone){
Date current = Calendar.getInstance().getTime();
String state = milestone.getState();
boolean open = state.equals("open");
long days = 200;
long days = MS_TIME_OK_DAYS;
if(dueOn != null) {
long diff = dueOn.getTime() - current.getTime();
days = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
Expand All @@ -134,11 +138,11 @@ private void updateMilestone(final Milestone milestone){
milestoneTime.setText(R.string.status_closed);
back.setColor(getResources().getColor(R.color.milestone_badge_default));
}
else if (-100 <= days && days < 0 && open){
else if (MS_TIME_PAST_DAYS <= days && days < 0 && open){
milestoneTime.setText(getString(R.string.ms_time_past) + " " +(-days) + " " + getString(R.string.ms_days));
back.setColor(getResources().getColor(R.color.milestone_badge_red));
}
else if (0 <= days && days <= 100 && open){
else if (0 <= days && days < MS_TIME_OK_DAYS && open){
milestoneTime.setText(days + " " + getString(R.string.ms_days));
back.setColor(getResources().getColor(R.color.milestone_badge_default));
}
Expand Down

0 comments on commit 7043b70

Please sign in to comment.