Привет всем! Честно говоря я уже устал пытаться решить эту проблему - все проверил двадцать раз. Приложение компилируется, все ок, но вот данные с формы не обновляются! Допустим я ввожу статические данные в xml. Затем пользователь их меняет, и я хочу взять свежие данные, но у меня всегда возвращается лишь то, что я положил туда в начале. Я пробовал кидать данные через класс (в официальном примере), но это не помогло. Искал ошибку в связке gradl-ов, но и там ничего сверх-естественного не нашлось.Ниже привожу листинги всех основных моментов, вы уж извините за кол-во листингов. Если вы не можете помочь с проблемой, плжлста дайте пример 100% рабочего примера, со всеми gradle.
Gradle-project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta7'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle-app
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-kapt'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.example.darkt.makeyouself"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// implementation 'com.google.firebase:firebase-auth:11.0.4'
def firebaseLibVersion = '11.2.0'
compile "com.google.firebase:firebase-core:$firebaseLibVersion"
compile "com.google.firebase:firebase-auth:$firebaseLibVersion"
compile "com.google.firebase:firebase-storage:$firebaseLibVersion"
compile "com.google.firebase:firebase-database:$firebaseLibVersion"
compile "com.google.firebase:firebase-messaging:$firebaseLibVersion"
compile "com.google.firebase:firebase-config:$firebaseLibVersion"
compile "com.google.android.gms:play-services-auth:$firebaseLibVersion"
compile "com.google.android.gms:play-services-places:$firebaseLibVersion"
compile 'com.kelvinapps:rxfirebase:0.0.15'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
implementation 'com.android.support:design:26.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
kapt "com.android.databinding:compiler:3.0.0-beta7"
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true
}
}
apply plugin: 'com.google.gms.google-services'
FBLogin - activity на которой и происходит все дело. Привожу урезанный вариант, основные моменты:
class FBLogin : AppCompatActivity() {
private var binding: ActivityFbloginBinding? = null
private var auth: FirebaseAuth? = null
private var dbHelper: FirebaseHelper? =null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_fblogin)
auth = FirebaseAuth.getInstance()
dbHelper = FirebaseHelper()
setContentView(R.layout.activity_fblogin)
// binding?.executePendingBindings()
loginButton.setOnClickListener{_ -> loginToSystem()}
}
private fun loginToSystem() {
binding?.executePendingBindings()
//showProgressDialog()
val email = binding?.userName?.text.toString().trim()
val password = binding?.userPass?.text.toString()
//binding?.executePendingBindings()
Toast.makeText(this, email, Toast.LENGTH_SHORT).show()
Toast.makeText(this, password, Toast.LENGTH_SHORT).show()
}
}
И собственно fblogin_activity.xml
<?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">
<data>
</data>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey_main"
android:descendantFocusability="beforeDescendants"
android:fitsSystemWindows="true"
android:focusableInTouchMode="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context="com.example.darkt.makeyouself.activities.FBLogin"
tools:ignore="MissingConstraints">
<EditText
android:id="@+id/userName"
android:layout_width="220dp"
android:layout_height="43dp"
android:ems="10"
android:inputType="textPersonName"
android:text="test01"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Login"/>
<EditText
android:id="@+id/userPass"
android:layout_width="220dp"
android:layout_height="45dp"
android:layout_marginTop="25dp"
android:ems="10"
android:inputType="textPassword"
android:text="123456"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/userName"
tools:layout_editor_absoluteX="74dp"
tools:layout_editor_absoluteY="245dp"
tools:text="Password"/>
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Login"
android:textColor="@color/green_main"
app:layout_constraintEnd_toEndOf="@+id/userPass"
app:layout_constraintTop_toBottomOf="@+id/userPass" />
</android.support.constraint.ConstraintLayout>
</layout>
Код приведен совсем в простом варианте. Как уже говорил, я пробовал все подряд, и вроде как я все делаю по-примерам с оф.сайт и просто с форумов, но вот переменные никак с формой связь не поддерживают. (текущий пример взять с java я использовал подобные конструкции и все работало!). Прошу не судить строго за код и минусами меня не забрасывать, это первой приложение на kotlin.
test01
и123456
?