update DBhelper constructor a bit

This commit is contained in:
tibbi 2016-10-22 11:19:31 +02:00
parent fab59e5335
commit fb12a8b38d
7 changed files with 37 additions and 13 deletions

View File

@ -10,7 +10,7 @@ import org.joda.time.DateTime;
import java.util.ArrayList;
import java.util.List;
public class MonthlyCalendarImpl implements DBHelper.DBOperationsListener {
public class MonthlyCalendarImpl implements DBHelper.MonthlyEventsListener {
private static final int DAYS_CNT = 42;
private static final String YEAR_PATTERN = "YYYY";

View File

@ -13,7 +13,7 @@ import com.simplemobiletools.calendar.models.Event
import org.joda.time.DateTime
import java.util.*
class DBHelper(context: Context, callback: DBOperationsListener?) : SQLiteOpenHelper(context, DBHelper.DB_NAME, null, DBHelper.DB_VERSION) {
class DBHelper(context: Context) : SQLiteOpenHelper(context, DBHelper.DB_NAME, null, DBHelper.DB_VERSION) {
private val MAIN_TABLE_NAME = "events"
private val COL_ID = "id"
private val COL_START_TS = "start_ts"
@ -29,7 +29,7 @@ class DBHelper(context: Context, callback: DBOperationsListener?) : SQLiteOpenHe
private val COL_REPEAT_MONTH = "repeat_month"
private val COL_REPEAT_DAY = "repeat_day"
private var mCallback: DBOperationsListener? = null
private var mCallback: MonthlyEventsListener? = null
companion object {
private val DB_NAME = "events.db"
@ -37,10 +37,12 @@ class DBHelper(context: Context, callback: DBOperationsListener?) : SQLiteOpenHe
lateinit private var mDb: SQLiteDatabase
}
constructor(context: Context, callback: MonthlyEventsListener?) : this(context) {
mCallback = callback
}
init {
mDb = writableDatabase
mCallback = callback
}
override fun onCreate(db: SQLiteDatabase) {
@ -256,7 +258,7 @@ class DBHelper(context: Context, callback: DBOperationsListener?) : SQLiteOpenHe
return events
}
interface DBOperationsListener {
interface MonthlyEventsListener {
fun eventInserted(event: Event)
fun eventUpdated(event: Event)
@ -265,4 +267,8 @@ class DBHelper(context: Context, callback: DBOperationsListener?) : SQLiteOpenHe
fun gotEvents(events: MutableList<Event>)
}
interface YearlyEventsListener {
fun yearlyEvents(events: MutableList<String>)
}
}

View File

@ -0,0 +1,5 @@
package com.simplemobiletools.calendar
interface YearlyCalendar {
fun updateYearlyCalendar(events: MutableList<String>)
}

View File

@ -0,0 +1,12 @@
package com.simplemobiletools.calendar
class YearlyCalendarImpl(year: Int) : DBHelper.YearlyEventsListener {
fun getEvents() {
}
override fun yearlyEvents(events: MutableList<String>) {
}
}

View File

@ -21,7 +21,7 @@ import kotlinx.android.synthetic.main.activity_event.*
import org.joda.time.DateTime
import org.joda.time.DateTimeZone
class EventActivity : SimpleActivity(), DBHelper.DBOperationsListener {
class EventActivity : SimpleActivity(), DBHelper.MonthlyEventsListener {
private var mWasReminderInit: Boolean = false
private var mWasEndDateSet: Boolean = false
private var mWasEndTimeSet: Boolean = false

View File

@ -23,7 +23,7 @@ import kotlinx.android.synthetic.main.day_fragment.view.*
import kotlinx.android.synthetic.main.top_navigation.view.*
import java.util.*
class DayFragment : Fragment(), DBHelper.DBOperationsListener, AdapterView.OnItemClickListener, AbsListView.MultiChoiceModeListener {
class DayFragment : Fragment(), DBHelper.MonthlyEventsListener, AdapterView.OnItemClickListener, AbsListView.MultiChoiceModeListener {
private val EDIT_EVENT = 1

View File

@ -5,15 +5,12 @@ import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.simplemobiletools.calendar.Config
import com.simplemobiletools.calendar.Constants
import com.simplemobiletools.calendar.NavigationListener
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.*
import com.simplemobiletools.calendar.views.SmallMonthView
import kotlinx.android.synthetic.main.year_fragment.view.*
import org.joda.time.DateTime
class YearFragment : Fragment() {
class YearFragment : Fragment(), YearlyCalendar {
private var mListener: NavigationListener? = null
private var mYear = 0
private var mSundayFirst = false
@ -57,4 +54,8 @@ class YearFragment : Fragment() {
fun setListener(listener: NavigationListener) {
mListener = listener
}
override fun updateYearlyCalendar(events: MutableList<String>) {
}
}