Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

458 changes: 458 additions & 0 deletions .idea/dbnavigator.xml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 13 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
compileSdkVersion 30
defaultConfig {
applicationId "com.example.umangburman.databindingwithlivedata"
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
Expand All @@ -23,16 +23,19 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'


def life_versions = "1.1.1"

// Lifecycle components
implementation "android.arch.lifecycle:extensions:$life_versions"
annotationProcessor "android.arch.lifecycle:compiler:$life_versions"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
//ViewModel components
implementation "androidx.lifecycle:lifecycle-viewmodel:2.3.1"
//noinspection LifecycleAnnotationProcessorWithJava8
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.3.1'
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.example.umangburman.databindingwithlivedata;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".View.MainActivity">
<activity android:name=".view.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.example.umangburman.databindingwithlivedata.Model;
package com.example.umangburman.databindingwithlivedata.model;

import android.util.Patterns;


public class LoginUser {

private String strEmailAddress;
private String strPassword;
private final String strEmailAddress;
private final String strPassword;

public LoginUser(String EmailAddress, String Password) {
strEmailAddress = EmailAddress;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.example.umangburman.databindingwithlivedata.view;

import androidx.lifecycle.ViewModelProvider;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import android.text.TextUtils;

import com.example.umangburman.databindingwithlivedata.R;
import com.example.umangburman.databindingwithlivedata.viewmodel.LoginViewModel;
import com.example.umangburman.databindingwithlivedata.databinding.ActivityMainBinding;

import java.util.Objects;

public class MainActivity extends AppCompatActivity {

private ActivityMainBinding binding;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

LoginViewModel loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class);

binding = DataBindingUtil.setContentView(MainActivity.this, R.layout.activity_main);

binding.setLifecycleOwner(this);

binding.setLoginViewModel(loginViewModel);

loginViewModel.getUser().observe(this, loginUser -> {

if (TextUtils.isEmpty(Objects.requireNonNull(loginUser).getStrEmailAddress())) {
binding.txtEmailAddress.setError("Enter an E-Mail Address");
binding.txtEmailAddress.requestFocus();
} else if (!loginUser.isEmailValid()) {
binding.txtEmailAddress.setError("Enter a Valid E-mail Address");
binding.txtEmailAddress.requestFocus();
} else if (TextUtils.isEmpty(Objects.requireNonNull(loginUser).getStrPassword())) {
binding.txtPassword.setError("Enter a Password");
binding.txtPassword.requestFocus();
} else if (!loginUser.isPasswordLengthGreaterThan5()) {
binding.txtPassword.setError("Enter at least 6 Digit password");
binding.txtPassword.requestFocus();
} else {
binding.lblEmailAnswer.setText(loginUser.getStrEmailAddress());
binding.lblPasswordAnswer.setText(loginUser.getStrPassword());
}

});

}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.example.umangburman.databindingwithlivedata.ViewModel;
package com.example.umangburman.databindingwithlivedata.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
import android.view.View;

import com.example.umangburman.databindingwithlivedata.Model.LoginUser;
import com.example.umangburman.databindingwithlivedata.model.LoginUser;

public class LoginViewModel extends ViewModel {

Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
<data>
<variable
name="LoginViewModel"
type="com.example.umangburman.databindingwithlivedata.ViewModel.LoginViewModel" />
type="com.example.umangburman.databindingwithlivedata.viewmodel.LoginViewModel" />
</data>

<android.support.v4.widget.NestedScrollView
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="true">

<android.support.constraint.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".View.MainActivity">
tools:context=".view.MainActivity">

<TextView
android:id="@+id/lblTitle"
Expand Down Expand Up @@ -124,8 +124,8 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lblEmailAnswer" />

</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

</android.support.v4.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>

</layout>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:4.2.2'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Sep 09 23:45:19 IST 2018
#Thu Jul 08 15:46:35 TRT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
zipStoreBase=GRADLE_USER_HOME
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ if $cygwin ; then
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a loginUser-defined pattern to the cygpath arguments
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
Expand Down