From 2c0ee8878a77501ee86cb85a51e4da752ed4391d Mon Sep 17 00:00:00 2001 From: whinc Date: Tue, 8 Dec 2015 10:41:25 +0800 Subject: [PATCH 1/5] Remove red error report in ViewStubActivity.java --- .../databinding/sample/viewstub/ViewStubActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/liangfeizc/databinding/sample/viewstub/ViewStubActivity.java b/app/src/main/java/com/liangfeizc/databinding/sample/viewstub/ViewStubActivity.java index be1e806..96a4a1e 100644 --- a/app/src/main/java/com/liangfeizc/databinding/sample/viewstub/ViewStubActivity.java +++ b/app/src/main/java/com/liangfeizc/databinding/sample/viewstub/ViewStubActivity.java @@ -1,6 +1,7 @@ package com.liangfeizc.databinding.sample.viewstub; import android.databinding.DataBindingUtil; +import android.databinding.ViewStubProxy; import android.os.Bundle; import android.view.View; import android.view.ViewStub; @@ -35,8 +36,9 @@ public void onInflate(ViewStub stub, View inflated) { * Don't panic for red error reporting. Just ignore it and run the app. Surprise never ends. */ public void inflateViewStub(View view) { - if (!mBinding.viewStub.isInflated()) { - mBinding.viewStub.getViewStub().inflate(); + ViewStubProxy viewStubProxy = (ViewStubProxy)(Object)mBinding.viewStub; + if (!viewStubProxy.isInflated()) { + viewStubProxy.getViewStub().inflate(); } } } \ No newline at end of file From ea0eb6f456b22fbea00870db5023a6638428541e Mon Sep 17 00:00:00 2001 From: whinc Date: Tue, 8 Dec 2015 10:58:35 +0800 Subject: [PATCH 2/5] remove files that don't need in VCS --- .gitignore | 39 +----- .idea/.name | 1 - .idea/compiler.xml | 22 ---- .idea/copyright/profiles_settings.xml | 3 - .idea/gradle.xml | 19 --- .idea/inspectionProfiles/Project_Default.xml | 6 - .../inspectionProfiles/profiles_settings.xml | 7 -- .idea/misc.xml | 69 ----------- .idea/modules.xml | 9 -- .idea/runConfigurations.xml | 12 -- .idea/vcs.xml | 6 - AndroidDataBinding.iml | 19 --- app/.gitignore | 1 - app/app.iml | 111 ------------------ 14 files changed, 5 insertions(+), 319 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/runConfigurations.xml delete mode 100644 .idea/vcs.xml delete mode 100644 AndroidDataBinding.iml delete mode 100644 app/.gitignore delete mode 100644 app/app.iml diff --git a/.gitignore b/.gitignore index ab1c64e..d1d697e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,6 @@ -# Built application files -*.apk -*.ap_ - -# Files for the Dalvik VM -*.dex - -# Java class files -*.class - -# Generated files -bin/ -gen/ - -# Gradle files -.gradle/ -build/ -/*/build/ - -# Local configuration file (sdk path, etc) -local.properties - -# Proguard folder generated by Eclipse -proguard/ - -# Log Files -*.log .gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures -/infer-out +.idea +build +*/build +*.iml +local.properties \ No newline at end of file diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 2fd06de..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -DataBindingSamples \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 7c4fca0..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 0833b17..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index ae715a8..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 3b31283..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 64948a6..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - Android Lint - - - Control flow issuesJava - - - Java - - - Probable bugsJava - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index defe20b..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/AndroidDataBinding.iml b/AndroidDataBinding.iml deleted file mode 100644 index 3216c27..0000000 --- a/AndroidDataBinding.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/app/app.iml b/app/app.iml deleted file mode 100644 index ac8f47e..0000000 --- a/app/app.iml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 48b1a35d9b4a9e357e149ec4e1a4104d33f4b480 Mon Sep 17 00:00:00 2001 From: whinc Date: Tue, 8 Dec 2015 11:24:07 +0800 Subject: [PATCH 3/5] Update dynamic sample --- .../liangfeizc/databinding/sample/dynamic/UserAdapter.java | 4 ++-- app/src/main/res/layout/user_item.xml | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/liangfeizc/databinding/sample/dynamic/UserAdapter.java b/app/src/main/java/com/liangfeizc/databinding/sample/dynamic/UserAdapter.java index 76a6d02..63a760a 100644 --- a/app/src/main/java/com/liangfeizc/databinding/sample/dynamic/UserAdapter.java +++ b/app/src/main/java/com/liangfeizc/databinding/sample/dynamic/UserAdapter.java @@ -19,13 +19,13 @@ * Created by rufi on 6/5/15. */ public class UserAdapter extends RecyclerView.Adapter { - private static final int USER_COUNT = 10; + private static final int USER_COUNT = 100; @NonNull private List mUsers; public UserAdapter() { - mUsers = new ArrayList<>(10); + mUsers = new ArrayList<>(USER_COUNT); for (int i = 0; i < USER_COUNT; i ++) { User user = new User(Randoms.nextFirstName(), Randoms.nextLastName()); mUsers.add(user); diff --git a/app/src/main/res/layout/user_item.xml b/app/src/main/res/layout/user_item.xml index 481bf8d..3bd4ec4 100644 --- a/app/src/main/res/layout/user_item.xml +++ b/app/src/main/res/layout/user_item.xml @@ -7,7 +7,9 @@ + android:orientation="horizontal" + android:padding="20dp" + > Date: Tue, 8 Dec 2015 11:52:28 +0800 Subject: [PATCH 4/5] Update DataBinding Conversions sample --- .../sample/converter/ConversionsActivity.java | 25 +++++--- .../main/res/layout/activity_conversions.xml | 64 ++++++++++++++----- 2 files changed, 64 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/liangfeizc/databinding/sample/converter/ConversionsActivity.java b/app/src/main/java/com/liangfeizc/databinding/sample/converter/ConversionsActivity.java index ea5b871..0586791 100644 --- a/app/src/main/java/com/liangfeizc/databinding/sample/converter/ConversionsActivity.java +++ b/app/src/main/java/com/liangfeizc/databinding/sample/converter/ConversionsActivity.java @@ -10,30 +10,37 @@ import android.view.ViewGroup; import com.liangfeizc.databinding.R; -import com.liangfeizc.databinding.sample.BaseActivity; import com.liangfeizc.databinding.databinding.ActivityConversionsBinding; +import com.liangfeizc.databinding.sample.BaseActivity; import com.liangfeizc.databinding.utils.ScreenUtils; public class ConversionsActivity extends BaseActivity { - private ObservableBoolean mIsError = new ObservableBoolean(); + private boolean mIsError; + private ObservableBoolean mIsErrorObservable = new ObservableBoolean(); + private ActivityConversionsBinding mBinding; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - ActivityConversionsBinding binding = - DataBindingUtil.setContentView(this, R.layout.activity_conversions); - - mIsError.set(true); + mBinding = DataBindingUtil.setContentView(this, R.layout.activity_conversions); - binding.setIsError(mIsError); - binding.setHeight(ScreenUtils.dp2px(this, 200)); + mIsError = true; + mBinding.setIsError(mIsError); + mBinding.setHeight(ScreenUtils.dp2px(this, 100)); + mIsErrorObservable.set(true); + mBinding.setIsErrorObservable(mIsErrorObservable); } public void toggleIsError(View view) { - mIsError.set(!mIsError.get()); + mIsError = !mIsError; + mBinding.setIsError(mIsError); + } + + public void toggleIsErrorObservable(View view) { + mIsErrorObservable.set(!mIsErrorObservable.get()); } @BindingConversion diff --git a/app/src/main/res/layout/activity_conversions.xml b/app/src/main/res/layout/activity_conversions.xml index 61d8684..6131236 100644 --- a/app/src/main/res/layout/activity_conversions.xml +++ b/app/src/main/res/layout/activity_conversions.xml @@ -2,29 +2,61 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> - + + + - - - + + android:layout_height="0dp" + android:layout_weight="1" + android:paddingBottom="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin"> + + -