From a105d270c0420b9eab5e4c2e97068b2d7f1ffa9f Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 2 Dec 2017 17:24:00 +0100 Subject: [PATCH] remove a redundant interface --- .../calendar/activities/EventActivity.kt | 11 +---------- .../calendar/fragments/DayFragment.kt | 19 +++++-------------- .../calendar/helpers/DBHelper.kt | 14 +------------- 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index 79349f3c9..6623191c8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -22,7 +22,7 @@ import kotlinx.android.synthetic.main.activity_event.* import org.joda.time.DateTime import java.util.* -class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { +class EventActivity : SimpleActivity() { companion object { val STORED_LOCALLY_ONLY = 0 } @@ -753,13 +753,4 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { event_type_image.applyColorFilter(textColor) event_caldav_calendar_image.applyColorFilter(textColor) } - - override fun eventInserted(event: Event) { - } - - override fun eventsDeleted(cnt: Int) { - } - - override fun gotEvents(events: MutableList) { - } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt index 8d640f7c7..ab2776a99 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt @@ -19,7 +19,9 @@ import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.dbHelper import com.simplemobiletools.calendar.extensions.getAppropriateTheme import com.simplemobiletools.calendar.extensions.getFilteredEvents -import com.simplemobiletools.calendar.helpers.* +import com.simplemobiletools.calendar.helpers.DAY_CODE +import com.simplemobiletools.calendar.helpers.EVENT_ID +import com.simplemobiletools.calendar.helpers.EVENT_OCCURRENCE_TS import com.simplemobiletools.calendar.helpers.Formatter import com.simplemobiletools.calendar.interfaces.DeleteEventsListener import com.simplemobiletools.calendar.interfaces.NavigationListener @@ -31,7 +33,7 @@ import kotlinx.android.synthetic.main.top_navigation.view.* import org.joda.time.DateTime import java.util.* -class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListener { +class DayFragment : Fragment(), DeleteEventsListener { var mListener: NavigationListener? = null private var mTextColor = 0 private var mDayCode = "" @@ -110,7 +112,7 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen fun checkEvents() { val startTS = Formatter.getDayStartTS(mDayCode) val endTS = Formatter.getDayEndTS(mDayCode) - DBHelper.newInstance(context!!, this).getEvents(startTS, endTS) { + context!!.dbHelper.getEvents(startTS, endTS) { receivedEvents(it) } } @@ -165,15 +167,4 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen } (activity as DayActivity).recheckEvents() } - - override fun eventInserted(event: Event) { - } - - override fun eventsDeleted(cnt: Int) { - (activity as DayActivity).recheckEvents() - } - - override fun gotEvents(events: MutableList) { - receivedEvents(events) - } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index 5832b0e63..aea2060dc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -70,10 +70,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont val REGULAR_EVENT_TYPE_ID = 1 var dbInstance: DBHelper? = null - private var mEventsListener: EventUpdateListener? = null - - fun newInstance(context: Context, callback: EventUpdateListener? = null): DBHelper { - mEventsListener = callback + fun newInstance(context: Context): DBHelper { if (dbInstance == null) dbInstance = DBHelper(context) @@ -427,7 +424,6 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont mDb.delete(EXCEPTIONS_TABLE_NAME, exceptionSelection, null) context.updateWidgets() - mEventsListener?.eventsDeleted(ids.size) ids.forEach { context.cancelNotification(it.toInt()) @@ -961,12 +957,4 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont cursor?.close() } } - - interface EventUpdateListener { - fun eventInserted(event: Event) - - fun eventsDeleted(cnt: Int) - - fun gotEvents(events: MutableList) - } }