Подскажите пожалуйста, как исправить ошибку. В editText использую двусторонний binding:
<EditText
android:id="@+id/note_title_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/enter_title"
android:inputType="text"
android:text='@={!TextUtils.isEmpty(note.title) ? note.title : ""}' />
На этапе сборки получаю ошибку:
Found data binding errors. ****/ data binding error ****msg:The expression ((TextUtilsIsEmptyNoteTitle1) ? (noteTitle) : ("")) cannot be inverted: The condition of a ternary operator must be constant: android.databinding.tool.writer.KCode@73312afc
Почему возникает такая ошибка не пойму. Поле title объекта note имеет тип String. Заранее благодарен за помощь.
Полный код разметки:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:clickable="true"
android:focusable="true"
tools:context=".view.fragment.EditNoteFragment">
<data>
<import type="android.text.TextUtils" />
<import type="android.view.View" />
<variable
name="note"
type="com.codit.recycleviewbinding.model.Note" />
</data>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light">
<ImageView
android:id="@+id/preview_image"
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:scaleType="fitCenter"
android:visibility="@{TextUtils.isEmpty(note.image) ? View.GONE : View.VISIBLE}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:noteImageUri="@{note.image}" />
<android.support.design.widget.TextInputLayout
android:id="@+id/note_title_input"
style="@style/textInputStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
app:errorEnabled="@{TextUtils.isEmpty(note.title)}"
app:hintEnabled="@{!TextUtils.isEmpty(note.title)}"
app:layout_constraintEnd_toStartOf="@+id/add_image_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/preview_image">
<EditText
android:id="@+id/note_title_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/enter_title"
android:inputType="text"
android:text='@={!TextUtils.isEmpty(note.title) ? note.title : ""}' />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/note_text_input"
style="@style/textInputStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:errorEnabled="@{TextUtils.isEmpty(note.text)}"
app:hintEnabled="@{!TextUtils.isEmpty(note.text)}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/note_title_input">
<EditText
android:id="@+id/note_text_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/enter_text"
android:inputType="textMultiLine"
android:text='@={!TextUtils.isEmpty(note.text) ? note.text : ""}' />
</android.support.design.widget.TextInputLayout>
<ImageButton
android:id="@+id/add_image_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:background="@android:color/white"
android:src="@android:drawable/ic_menu_camera"
android:tint="@color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="@+id/note_title_input"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/note_title_input" />
<Button
android:id="@+id/add_note_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
android:background="@drawable/button_style"
android:text="@string/save_note"
android:textColor="@android:color/white"
android:visibility="@{TextUtils.isEmpty(note.text) ? View.VISIBLE : View.GONE}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/note_text_input" />
<Button
android:id="@+id/edit_note_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
android:background="@drawable/button_style"
android:text="@string/edit_note"
android:visibility="@{TextUtils.isEmpty(note.text) ? View.GONE : View.VISIBLE}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/note_text_input" />
</android.support.constraint.ConstraintLayout>
</layout>