show attendees selected from autocomplete differently

This commit is contained in:
tibbi 2019-03-14 22:35:00 +01:00
parent 979f463e97
commit 874056dfca
2 changed files with 41 additions and 7 deletions

View File

@ -1156,8 +1156,12 @@ class EventActivity : SimpleActivity() {
private fun addAttendee(value: String? = null) { private fun addAttendee(value: String? = null) {
val attendeeHolder = layoutInflater.inflate(R.layout.item_attendee, event_attendees_holder, false) as RelativeLayout val attendeeHolder = layoutInflater.inflate(R.layout.item_attendee, event_attendees_holder, false) as RelativeLayout
mAttendeeViews.add(attendeeHolder.event_attendee) val autoCompleteView = attendeeHolder.event_attendee
attendeeHolder.event_attendee.onTextChangeListener { val selectedAttendeeHolder = attendeeHolder.event_contact_attendee
val selectedAttendeeName = selectedAttendeeHolder.event_contact_name
mAttendeeViews.add(autoCompleteView)
autoCompleteView.onTextChangeListener {
if (mWasContactsPermissionChecked && value == null) { if (mWasContactsPermissionChecked && value == null) {
checkNewAttendeeField(value) checkNewAttendeeField(value)
} else { } else {
@ -1169,17 +1173,27 @@ class EventActivity : SimpleActivity() {
} }
event_attendees_holder.addView(attendeeHolder) event_attendees_holder.addView(attendeeHolder)
attendeeHolder.event_attendee.setColors(config.textColor, getAdjustedPrimaryColor(), config.backgroundColor) event_attendees_holder.onGlobalLayout {
selectedAttendeeHolder.layoutParams.height = autoCompleteView.height
}
autoCompleteView.setColors(config.textColor, getAdjustedPrimaryColor(), config.backgroundColor)
selectedAttendeeName.setColors(config.textColor, getAdjustedPrimaryColor(), config.backgroundColor)
if (value != null) { if (value != null) {
attendeeHolder.event_attendee.setText(value) autoCompleteView.setText(value)
} }
val adapter = AutoCompleteTextViewAdapter(this, mAvailableContacts) val adapter = AutoCompleteTextViewAdapter(this, mAvailableContacts)
attendeeHolder.event_attendee.setAdapter(adapter) autoCompleteView.setAdapter(adapter)
attendeeHolder.event_attendee.setOnItemClickListener { parent, view, position, id -> autoCompleteView.setOnItemClickListener { parent, view, position, id ->
val currAttendees = (attendeeHolder.event_attendee.adapter as AutoCompleteTextViewAdapter).resultList val currAttendees = (autoCompleteView.adapter as AutoCompleteTextViewAdapter).resultList
val selectedAttendee = currAttendees[position] val selectedAttendee = currAttendees[position]
hideKeyboard(autoCompleteView)
autoCompleteView.beGone()
selectedAttendeeName.text = selectedAttendee.getPublicName()
selectedAttendeeHolder.beVisible()
} }
} }

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/event_attendee_holder" android:id="@+id/event_attendee_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -21,4 +22,23 @@
android:textCursorDrawable="@null" android:textCursorDrawable="@null"
android:textSize="@dimen/bigger_text_size"/> android:textSize="@dimen/bigger_text_size"/>
<RelativeLayout
android:id="@+id/event_contact_attendee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/event_attendee"
android:layout_alignBottom="@+id/event_attendee"
android:visibility="gone">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/event_contact_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/small_margin"
android:lines="1"
android:textSize="@dimen/bigger_text_size"
tools:text="Simple Mobile"/>
</RelativeLayout>
</RelativeLayout> </RelativeLayout>