Adding alternate integration samples
Change-Id: I33bb8eb157824cbe9344bdf2315e8a92a35023e7
diff --git a/examples/hellobaku/android/app/src/main/AndroidManifest.xml b/examples/hellobaku/android/app/src/main/AndroidManifest.xml
index 40fdc1f..f3d2c93 100644
--- a/examples/hellobaku/android/app/src/main/AndroidManifest.xml
+++ b/examples/hellobaku/android/app/src/main/AndroidManifest.xml
@@ -16,6 +16,24 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity
+ android:name=".HelloActivityComposition"
+ android:label="@string/comp_label" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".HelloActivityALaCarte"
+ android:label="@string/alacarte_label" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
</application>
</manifest>
diff --git a/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivity.java b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivity.java
index 4e3623e..7c12d40 100644
--- a/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivity.java
+++ b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivity.java
@@ -10,7 +10,7 @@
public class HelloActivity extends BakuActivity {
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello);
diff --git a/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityALaCarte.java b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityALaCarte.java
new file mode 100644
index 0000000..f34b6e6
--- /dev/null
+++ b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityALaCarte.java
@@ -0,0 +1,60 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.baku.hellobaku;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+import io.v.baku.toolkit.VAndroidContextMixin;
+import io.v.baku.toolkit.VAndroidContextTrait;
+import io.v.baku.toolkit.bind.SyncbaseBinding;
+import io.v.rx.syncbase.GlobalUserSyncgroup;
+import io.v.rx.syncbase.RxDb;
+import io.v.rx.syncbase.RxSyncbase;
+import rx.Subscription;
+
+public class HelloActivityALaCarte extends Activity {
+ private RxSyncbase mSb;
+ private Subscription mActivityDataBindings;
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_hello);
+
+ final VAndroidContextTrait<HelloActivityALaCarte> vActivity =
+ VAndroidContextMixin.withDefaults(this, savedInstanceState);
+
+ mSb = new RxSyncbase(vActivity);
+ final RxDb db = mSb.rxApp("app").rxDb("db");
+
+ // We want these data bindings to share the lifecycle of the Activity from onCreate to
+ // onDestroy, so keep track of their CompositeSubscription and unsubscribe in onDestroy.
+ mActivityDataBindings = SyncbaseBinding.builder()
+ .activity(vActivity)
+ .rxTable(db.rxTable("t"))
+
+ .key("text")
+ .bindTo(R.id.textView)
+ .bindTo(R.id.editText)
+
+ .getSubscription();
+
+ GlobalUserSyncgroup.builder()
+ .activity(vActivity)
+ .syncbase(mSb).db(db)
+ .prefix("t")
+ .sgSuffix("myGlobalUserSyncgroup")
+ .build()
+ .join();
+ }
+
+ @Override
+ protected void onDestroy() {
+ mActivityDataBindings.unsubscribe();
+ mSb.close();
+ super.onDestroy();
+ }
+}
diff --git a/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityComposition.java b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityComposition.java
new file mode 100644
index 0000000..6aa337a
--- /dev/null
+++ b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityComposition.java
@@ -0,0 +1,33 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.baku.hellobaku;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+import io.v.baku.toolkit.BakuActivityMixin;
+import io.v.baku.toolkit.BakuActivityTrait;
+
+public class HelloActivityComposition extends Activity {
+ private BakuActivityTrait<HelloActivityComposition> mBaku;
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_hello);
+
+ mBaku = new BakuActivityMixin<>(this, savedInstanceState);
+
+ mBaku.binder().key("text")
+ .bindTo(R.id.textView)
+ .bindTo(R.id.editText);
+ }
+
+ @Override
+ protected void onDestroy() {
+ mBaku.close();
+ super.onDestroy();
+ }
+}
diff --git a/examples/hellobaku/android/app/src/main/res/values/strings.xml b/examples/hellobaku/android/app/src/main/res/values/strings.xml
index 778a970..b3c397f 100644
--- a/examples/hellobaku/android/app/src/main/res/values/strings.xml
+++ b/examples/hellobaku/android/app/src/main/res/values/strings.xml
@@ -1,6 +1,5 @@
<resources>
<string name="app_name">Hello Baku</string>
-
- <string name="hello_world">Hello world!</string>
- <string name="action_settings">Settings</string>
+ <string name="comp_label">Hello Baku - Composition</string>
+ <string name="alacarte_label">Hello Baku - À la Carte</string>
</resources>