Skip to content

Commit 10478ca

Browse files
committed
Add project files
1 parent 4f2c35c commit 10478ca

File tree

35 files changed

+678
-0
lines changed

35 files changed

+678
-0
lines changed

DataBinding/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures

DataBinding/.idea/.name

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DataBinding/.idea/compiler.xml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DataBinding/.idea/copyright/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DataBinding/.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DataBinding/.idea/gradle.xml

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DataBinding/.idea/misc.xml

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DataBinding/.idea/modules.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DataBinding/.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DataBinding/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

DataBinding/app/build.gradle

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 24
5+
buildToolsVersion "24.0.0"
6+
7+
defaultConfig {
8+
applicationId "com.learn2crack.databinding"
9+
minSdkVersion 19
10+
targetSdkVersion 24
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
15+
dataBinding {
16+
enabled = true
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
}
26+
27+
dependencies {
28+
compile fileTree(dir: 'libs', include: ['*.jar'])
29+
testCompile 'junit:junit:4.12'
30+
compile 'com.android.support:appcompat-v7:24.0.0'
31+
}

DataBinding/app/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /home/rajamalw/android-sdk-linux/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.learn2crack.databinding;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.learn2crack.databinding">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity android:name=".MainActivity">
12+
<intent-filter>
13+
<action android:name="android.intent.action.MAIN"/>
14+
15+
<category android:name="android.intent.category.LAUNCHER"/>
16+
</intent-filter>
17+
</activity>
18+
</application>
19+
20+
</manifest>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.learn2crack.databinding;
2+
3+
import android.databinding.DataBindingUtil;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
import android.util.Log;
7+
import android.widget.Toast;
8+
9+
import com.learn2crack.databinding.databinding.ActivityMainBinding;
10+
11+
12+
public class MainActivity extends AppCompatActivity {
13+
public static final String TAG =MainActivity.class.getSimpleName();
14+
15+
private ActivityMainBinding binding;
16+
17+
@Override
18+
protected void onCreate(Bundle savedInstanceState) {
19+
super.onCreate(savedInstanceState);
20+
21+
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
22+
User user = new User();
23+
user.setName("Learn2Crack");
24+
binding.setUser(user);
25+
binding.setActivity(this);
26+
}
27+
28+
public void onButtonClick(String email){
29+
30+
Log.d(TAG, "Email :" +binding.getUser().getEmail());
31+
Log.d(TAG, "Email : "+email);
32+
Toast.makeText(this,email,Toast.LENGTH_SHORT).show();
33+
}
34+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.learn2crack.databinding;
2+
3+
import android.databinding.BaseObservable;
4+
import android.databinding.Bindable;
5+
6+
public class User extends BaseObservable {
7+
8+
private String name;
9+
private String email;
10+
11+
public String getName() {
12+
return name;
13+
}
14+
15+
public void setName(String name) {
16+
this.name = name;
17+
}
18+
19+
@Bindable
20+
public String getEmail() {
21+
return email;
22+
}
23+
24+
public void setEmail(String email) {
25+
this.email = email;
26+
notifyPropertyChanged(com.learn2crack.databinding.BR.email);
27+
}
28+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools">
5+
6+
<data>
7+
<variable name="user" type="com.learn2crack.databinding.User"/>
8+
<variable name="activity" type="com.learn2crack.databinding.MainActivity"/>
9+
</data>
10+
11+
<RelativeLayout
12+
android:layout_width="match_parent"
13+
android:layout_height="match_parent"
14+
android:paddingBottom="@dimen/activity_vertical_margin"
15+
android:paddingLeft="@dimen/activity_horizontal_margin"
16+
android:paddingRight="@dimen/activity_horizontal_margin"
17+
android:paddingTop="@dimen/activity_vertical_margin"
18+
android:gravity="center"
19+
tools:context=".databinding.MainActivity">
20+
21+
<TextView
22+
android:id="@+id/name"
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:layout_centerHorizontal="true"
26+
android:textSize="18sp"
27+
android:text="@{user.name}"/>
28+
29+
<EditText
30+
android:id="@+id/email"
31+
android:layout_width="match_parent"
32+
android:layout_height="wrap_content"
33+
android:layout_marginTop="20dp"
34+
android:layout_below="@+id/name"
35+
android:inputType="textEmailAddress"
36+
android:text="@={user.email}"/>
37+
38+
<Button
39+
android:id="@+id/button"
40+
android:layout_width="match_parent"
41+
android:layout_height="wrap_content"
42+
android:layout_marginTop="20dp"
43+
android:layout_below="@+id/email"
44+
android:text="Get data"
45+
android:background="@color/colorPrimary"
46+
android:textColor="@android:color/white"
47+
android:onClick="@{()->activity.onButtonClick(user.email)}"/>
48+
49+
<TextView
50+
android:layout_width="wrap_content"
51+
android:layout_height="wrap_content"
52+
android:layout_marginTop="20dp"
53+
android:layout_below="@id/button"
54+
android:layout_centerHorizontal="true"
55+
android:textSize="16sp"
56+
android:text="@{user.email}"/>
57+
58+
</RelativeLayout>
59+
</layout>
Loading
Loading
Loading
Loading
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<resources>
2+
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
3+
(such as screen margins) for screens with more than 820dp of available width. This
4+
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
5+
<dimen name="activity_horizontal_margin">64dp</dimen>
6+
</resources>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#3F51B5</color>
4+
<color name="colorPrimaryDark">#303F9F</color>
5+
<color name="colorAccent">#FF4081</color>
6+
</resources>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
<!-- Default screen margins, per the Android Design guidelines. -->
3+
<dimen name="activity_horizontal_margin">16dp</dimen>
4+
<dimen name="activity_vertical_margin">16dp</dimen>
5+
</resources>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">DataBinding</string>
3+
</resources>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
<item name="colorPrimary">@color/colorPrimary</item>
7+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8+
<item name="colorAccent">@color/colorAccent</item>
9+
</style>
10+
11+
</resources>

0 commit comments

Comments
 (0)