mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
handle repetition spinner
This commit is contained in:
@@ -131,7 +131,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||||||
final String description = cursor.getString(cursor.getColumnIndex(COL_DESCRIPTION));
|
final String description = cursor.getString(cursor.getColumnIndex(COL_DESCRIPTION));
|
||||||
final int reminderMinutes = cursor.getInt(cursor.getColumnIndex(COL_REMINDER_MINUTES));
|
final int reminderMinutes = cursor.getInt(cursor.getColumnIndex(COL_REMINDER_MINUTES));
|
||||||
cursor.close();
|
cursor.close();
|
||||||
return new Event(id, startTS, endTS, title, description, reminderMinutes);
|
return new Event(id, startTS, endTS, title, description, reminderMinutes, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -177,7 +177,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||||||
final String title = cursor.getString(cursor.getColumnIndex(COL_TITLE));
|
final String title = cursor.getString(cursor.getColumnIndex(COL_TITLE));
|
||||||
final String description = cursor.getString(cursor.getColumnIndex(COL_DESCRIPTION));
|
final String description = cursor.getString(cursor.getColumnIndex(COL_DESCRIPTION));
|
||||||
final int reminderMinutes = cursor.getInt(cursor.getColumnIndex(COL_REMINDER_MINUTES));
|
final int reminderMinutes = cursor.getInt(cursor.getColumnIndex(COL_REMINDER_MINUTES));
|
||||||
events.add(new Event(id, startTS, endTS, title, description, reminderMinutes));
|
events.add(new Event(id, startTS, endTS, title, description, reminderMinutes, 0));
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@@ -34,6 +34,10 @@ import butterknife.OnClick;
|
|||||||
import butterknife.OnItemSelected;
|
import butterknife.OnItemSelected;
|
||||||
|
|
||||||
public class EventActivity extends SimpleActivity implements DBHelper.DBOperationsListener {
|
public class EventActivity extends SimpleActivity implements DBHelper.DBOperationsListener {
|
||||||
|
private static final int DAILY = 86400;
|
||||||
|
private static final int WEEKLY = 604800;
|
||||||
|
private static final int YEARLY = 31536000;
|
||||||
|
|
||||||
@BindView(R.id.event_start_date) TextView mStartDate;
|
@BindView(R.id.event_start_date) TextView mStartDate;
|
||||||
@BindView(R.id.event_start_time) TextView mStartTime;
|
@BindView(R.id.event_start_time) TextView mStartTime;
|
||||||
@BindView(R.id.event_end_date) TextView mEndDate;
|
@BindView(R.id.event_end_date) TextView mEndDate;
|
||||||
@@ -42,6 +46,7 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||||||
@BindView(R.id.event_description) EditText mDescriptionET;
|
@BindView(R.id.event_description) EditText mDescriptionET;
|
||||||
@BindView(R.id.event_reminder_other) EditText mReminderOtherET;
|
@BindView(R.id.event_reminder_other) EditText mReminderOtherET;
|
||||||
@BindView(R.id.event_reminder) AppCompatSpinner mReminder;
|
@BindView(R.id.event_reminder) AppCompatSpinner mReminder;
|
||||||
|
@BindView(R.id.event_repetition) AppCompatSpinner mRepetition;
|
||||||
|
|
||||||
private static DateTime mEventStartDateTime;
|
private static DateTime mEventStartDateTime;
|
||||||
private static DateTime mEventEndDateTime;
|
private static DateTime mEventEndDateTime;
|
||||||
@@ -79,6 +84,7 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||||||
updateEndDate();
|
updateEndDate();
|
||||||
updateEndTime();
|
updateEndTime();
|
||||||
setupReminder();
|
setupReminder();
|
||||||
|
setupRepetition();
|
||||||
|
|
||||||
mWasEndDateSet = (event != null);
|
mWasEndDateSet = (event != null);
|
||||||
mWasEndTimeSet = (event != null);
|
mWasEndTimeSet = (event != null);
|
||||||
@@ -124,6 +130,23 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupRepetition() {
|
||||||
|
switch (mEvent.getRepeatInterval()) {
|
||||||
|
case DAILY:
|
||||||
|
mReminder.setSelection(1);
|
||||||
|
break;
|
||||||
|
case WEEKLY:
|
||||||
|
mReminder.setSelection(2);
|
||||||
|
break;
|
||||||
|
case YEARLY:
|
||||||
|
mReminder.setSelection(3);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mReminder.setSelection(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@OnItemSelected(R.id.event_reminder)
|
@OnItemSelected(R.id.event_reminder)
|
||||||
public void handleReminder() {
|
public void handleReminder() {
|
||||||
if (!mWasReminderInit) {
|
if (!mWasReminderInit) {
|
||||||
@@ -190,12 +213,12 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||||||
|
|
||||||
final DBHelper dbHelper = DBHelper.newInstance(getApplicationContext(), this);
|
final DBHelper dbHelper = DBHelper.newInstance(getApplicationContext(), this);
|
||||||
final String description = mDescriptionET.getText().toString().trim();
|
final String description = mDescriptionET.getText().toString().trim();
|
||||||
final int reminderMinutes = getReminderMinutes();
|
|
||||||
mEvent.setStartTS(startTS);
|
mEvent.setStartTS(startTS);
|
||||||
mEvent.setEndTS(endTS);
|
mEvent.setEndTS(endTS);
|
||||||
mEvent.setTitle(title);
|
mEvent.setTitle(title);
|
||||||
mEvent.setDescription(description);
|
mEvent.setDescription(description);
|
||||||
mEvent.setReminderMinutes(reminderMinutes);
|
mEvent.setReminderMinutes(getReminderMinutes());
|
||||||
|
mEvent.setRepeatInterval(getRepeatInterval());
|
||||||
if (mEvent.getId() == 0) {
|
if (mEvent.getId() == 0) {
|
||||||
dbHelper.insert(mEvent);
|
dbHelper.insert(mEvent);
|
||||||
} else {
|
} else {
|
||||||
@@ -218,6 +241,19 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getRepeatInterval() {
|
||||||
|
switch (mRepetition.getSelectedItemPosition()) {
|
||||||
|
case 1:
|
||||||
|
return DAILY;
|
||||||
|
case 2:
|
||||||
|
return WEEKLY;
|
||||||
|
case 3:
|
||||||
|
return YEARLY;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateStartDate() {
|
private void updateStartDate() {
|
||||||
mStartDate.setText(Formatter.getEventDate(getApplicationContext(), mEventStartDateTime));
|
mStartDate.setText(Formatter.getEventDate(getApplicationContext(), mEventStartDateTime));
|
||||||
}
|
}
|
||||||
|
@@ -3,13 +3,14 @@ package com.simplemobiletools.calendar.models;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class Event implements Serializable {
|
public class Event implements Serializable {
|
||||||
private static final long serialVersionUID = -32456795132354616L;
|
private static final long serialVersionUID = -32456795132344616L;
|
||||||
private int mId;
|
private int mId;
|
||||||
private int mStartTS;
|
private int mStartTS;
|
||||||
private int mEndTS;
|
private int mEndTS;
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
private String mDescription;
|
private String mDescription;
|
||||||
private int mReminderMinutes;
|
private int mReminderMinutes;
|
||||||
|
private int mRepeatInterval;
|
||||||
|
|
||||||
public Event() {
|
public Event() {
|
||||||
mId = 0;
|
mId = 0;
|
||||||
@@ -18,15 +19,17 @@ public class Event implements Serializable {
|
|||||||
mTitle = "";
|
mTitle = "";
|
||||||
mDescription = "";
|
mDescription = "";
|
||||||
mReminderMinutes = 0;
|
mReminderMinutes = 0;
|
||||||
|
mRepeatInterval = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Event(int id, int startTS, int endTS, String title, String description, int reminerMinutes) {
|
public Event(int id, int startTS, int endTS, String title, String description, int reminderMinutes, int repeatInterval) {
|
||||||
mId = id;
|
mId = id;
|
||||||
mStartTS = startTS;
|
mStartTS = startTS;
|
||||||
mEndTS = endTS;
|
mEndTS = endTS;
|
||||||
mTitle = title;
|
mTitle = title;
|
||||||
mDescription = description;
|
mDescription = description;
|
||||||
mReminderMinutes = reminerMinutes;
|
mReminderMinutes = reminderMinutes;
|
||||||
|
mRepeatInterval = repeatInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@@ -77,6 +80,14 @@ public class Event implements Serializable {
|
|||||||
mReminderMinutes = reminderMinutes;
|
mReminderMinutes = reminderMinutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRepeatInterval() {
|
||||||
|
return mRepeatInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepeatInterval(int repeatInterval) {
|
||||||
|
mRepeatInterval = repeatInterval;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Event {" +
|
return "Event {" +
|
||||||
@@ -86,6 +97,7 @@ public class Event implements Serializable {
|
|||||||
", title=" + getTitle() +
|
", title=" + getTitle() +
|
||||||
", description=" + getDescription() +
|
", description=" + getDescription() +
|
||||||
", reminderMinutes=" + getReminderMinutes() +
|
", reminderMinutes=" + getReminderMinutes() +
|
||||||
|
", repeatInterval=" + getRepeatInterval() +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user