Skip to content

Commit 34746e4

Browse files
committed
add autocompletion for events
1 parent ea40162 commit 34746e4

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,46 @@ class EventActivity : SimpleActivity() {
231231
val eventId = intent.getLongExtra(EVENT_ID, 0L)
232232
ensureBackgroundThread {
233233
val locations = eventsDB.getAllLocations()
234+
val eventTitleMap = eventsDB.getAllEvents()
235+
.associateBy { it.title } as HashMap<String, Event>
236+
binding.eventTitle.setOnItemClickListener { parent, view, position, id ->
237+
val prev = eventTitleMap[parent.getItemAtPosition(position)]
238+
binding.eventLocation.setText(prev!!.location)
239+
binding.eventDescription.setText(prev.description)
240+
241+
binding.eventAllDay.isChecked = prev.getIsAllDay()
242+
mEventEndDateTime = mEventStartDateTime.plus(1000L * (prev.endTS - prev.startTS))
243+
244+
mReminder1Minutes = prev.reminder1Minutes
245+
mReminder2Minutes = prev.reminder2Minutes
246+
mReminder3Minutes = prev.reminder3Minutes
247+
248+
mReminder1Type = prev.reminder1Type
249+
mReminder2Type = prev.reminder2Type
250+
mReminder3Type = prev.reminder3Type
251+
252+
mAccessLevel = prev.accessLevel
253+
mAvailability = prev.availability
254+
mStatus = prev.status
255+
mEventColor = prev.color
256+
257+
mAttendees = prev.attendees as ArrayList<Attendee>
258+
259+
mCalendarId = prev.calendarId
260+
261+
checkRepeatTexts(mRepeatInterval)
262+
checkRepeatRule()
263+
updateTexts()
264+
updateCalendar()
265+
checkAttendees()
266+
updateActionBarTitle()
267+
}
234268

235269
runOnUiThread {
236-
val adapter = ArrayAdapter(this, R.layout.item_dropdown, locations)
237-
binding.eventLocation.setAdapter(adapter)
270+
val locationAdapter = ArrayAdapter(this, R.layout.item_dropdown, locations)
271+
binding.eventLocation.setAdapter(locationAdapter)
272+
val titleAdapter = ArrayAdapter(this, R.layout.item_dropdown, eventTitleMap.keys.toList())
273+
binding.eventTitle.setAdapter(titleAdapter)
238274
}
239275

240276
val event = eventsDB.getEventWithId(eventId)

app/src/main/res/layout/activity_event.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
android:layout_width="match_parent"
3636
android:layout_height="wrap_content">
3737

38-
<org.fossify.commons.views.MyEditText
38+
<AutoCompleteTextView
3939
android:id="@+id/event_title"
4040
android:layout_width="match_parent"
4141
android:layout_height="wrap_content"

0 commit comments

Comments
 (0)