Skip to content

Commit

Permalink
Added 2 weeks and 1 month
Browse files Browse the repository at this point in the history
  • Loading branch information
arepina committed Dec 17, 2017
1 parent e2a05c3 commit 0f89372
Showing 1 changed file with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static Intent createIntent(final Milestone milestone,

private Button monthButton;

private Button chooseButton;
private Button chooseDateButton;

private Button clear;

Expand Down Expand Up @@ -137,12 +137,12 @@ protected void onCreate(Bundle savedInstanceState) {
dateText = finder.find(R.id.et_milestone_date);
twoWeeksButton = finder.find(R.id.b_two_weeks);
monthButton = finder.find(R.id.b_month);
chooseButton = finder.find(R.id.b_choose_date);
chooseDateButton = finder.find(R.id.b_choose_date);
clear = finder.find(R.id.b_clear);

final Calendar dateAndTime = Calendar.getInstance();

chooseButton.setOnClickListener(new View.OnClickListener() {
chooseDateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DatePickerDialog.OnDateSetListener picker =new DatePickerDialog.OnDateSetListener() {
Expand All @@ -164,6 +164,36 @@ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth
}
});

twoWeeksButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int noOfDays = 14; //two weeks
Date dateOfOrder = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(dateOfOrder);
dateAndTime.add(Calendar.DAY_OF_YEAR, noOfDays);
SimpleDateFormat sd = new SimpleDateFormat("dd-MM-yyyy");
final Date startDate = dateAndTime.getTime();
String fdate = sd.format(startDate);
dateText.setText(fdate);
}
});

monthButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int noOfDays = 31; //1 month
Date dateOfOrder = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(dateOfOrder);
dateAndTime.add(Calendar.DAY_OF_YEAR, noOfDays);
SimpleDateFormat sd = new SimpleDateFormat("dd-MM-yyyy");
final Date startDate = dateAndTime.getTime();
String fdate = sd.format(startDate);
dateText.setText(fdate);
}
});

clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down

0 comments on commit 0f89372

Please sign in to comment.