add some arbitrary events into the list

This commit is contained in:
tibbi 2016-11-27 23:09:29 +01:00
parent d204b1b42c
commit 216e133194
2 changed files with 33 additions and 6 deletions

View File

@ -13,9 +13,12 @@ import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.adapters.EventListWidgetAdapter import com.simplemobiletools.calendar.adapters.EventListWidgetAdapter
import com.simplemobiletools.calendar.extensions.adjustAlpha import com.simplemobiletools.calendar.extensions.adjustAlpha
import com.simplemobiletools.calendar.helpers.* import com.simplemobiletools.calendar.helpers.*
import com.simplemobiletools.calendar.helpers.Formatter
import com.simplemobiletools.calendar.models.ListEvent import com.simplemobiletools.calendar.models.ListEvent
import com.simplemobiletools.calendar.models.ListItem import com.simplemobiletools.calendar.models.ListItem
import com.simplemobiletools.calendar.models.ListSection
import kotlinx.android.synthetic.main.widget_config_list.* import kotlinx.android.synthetic.main.widget_config_list.*
import org.joda.time.DateTime
import yuku.ambilwarna.AmbilWarnaDialog import yuku.ambilwarna.AmbilWarnaDialog
import java.util.* import java.util.*
@ -46,11 +49,7 @@ class WidgetListConfigureActivity : AppCompatActivity() {
if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID)
finish() finish()
val listItems = ArrayList<ListItem>(10) mEventsAdapter = EventListWidgetAdapter(this, getListItems())
val event = ListEvent(1, 1, 2, "title", "desc")
listItems.add(event)
mEventsAdapter = EventListWidgetAdapter(this, listItems)
mEventsAdapter!!.setTextColor(mTextColor) mEventsAdapter!!.setTextColor(mTextColor)
config_events_list.adapter = mEventsAdapter config_events_list.adapter = mEventsAdapter
@ -148,6 +147,31 @@ class WidgetListConfigureActivity : AppCompatActivity() {
config_save.setBackgroundColor(mBgColor) config_save.setBackgroundColor(mBgColor)
} }
private fun getListItems(): ArrayList<ListItem> {
val listItems = ArrayList<ListItem>(10)
var dateTime = DateTime.now().withTime(0, 0, 0, 0).plusDays(1)
var code = Formatter.getDayCodeFromTS((dateTime.millis / 1000).toInt())
var day = Formatter.getDayTitle(this, code)
listItems.add(ListSection(day))
var time = dateTime.withHourOfDay(7)
listItems.add(ListEvent(1, (time.millis / 1000).toInt(), (time.plusMinutes(30).millis / 1000).toInt(), "Workout", "Leg day"))
time = dateTime.withHourOfDay(8)
listItems.add(ListEvent(2, (time.millis / 1000).toInt(), (time.plusHours(1).millis / 1000).toInt(), "Meeting with John", "In Rockstone Garden"))
dateTime = dateTime.plusDays(1)
code = Formatter.getDayCodeFromTS((dateTime.millis / 1000).toInt())
day = Formatter.getDayTitle(this, code)
listItems.add(ListSection(day))
time = dateTime.withHourOfDay(13)
listItems.add(ListEvent(3, (time.millis / 1000).toInt(), (time.plusHours(1).millis / 1000).toInt(), "Lunch with Mary", "In the Plaza"))
time = dateTime.withHourOfDay(18)
listItems.add(ListEvent(4, (time.millis / 1000).toInt(), (time.plusMinutes(10).millis / 1000).toInt(), "Coffee time", ""))
return listItems
}
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener { private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
mBgAlpha = progress.toFloat() / 100.toFloat() mBgAlpha = progress.toFloat() / 100.toFloat()

View File

@ -11,7 +11,10 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/config_bg_color" android:layout_above="@+id/config_bg_color"
android:layout_marginBottom="@dimen/activity_margin" android:layout_marginBottom="@dimen/activity_margin"
android:clipToPadding="false"/> android:clipToPadding="false"
android:divider="@null"
android:paddingLeft="@dimen/activity_margin"
android:paddingTop="@dimen/medium_padding"/>
<Button <Button
android:id="@+id/config_bg_color" android:id="@+id/config_bg_color"