From 09932120943630b31df9693ce013bb2f5eca2b8e Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 15 Sep 2016 23:58:49 +0200 Subject: [PATCH] convert Day and Event models to kotlin --- .../calendar/MyWidgetProvider.java | 4 +- .../activities/WidgetConfigureActivity.java | 4 +- .../calendar/models/Day.java | 37 ------- .../calendar/models/Event.java | 103 ------------------ .../simplemobiletools/calendar/models/Day.kt | 7 ++ .../calendar/models/Event.kt | 15 +++ 6 files changed, 26 insertions(+), 144 deletions(-) delete mode 100644 app/src/main/java/com/simplemobiletools/calendar/models/Day.java delete mode 100644 app/src/main/java/com/simplemobiletools/calendar/models/Event.java create mode 100644 app/src/main/kotlin/com/simplemobiletools/calendar/models/Day.kt create mode 100644 app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt diff --git a/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java b/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java index 966387261..e0031a0f8 100644 --- a/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java +++ b/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java @@ -138,11 +138,11 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar { int curTextColor = mWeakTextColor; float curTextSize = mDayTextSize; - if (day.getIsThisMonth()) { + if (day.isThisMonth()) { curTextColor = mTextColor; } - if (day.getIsToday()) { + if (day.isToday()) { curTextSize = mTodayTextSize; } diff --git a/app/src/main/java/com/simplemobiletools/calendar/activities/WidgetConfigureActivity.java b/app/src/main/java/com/simplemobiletools/calendar/activities/WidgetConfigureActivity.java index 788169aa5..ac3bee765 100644 --- a/app/src/main/java/com/simplemobiletools/calendar/activities/WidgetConfigureActivity.java +++ b/app/src/main/java/com/simplemobiletools/calendar/activities/WidgetConfigureActivity.java @@ -193,11 +193,11 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend int curTextColor = mWeakTextColor; float curTextSize = mDayTextSize; - if (day.getIsThisMonth()) { + if (day.isThisMonth()) { curTextColor = mTextColor; } - if (day.getIsToday()) { + if (day.isToday()) { curTextSize = mTodayTextSize; } diff --git a/app/src/main/java/com/simplemobiletools/calendar/models/Day.java b/app/src/main/java/com/simplemobiletools/calendar/models/Day.java deleted file mode 100644 index 2bb7285f4..000000000 --- a/app/src/main/java/com/simplemobiletools/calendar/models/Day.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.simplemobiletools.calendar.models; - -public class Day { - private final int mValue; - private final boolean mIsThisMonth; - private final boolean mIsToday; - private final boolean mHasEvent; - private final String mCode; - - public Day(int value, boolean isThisMonth, boolean isToday, String code, boolean hasEvent) { - mValue = value; - mIsThisMonth = isThisMonth; - mIsToday = isToday; - mCode = code; - mHasEvent = hasEvent; - } - - public int getValue() { - return mValue; - } - - public boolean getIsThisMonth() { - return mIsThisMonth; - } - - public boolean getIsToday() { - return mIsToday; - } - - public String getCode() { - return mCode; - } - - public boolean getHasEvent() { - return mHasEvent; - } -} diff --git a/app/src/main/java/com/simplemobiletools/calendar/models/Event.java b/app/src/main/java/com/simplemobiletools/calendar/models/Event.java deleted file mode 100644 index a4f29e89d..000000000 --- a/app/src/main/java/com/simplemobiletools/calendar/models/Event.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.simplemobiletools.calendar.models; - -import java.io.Serializable; - -public class Event implements Serializable { - private static final long serialVersionUID = -32456795132344616L; - private int mId; - private int mStartTS; - private int mEndTS; - private String mTitle; - private String mDescription; - private int mReminderMinutes; - private int mRepeatInterval; - - public Event() { - mId = 0; - mStartTS = 0; - mEndTS = 0; - mTitle = ""; - mDescription = ""; - mReminderMinutes = 0; - mRepeatInterval = 0; - } - - public Event(int id, int startTS, int endTS, String title, String description, int reminderMinutes, int repeatInterval) { - mId = id; - mStartTS = startTS; - mEndTS = endTS; - mTitle = title; - mDescription = description; - mReminderMinutes = reminderMinutes; - mRepeatInterval = repeatInterval; - } - - public int getId() { - return mId; - } - - public void setId(int id) { - mId = id; - } - - public int getStartTS() { - return mStartTS; - } - - public void setStartTS(int startTS) { - mStartTS = startTS; - } - - public int getEndTS() { - return mEndTS; - } - - public void setEndTS(int endTS) { - mEndTS = endTS; - } - - public String getTitle() { - return mTitle; - } - - public void setTitle(String title) { - mTitle = title; - } - - public String getDescription() { - return mDescription; - } - - public void setDescription(String description) { - mDescription = description; - } - - public int getReminderMinutes() { - return mReminderMinutes; - } - - public void setReminderMinutes(int reminderMinutes) { - mReminderMinutes = reminderMinutes; - } - - public int getRepeatInterval() { - return mRepeatInterval; - } - - public void setRepeatInterval(int repeatInterval) { - mRepeatInterval = repeatInterval; - } - - @Override - public String toString() { - return "Event {" + - "id=" + getId() + - ", startTS=" + getStartTS() + - ", endTS=" + getEndTS() + - ", title=" + getTitle() + - ", description=" + getDescription() + - ", reminderMinutes=" + getReminderMinutes() + - ", repeatInterval=" + getRepeatInterval() + - "}"; - } -} diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Day.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Day.kt new file mode 100644 index 000000000..c0a980f5f --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Day.kt @@ -0,0 +1,7 @@ +package com.simplemobiletools.calendar.models + +class Day(val value: Int, val isThisMonth: Boolean, val isToday: Boolean, val code: String, val hasEvent: Boolean) { + override fun toString(): String { + return "Day {value=$value, isThisMonth=$isThisMonth, itToday=$isToday, code=$code, hasEvent=$hasEvent}" + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt new file mode 100644 index 000000000..c76680b63 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt @@ -0,0 +1,15 @@ +package com.simplemobiletools.calendar.models + +import java.io.Serializable + +class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var title: String = "", var description: String = "", + var reminderMinutes: Int = 0, var repeatInterval: Int = 0) : Serializable { + override fun toString(): String { + return "Event {id=$id, startTS=$startTS, endTS=$endTS, title=$title, description=$description, " + + "reminderMinutes=$reminderMinutes, repeatInterval=$repeatInterval}" + } + + companion object { + private val serialVersionUID = -32456795132344616L + } +}