From e1931e6aa9b78b201468146c60b5144de5a0a249 Mon Sep 17 00:00:00 2001 From: Aditya Sharat Date: Tue, 13 Dec 2016 13:42:40 +0530 Subject: [PATCH 1/3] Resolves issue #63 --- build.gradle | 2 +- data/layout.json | 5 + data/layouts.json | 35 ++++++ data/user.json | 7 +- demo/src/main/res/drawable/border.xml | 6 +- demo/src/main/res/layout/activity_main.xml | 12 +- demo/src/main/res/layout/activity_native.xml | 24 ++-- .../res/layout/relative_layout_example.xml | 26 ++--- demo/src/main/res/menu/main.xml | 6 +- demo/src/main/res/raw/data_init.json | 10 +- demo/src/main/res/raw/data_update.json | 6 +- demo/src/main/res/values-v21/styles.xml | 1 + demo/src/main/res/values/styles.xml | 3 + demo/src/performance/AndroidManifest.xml | 7 +- library/build.gradle | 2 +- .../flipkart/android/proteus/DataContext.java | 10 +- .../builder/DataParsingLayoutBuilder.java | 103 ------------------ .../proteus/builder/SimpleLayoutBuilder.java | 15 +-- .../android/proteus/parser/Attributes.java | 1 + .../parser/custom/ViewGroupParser.java | 69 ++++++++---- .../proteus/toolbox/ProteusConstants.java | 6 +- 21 files changed, 168 insertions(+), 188 deletions(-) diff --git a/build.gradle b/build.gradle index 7896d046..d69cc69e 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.1' + classpath 'com.android.tools.build:gradle:2.2.2' } } diff --git a/data/layout.json b/data/layout.json index 0b560a79..94c06efb 100644 --- a/data/layout.json +++ b/data/layout.json @@ -135,6 +135,11 @@ "padding": "16dp", "paddingBottom": "0dp" }, + { + "type": "DataDrivenExample", + "padding": "16dp", + "paddingBottom": "0dp" + }, { "type": "CircleView", "layout_width": "150dp", diff --git a/data/layouts.json b/data/layouts.json index 4ce0a781..97576103 100644 --- a/data/layouts.json +++ b/data/layouts.json @@ -165,5 +165,40 @@ ] } ] + }, + "DataDrivenExample": { + "type": "FrameLayout", + "layout_width": "match_parent", + "layout_height": "wrap_content", + "children": [ + { + "type": "LinearLayout", + "orientation": "horizontal", + "layout_width": "match_parent", + "background": "#ffffff", + "padding": "16dp", + "children": { + "data": "$user.tags", + "layout":{ + "type": "TextView", + "dataContext": { + "tag": "user.tags[$index]" + }, + "layout_marginRight": "8dp", + "layout_height": "32dp", + "textSize": "12sp", + "textColor": "#2cdb81", + "text": "$tag", + "padding": "8dp", + "gravity": "center", + "border": { + "width": "2dp", + "color": "#cccccc", + "bgColor": "#efefef" + } + } + } + } + ] } } \ No newline at end of file diff --git a/data/user.json b/data/user.json index 7b5723ef..82c6ef81 100644 --- a/data/user.json +++ b/data/user.json @@ -15,6 +15,11 @@ "experience": { "current": 4561, "max": 9999 - } + }, + "tags": [ + "alpha", + "beta", + "gamma" + ] } } \ No newline at end of file diff --git a/demo/src/main/res/drawable/border.xml b/demo/src/main/res/drawable/border.xml index ac5ab17e..d476438b 100644 --- a/demo/src/main/res/drawable/border.xml +++ b/demo/src/main/res/drawable/border.xml @@ -16,10 +16,10 @@ --> + android:shape="rectangle"> + android:color="#cccccc"/> - + \ No newline at end of file diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index d245943c..66241e6f 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -15,10 +15,10 @@ --> + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical">