├── .gitignore
├── .project
├── LICENSE
├── README.adoc
├── app
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── org
│ │ └── robobinding
│ │ └── gallerytest
│ │ └── DemoTraveller.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── org
│ │ └── robobinding
│ │ └── gallery
│ │ ├── activity
│ │ ├── AbstractActivity.java
│ │ ├── AbstractFragment.java
│ │ ├── AbstractFragmentActivity.java
│ │ ├── AdapterViewActivity.java
│ │ ├── ContextMenuDemoActivity.java
│ │ ├── ContextualActionModeActivity.java
│ │ ├── CustomComponentActivity.java
│ │ ├── EditTextActivity.java
│ │ ├── FragmentDemo.java
│ │ ├── FragmentTitleTag.java
│ │ ├── GalleryActivity.java
│ │ ├── GalleryApp.java
│ │ ├── ListFragmentDemo.java
│ │ ├── ListFragmentDemoActivity.java
│ │ ├── ListViewActivity.java
│ │ ├── MenuItemBinding.java
│ │ ├── MenuItemGroupBinding.java
│ │ ├── OptionMenuFragment.java
│ │ ├── OptionsMenuActivity.java
│ │ ├── RecyclerViewActivity.java
│ │ ├── TypedCursorActivity.java
│ │ ├── ViewActivity.java
│ │ ├── ViewBindingForView.java
│ │ └── ViewPagerActivity.java
│ │ ├── invocationlog
│ │ ├── PublicMethodInvocationLog.java
│ │ └── PublicMethodInvocationLogAspect.aj
│ │ ├── model
│ │ ├── MemoryProductStore.java
│ │ ├── Product.java
│ │ ├── Strings.java
│ │ ├── TestData.java
│ │ ├── adapterview
│ │ │ ├── SampleStringType.java
│ │ │ ├── SampleStrings.java
│ │ │ └── StringItemLayout.java
│ │ ├── customcomponent
│ │ │ ├── TitleDescriptionBar.java
│ │ │ └── TitleDescriptionBarBinding.java
│ │ ├── listview
│ │ │ └── SampleStringsFooter.java
│ │ ├── typedcursor
│ │ │ ├── DatabaseHelper.java
│ │ │ ├── GetAllQuery.java
│ │ │ ├── ProductItemPresentationModel.java
│ │ │ ├── ProductRowMapper.java
│ │ │ └── ProductTable.java
│ │ └── view
│ │ │ ├── BooleanVisibility.java
│ │ │ └── IntegerVisibility.java
│ │ ├── presentationmodel
│ │ ├── AdapterViewPresentationModel.java
│ │ ├── ContextMenuDemoPresentationModel.java
│ │ ├── ContextMenuPresentationModel.java
│ │ ├── ContextualActionModePresentationModel.java
│ │ ├── CustomComponentPresentationModel.java
│ │ ├── EditTextPresentationModel.java
│ │ ├── FragmentDemoPresentationModel.java
│ │ ├── FragmentTitleTagPresentationModel.java
│ │ ├── GalleryPresentationModel.java
│ │ ├── ListFragmentDemoPresentationModel.java
│ │ ├── ListViewPresentationModel.java
│ │ ├── MenuPresentationModel.java
│ │ ├── RecyclerViewPresentationModel.java
│ │ ├── StringItemPresentationModel.java
│ │ ├── ToStringItemPresentationModel.java
│ │ ├── TypedCursorPresentationModel.java
│ │ └── ViewPresentationModel.java
│ │ └── util
│ │ └── CircularIntegers.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-ldpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable
│ ├── background_activated.xml
│ ├── my_custom_border.xml
│ └── my_list_selector_background.xml
│ ├── layout
│ ├── activity_adapter_view.xml
│ ├── activity_byinterface_noaspectj.xml
│ ├── activity_bysubclass_noaspectj.xml
│ ├── activity_context_menu_demo.xml
│ ├── activity_contextual_action_mode.xml
│ ├── activity_custom_component.xml
│ ├── activity_edittext.xml
│ ├── activity_fragment.xml
│ ├── activity_gallery.xml
│ ├── activity_list_view.xml
│ ├── activity_recycler_view.xml
│ ├── activity_typed_cursor.xml
│ ├── activity_view.xml
│ ├── custom_or_third_party_component.xml
│ ├── fragment_demo.xml
│ ├── fragment_list_demo.xml
│ ├── fragment_options_menu.xml
│ ├── fragment_title_tag.xml
│ ├── sample_strings_footer.xml
│ ├── sample_strings_header.xml
│ ├── string_item_layout1.xml
│ ├── string_item_layout2.xml
│ └── title_description_bar.xml
│ ├── menu
│ ├── context_menu.xml
│ ├── contextual_action_mode.xml
│ └── options_menu.xml
│ └── values
│ ├── attrs.xml
│ ├── ids.xml
│ └── strings.xml
├── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | /.idea
3 | /build
4 | /.gradle
5 | /app/app.iml
6 | /app/build
7 | /RoboBinding-gallery.iml
8 | /app/libs
9 | /local.properties
10 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | RoboBinding-gallery
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2012-2014 Cheng Wei and RoboBinding Contributors
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions
13 | and limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | **Note:** please issue the following in command line - 'gradlew build --refresh-dependencies' in Windows or './gradlew build --refresh-dependencies' in Linux or Mac to force update to the latest RoboBinding snapshot when required.
2 |
3 | An android app to showcase the usage of https://github.com/RoboBinding/RoboBinding[RoboBinding] framework.
4 |
5 | The project can be directly imported into Android Studio.
6 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | maven() {
4 | name 'Local RoboBinding AspectJPlugin Maven Repository'
5 | url "file://D:/git/RoboBinding-aspectj-plugin/mavenRepo"
6 | }
7 | mavenCentral()
8 | maven() {
9 | name 'RoboBinding AspectJPlugin Maven Repository'
10 | url "https://github.com/RoboBinding/RoboBinding-aspectj-plugin/raw/master/mavenRepo"
11 | //url "file://D:/git/RoboBinding-aspectj-plugin/mavenRepo"
12 | }
13 | }
14 |
15 | dependencies {
16 | classpath 'com.android.tools.build:gradle:2.2.1'
17 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
18 | classpath 'org.robobinding:aspectj-plugin:0.8.5'
19 | }
20 | }
21 |
22 | apply plugin: 'com.android.application'
23 | apply plugin: 'com.neenbedankt.android-apt'
24 | apply plugin: 'org.robobinding.android-aspectj'
25 |
26 | android {
27 | compileSdkVersion 22
28 | buildToolsVersion "22.0.1"
29 |
30 | defaultConfig {
31 | minSdkVersion 8
32 | targetSdkVersion 21
33 |
34 | testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
35 | //testInstrumentationRunner "android.test.InstrumentationTestRunner"
36 | testApplicationId 'org.robobinding.gallerytest'
37 | testHandleProfiling true
38 | testFunctionalTest true
39 |
40 | }
41 |
42 | compileOptions {
43 | sourceCompatibility JavaVersion.VERSION_1_6
44 | targetCompatibility JavaVersion.VERSION_1_6
45 | }
46 |
47 | buildTypes {
48 | release {
49 | minifyEnabled false
50 | proguardFiles 'proguard-rules.pro'
51 | }
52 | }
53 |
54 | lintOptions {
55 | disable 'UnusedAttribute', 'ValidFragment', 'GradleDependency', 'OnClick', 'MissingPrefix', 'MenuTitle'
56 | abortOnError false
57 | }
58 |
59 | packagingOptions {
60 | exclude 'LICENSE.txt'
61 | }
62 | }
63 |
64 | repositories {
65 | maven() {
66 | name 'RoboBinding Framework Maven Repository'
67 | url "file://D:/git/RoboBinding/framework/mavenRepo"
68 | }
69 | maven() {
70 | name 'RoboBinding CodeGen Maven Repository'
71 | url "file://D:/git/RoboBinding/codegen/mavenRepo"
72 | }
73 | maven() {
74 | name 'RoboBinding Extras Maven Repository'
75 | url "file://D:/git/RoboBinding/extras/mavenRepo"
76 | }
77 | mavenCentral()
78 | maven() {
79 | name 'SonaType snapshot repository'
80 | url 'https://oss.sonatype.org/content/repositories/snapshots'
81 | }
82 | }
83 |
84 | ext {
85 | //robobindingVersion = 'latest.integration'
86 | robobindingVersion = '0.8.14'
87 | }
88 |
89 | dependencies {
90 | //compile fileTree(dir: 'libs', include: '*.jar')
91 | compile ("org.robobinding:robobinding:${robobindingVersion}:with-aop") {
92 | exclude group: 'com.google.guava'
93 | }
94 | compile "org.robobinding:extras:${robobindingVersion}"
95 | compile 'com.android.support:appcompat-v7:22.1.1'
96 | compile 'com.android.support:recyclerview-v7:22.1.1'
97 | compile 'com.google.guava:guava:16.0'
98 |
99 | //aspectPath fileTree(dir: 'libs', include: '*.jar')
100 | aspectPath "org.robobinding:robobinding:${robobindingVersion}:with-aop"
101 |
102 | apt "org.robobinding:codegen:$robobindingVersion"
103 |
104 | androidTestCompile('com.jakewharton.espresso:espresso-support-v4:1.1-r3') {
105 | exclude group:'com.android.support', module:'support-v4'
106 | exclude group:'com.android.support', module:'appcompat-v7'
107 | exclude group: 'com.google.guava'
108 | }
109 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\windows7\android-studio\sdk/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 | #}
18 | -optimizationpasses 5
19 | -dontusemixedcaseclassnames
20 | -dontskipnonpubliclibraryclasses
21 | -dontpreverify
22 | -verbose
23 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
24 |
25 | -keep public class * extends android.app.Activity
26 | -keep public class * extends android.app.Application
27 | -keep public class * extends android.app.Service
28 | -keep public class * extends android.content.BroadcastReceiver
29 | -keep public class * extends android.content.ContentProvider
30 | -keep public class * extends android.app.backup.BackupAgentHelper
31 | -keep public class * extends android.preference.Preference
32 | -keep public class com.android.vending.licensing.ILicensingService
33 |
34 | -keepclasseswithmembernames class * {
35 | native ;
36 | }
37 |
38 | -keepclasseswithmembers class * {
39 | public (android.content.Context, android.util.AttributeSet);
40 | }
41 |
42 | -keepclasseswithmembers class * {
43 | public (android.content.Context, android.util.AttributeSet, int);
44 | }
45 |
46 | -keepclassmembers class * extends android.app.Activity {
47 | public void *(android.view.View);
48 | }
49 |
50 | -keepclassmembers enum * {
51 | public static **[] values();
52 | public static ** valueOf(java.lang.String);
53 | }
54 |
55 | -keep class * implements android.os.Parcelable {
56 | public static final android.os.Parcelable$Creator *;
57 | }
58 |
59 | -dontwarn sun.misc.Unsafe
60 |
61 | ##########################
62 | ### For robobinding
63 | ##########################
64 | -keepattributes *Annotation*,Signature
65 |
66 | -keep class * implements org.robobinding.property.ObservableBean {
67 | public *** *(...);
68 | }
69 |
70 | -keepclassmembers class * extends org.robobinding.widget.view.ViewListeners {
71 | public (...);
72 | }
73 |
74 | -keepclassmembers class org.robobinding.gallery.model.dynamicbinding.CustomOrThirdPartyComponent {
75 | public void set*(***);
76 | public boolean is*();
77 | public *** get*();
78 | }
79 |
80 | -dontwarn android.widget.AbsListView, android.view.View
81 | -dontwarn javax.annotation.**
82 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/org/robobinding/gallerytest/DemoTraveller.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallerytest;
2 |
3 | import android.test.ActivityInstrumentationTestCase2;
4 | import android.test.suitebuilder.annotation.LargeTest;
5 | import android.widget.Spinner;
6 |
7 | import com.google.android.apps.common.testing.ui.espresso.Espresso;
8 | import com.google.android.apps.common.testing.ui.espresso.action.ViewActions;
9 | import com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers;
10 |
11 | import org.hamcrest.Matchers;
12 | import org.robobinding.gallery.R;
13 | import org.robobinding.gallery.activity.GalleryActivity;
14 |
15 | /**
16 | *
17 | * @since 1.0
18 | * @version $Revision: 1.0 $
19 | * @author Cheng Wei
20 | */
21 | @LargeTest
22 | public class DemoTraveller extends ActivityInstrumentationTestCase2 {
23 | public DemoTraveller() {
24 | super(GalleryActivity.class);
25 | }
26 |
27 | public void testTravelThroughAllDemos() {
28 | Spinner demoSpinner = (Spinner)getActivity().findViewById(R.id.demoSpinner);
29 | int numDemos = demoSpinner.getCount();
30 |
31 | for(int i=0; i
2 |
6 |
7 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/AbstractActivity.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.MenuBinder;
4 | import org.robobinding.ViewBinder;
5 | import org.robobinding.binder.BinderFactory;
6 | import org.robobinding.gallery.model.typedcursor.DatabaseHelper;
7 |
8 | import android.support.v7.app.ActionBarActivity;
9 | import android.view.Menu;
10 | import android.view.MenuInflater;
11 | import android.view.View;
12 |
13 | /**
14 | *
15 | * @since 1.0
16 | * @version $Revision: 1.0 $
17 | * @author Cheng Wei
18 | */
19 | public abstract class AbstractActivity extends ActionBarActivity {
20 | public void initializeContentView(int layoutId, Object presentationModel) {
21 | ViewBinder viewBinder = createViewBinder();
22 | View rootView = viewBinder.inflateAndBind(layoutId, presentationModel);
23 | setContentView(rootView);
24 | }
25 |
26 | private ViewBinder createViewBinder() {
27 | BinderFactory binderFactory = getReusableBinderFactory();
28 | return binderFactory.createViewBinder(this);
29 | }
30 |
31 | protected BinderFactory getReusableBinderFactory() {
32 | BinderFactory binderFactory = getGalleryApp().getReusableBinderFactory();
33 | return binderFactory;
34 | }
35 |
36 | private GalleryApp getGalleryApp() {
37 | return (GalleryApp)getApplicationContext();
38 | }
39 |
40 | protected DatabaseHelper getDatabaseHelper() {
41 | return getGalleryApp().getDatabaseHelper();
42 | }
43 |
44 | protected MenuBinder createMenuBinder(Menu menu, MenuInflater menuInflater) {
45 | BinderFactory binderFactory = getReusableBinderFactory();
46 | return binderFactory.createMenuBinder(menu, menuInflater, this);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/AbstractFragment.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.MenuBinder;
4 | import org.robobinding.ViewBinder;
5 | import org.robobinding.binder.BinderFactory;
6 |
7 | import android.support.v4.app.Fragment;
8 | import android.view.Menu;
9 | import android.view.MenuInflater;
10 |
11 | /**
12 | *
13 | * @since 1.0
14 | * @version $Revision: 1.0 $
15 | * @author Cheng Wei
16 | */
17 | public abstract class AbstractFragment extends Fragment {
18 | protected ViewBinder createViewBinder() {
19 | BinderFactory binderFactory = getReusableBinderFactory();
20 | return binderFactory.createViewBinder(getActivity());
21 | }
22 |
23 | private BinderFactory getReusableBinderFactory() {
24 | BinderFactory binderFactory = getGalleryApp().getReusableBinderFactory();
25 | return binderFactory;
26 | }
27 |
28 | private GalleryApp getGalleryApp() {
29 | return (GalleryApp)getActivity().getApplicationContext();
30 | }
31 |
32 | protected MenuBinder createMenuBinder(Menu menu, MenuInflater menuInflater) {
33 | BinderFactory binderFactory = getReusableBinderFactory();
34 | return binderFactory.createMenuBinder(menu, menuInflater, getActivity());
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/AbstractFragmentActivity.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.gallery.R;
4 |
5 | import android.os.Bundle;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v4.app.FragmentManager;
8 | import android.support.v7.app.ActionBarActivity;
9 |
10 | /**
11 | *
12 | * @since 1.0
13 | * @version $Revision: 1.0 $
14 | * @author Cheng Wei
15 | */
16 | public abstract class AbstractFragmentActivity extends ActionBarActivity {
17 |
18 | @Override
19 | public void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_fragment);
22 |
23 | FragmentManager fm = getSupportFragmentManager();
24 | Fragment fragment = fm.findFragmentById(R.id.fragmentContainer);
25 | if (fragment == null) {
26 | fragment = createFragment();
27 | fm.beginTransaction().add(R.id.fragmentContainer, fragment).commit();
28 | }
29 | }
30 |
31 | protected abstract Fragment createFragment();
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/AdapterViewActivity.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.ViewBinder;
4 | import org.robobinding.binder.BinderFactory;
5 | import org.robobinding.gallery.R;
6 | import org.robobinding.gallery.presentationmodel.AdapterViewPresentationModel;
7 |
8 | import android.os.Bundle;
9 | import android.view.View;
10 |
11 | /**
12 | *
13 | * @since 1.0
14 | * @version $Revision: 1.0 $
15 | * @author Cheng Wei
16 | */
17 | public class AdapterViewActivity extends AbstractActivity {
18 | private AdapterViewPresentationModel presentationModel;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 |
24 | presentationModel = new AdapterViewPresentationModel();
25 | ViewBinder viewBinder = getReusableBinderFactory().createViewBinder(this, false);
26 | View rootView = viewBinder.inflateAndBind(R.layout.activity_adapter_view, presentationModel);
27 | setContentView(rootView);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/ContextMenuDemoActivity.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.MenuBinder;
4 | import org.robobinding.gallery.R;
5 | import org.robobinding.gallery.model.MemoryProductStore;
6 | import org.robobinding.gallery.presentationmodel.ContextMenuDemoPresentationModel;
7 | import org.robobinding.gallery.presentationmodel.ContextMenuPresentationModel;
8 |
9 | import android.os.Bundle;
10 | import android.view.ContextMenu;
11 | import android.view.ContextMenu.ContextMenuInfo;
12 | import android.view.View;
13 | import android.widget.ListView;
14 |
15 | /**
16 | *
17 | * @since 1.0
18 | * @version $Revision: 1.0 $
19 | * @author Cheng Wei
20 | */
21 | public class ContextMenuDemoActivity extends AbstractActivity {
22 | private ContextMenuDemoPresentationModel presentationModel;
23 | private ContextMenuPresentationModel contextMenuPresentationModel;
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 |
28 | MemoryProductStore productStore = MemoryProductStore.getInstance();
29 | productStore.reset();
30 |
31 | presentationModel = new ContextMenuDemoPresentationModel(productStore);
32 | contextMenuPresentationModel = new ContextMenuPresentationModel(productStore, presentationModel);
33 |
34 | initializeContentView(R.layout.activity_context_menu_demo, presentationModel);
35 |
36 | ListView productListView = (ListView)findViewById(R.id.productList);
37 | registerForContextMenu(productListView);
38 | }
39 |
40 | @Override
41 | public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
42 | MenuBinder menuBinder = createMenuBinder(menu, getMenuInflater());
43 | menuBinder.inflateAndBind(R.menu.context_menu, contextMenuPresentationModel);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/ContextualActionModeActivity.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.MenuBinder;
4 | import org.robobinding.gallery.R;
5 | import org.robobinding.gallery.model.MemoryProductStore;
6 | import org.robobinding.gallery.presentationmodel.ContextualActionModePresentationModel;
7 |
8 | import android.os.Bundle;
9 | import android.support.v7.view.ActionMode;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.View;
13 | import android.widget.AdapterView;
14 | import android.widget.AdapterView.OnItemLongClickListener;
15 | import android.widget.ListView;
16 |
17 | /**
18 | *
19 | * @since 1.0
20 | * @version $Revision: 1.0 $
21 | * @author Cheng Wei
22 | */
23 | public class ContextualActionModeActivity extends AbstractActivity {
24 | private ContextualActionModePresentationModel presentationModel;
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 |
29 | MemoryProductStore productStore = MemoryProductStore.getInstance();
30 | productStore.reset();
31 |
32 | presentationModel = new ContextualActionModePresentationModel(productStore);
33 |
34 | initializeContentView(R.layout.activity_contextual_action_mode, presentationModel);
35 |
36 | ListView productListView = (ListView)findViewById(R.id.productList);
37 | productListView.setOnItemLongClickListener(new OnItemLongClickListener() {
38 | @Override
39 | public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
40 | startSupportActionMode(new ActionMode.Callback() {
41 |
42 | @Override
43 | public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
44 | return false;
45 | }
46 |
47 | @Override
48 | public void onDestroyActionMode(ActionMode actionMode) {
49 | }
50 |
51 | @Override
52 | public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
53 | MenuBinder menuBinder = createMenuBinder(menu, getMenuInflater());
54 | menuBinder.inflateAndBind(R.menu.contextual_action_mode, presentationModel);
55 | return true;
56 | }
57 |
58 | @Override
59 | public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
60 | return false;
61 | }
62 | });
63 | return true;
64 | }
65 | });
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/CustomComponentActivity.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.ViewBinder;
4 | import org.robobinding.binder.BinderFactory;
5 | import org.robobinding.binder.BinderFactoryBuilder;
6 | import org.robobinding.gallery.R;
7 | import org.robobinding.gallery.model.customcomponent.TitleDescriptionBar;
8 | import org.robobinding.gallery.model.customcomponent.TitleDescriptionBarBinding;
9 | import org.robobinding.gallery.presentationmodel.CustomComponentPresentationModel;
10 |
11 | import android.app.Activity;
12 | import android.os.Bundle;
13 | import android.view.View;
14 |
15 | /**
16 | *
17 | * @since 1.0
18 | * @version $Revision: 1.0 $
19 | * @author Cheng Wei
20 | */
21 | public class CustomComponentActivity extends Activity {
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 |
26 | CustomComponentPresentationModel presentationModel = new CustomComponentPresentationModel();
27 |
28 | initializeContentView(R.layout.activity_custom_component, presentationModel);
29 | }
30 |
31 | private void initializeContentView(int layoutId, Object presentationModel) {
32 | ViewBinder viewBinder = createViewBinder();
33 | View rootView = viewBinder.inflateAndBind(layoutId, presentationModel);
34 | setContentView(rootView);
35 | }
36 |
37 | private ViewBinder createViewBinder() {
38 | BinderFactory binderFactory = new BinderFactoryBuilder()
39 | .add(new TitleDescriptionBarBinding().forView(TitleDescriptionBar.class))
40 | .build();
41 | return binderFactory.createViewBinder(this);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/EditTextActivity.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.gallery.R;
4 | import org.robobinding.gallery.presentationmodel.EditTextPresentationModel;
5 |
6 | import android.os.Bundle;
7 |
8 | /**
9 | *
10 | * @since 1.0
11 | * @version $Revision: 1.0 $
12 | * @author Cheng Wei
13 | */
14 | public class EditTextActivity extends AbstractActivity {
15 | private EditTextPresentationModel presentationModel;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 |
21 | presentationModel = new EditTextPresentationModel();
22 | initializeContentView(R.layout.activity_edittext, presentationModel);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/FragmentDemo.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.ViewBinder;
4 | import org.robobinding.gallery.R;
5 | import org.robobinding.gallery.model.MemoryProductStore;
6 | import org.robobinding.gallery.model.Product;
7 | import org.robobinding.gallery.presentationmodel.FragmentDemoPresentationModel;
8 |
9 | import android.os.Bundle;
10 | import android.support.annotation.Nullable;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 |
15 | /**
16 | *
17 | * @since 1.0
18 | * @version $Revision: 1.0 $
19 | * @author Cheng Wei
20 | */
21 | public class FragmentDemo extends AbstractFragment {
22 | public static final String EXTRA_PRODUCT_INDEX = "org.robobinding.gallery.FragmentDemo.productIndex";
23 |
24 | private FragmentDemoPresentationModel presentationModel;
25 |
26 | @Override
27 | public void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 |
30 | int productIndex = getArguments().getInt(EXTRA_PRODUCT_INDEX);
31 | Product product = MemoryProductStore.getInstance().getByIndex(productIndex);
32 |
33 | presentationModel = new FragmentDemoPresentationModel(product);
34 | }
35 |
36 | @Override
37 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
38 | ViewBinder viewBinder = createViewBinder();
39 | return viewBinder.inflateAndBindWithoutAttachingToRoot(R.layout.fragment_demo, presentationModel, container);
40 | }
41 |
42 | public static FragmentDemo newInstance(int productIndex) {
43 | Bundle args = new Bundle();
44 | args.putInt(EXTRA_PRODUCT_INDEX, productIndex);
45 | FragmentDemo fragment = new FragmentDemo();
46 | fragment.setArguments(args);
47 | return fragment;
48 | }
49 |
50 | private FragmentDemo() {
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/FragmentTitleTag.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import org.robobinding.ViewBinder;
10 | import org.robobinding.gallery.R;
11 | import org.robobinding.gallery.model.MemoryProductStore;
12 | import org.robobinding.gallery.model.Product;
13 | import org.robobinding.gallery.presentationmodel.FragmentDemoPresentationModel;
14 | import org.robobinding.gallery.presentationmodel.FragmentTitleTagPresentationModel;
15 |
16 | /**
17 | * Created by cheng on 2015/7/26.
18 | */
19 | public class FragmentTitleTag extends AbstractFragment {
20 | private FragmentTitleTagPresentationModel presentationModel;
21 |
22 | @Override
23 | public void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 |
26 | presentationModel = new FragmentTitleTagPresentationModel();
27 | }
28 |
29 | @Override
30 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
31 | ViewBinder viewBinder = createViewBinder();
32 | return viewBinder.inflateAndBind(R.layout.fragment_title_tag, presentationModel);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/GalleryActivity.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import java.util.Map;
4 |
5 | import org.robobinding.gallery.R;
6 | import org.robobinding.gallery.presentationmodel.GalleryPresentationModel;
7 |
8 | import android.app.Activity;
9 | import android.os.Bundle;
10 |
11 | import com.google.common.collect.Maps;
12 |
13 | /**
14 | *
15 | * @since 1.0
16 | * @version $Revision: 1.0 $
17 | * @author Cheng Wei
18 | */
19 | public class GalleryActivity extends AbstractActivity {
20 | @Override
21 | public void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 |
24 | Map> demoActivityMappings = Maps.newLinkedHashMap();
25 | demoActivityMappings.put("View", ViewActivity.class);
26 | demoActivityMappings.put("EditText", EditTextActivity.class);
27 | demoActivityMappings.put("AdapterView", AdapterViewActivity.class);
28 | demoActivityMappings.put("ListView", ListViewActivity.class);
29 | demoActivityMappings.put("RecyclerView", RecyclerViewActivity.class);
30 | demoActivityMappings.put("Custom Component", CustomComponentActivity.class);
31 | demoActivityMappings.put("TypedCursor", TypedCursorActivity.class);
32 | demoActivityMappings.put("Fragment & ViewPager", ListFragmentDemoActivity.class);
33 | demoActivityMappings.put("Options Menu", OptionsMenuActivity.class);
34 | demoActivityMappings.put("Context Menu", ContextMenuDemoActivity.class);
35 | demoActivityMappings.put("Contextual Action Mode", ContextualActionModeActivity.class);
36 |
37 | GalleryPresentationModel presentationModel = new GalleryPresentationModel(this, demoActivityMappings);
38 | initializeContentView(R.layout.activity_gallery, presentationModel);
39 | }
40 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/GalleryApp.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.binder.BinderFactory;
4 | import org.robobinding.binder.BinderFactoryBuilder;
5 | import org.robobinding.customviewbinding.CustomViewBinding;
6 | import org.robobinding.gallery.model.customcomponent.TitleDescriptionBar;
7 | import org.robobinding.gallery.model.customcomponent.TitleDescriptionBarBinding;
8 | import org.robobinding.gallery.model.typedcursor.DatabaseHelper;
9 | import org.robobinding.supportwidget.recyclerview.RecyclerViewBinding;
10 | import org.robobinding.widget.menuitemgroup.MenuItemGroup;
11 |
12 | import android.app.Application;
13 | import android.support.v7.widget.RecyclerView;
14 | import android.view.MenuItem;
15 | import android.view.View;
16 | import android.widget.TextView;
17 |
18 | /**
19 | *
20 | * @since 1.0
21 | * @version $Revision: 1.0 $
22 | * @author Cheng Wei
23 | */
24 | public class GalleryApp extends Application {
25 | private BinderFactory reusableBinderFactory;
26 | private DatabaseHelper databaseHelper;
27 |
28 | @Override
29 | public void onCreate() {
30 | super.onCreate();
31 |
32 | databaseHelper = new DatabaseHelper(this);
33 | reusableBinderFactory = new BinderFactoryBuilder()
34 | .add(new ViewBindingForView().extend(View.class))
35 | .add(new MenuItemBinding().extend(MenuItem.class))
36 | .add(new MenuItemGroupBinding().forView(MenuItemGroup.class))
37 | .add(CustomViewBinding.forView(RecyclerView.class, new RecyclerViewBinding()))
38 | .build();
39 | }
40 |
41 | public BinderFactory getReusableBinderFactory() {
42 | return reusableBinderFactory;
43 | }
44 |
45 | public DatabaseHelper getDatabaseHelper() {
46 | return databaseHelper;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/ListFragmentDemo.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.ViewBinder;
4 | import org.robobinding.gallery.R;
5 | import org.robobinding.gallery.model.MemoryProductStore;
6 | import org.robobinding.gallery.presentationmodel.ListFragmentDemoPresentationModel;
7 |
8 | import android.os.Bundle;
9 | import android.support.annotation.Nullable;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | /**
15 | *
16 | * @since 1.0
17 | * @version $Revision: 1.0 $
18 | * @author Cheng Wei
19 | */
20 | public class ListFragmentDemo extends AbstractFragment {
21 | private ListFragmentDemoPresentationModel presentationModel;
22 |
23 | @Override
24 | public void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 |
27 | MemoryProductStore productStore = MemoryProductStore.getInstance();
28 | productStore.reset();
29 | presentationModel = new ListFragmentDemoPresentationModel(getActivity(), productStore.getAll());
30 | }
31 |
32 | @Override
33 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
34 | ViewBinder viewBinder = createViewBinder();
35 | return viewBinder.inflateAndBindWithoutAttachingToRoot(R.layout.fragment_list_demo, presentationModel, container);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/ListFragmentDemoActivity.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import android.support.v4.app.Fragment;
4 |
5 | /**
6 | *
7 | * @since 1.0
8 | * @version $Revision: 1.0 $
9 | * @author Cheng Wei
10 | */
11 | public class ListFragmentDemoActivity extends AbstractFragmentActivity {
12 | @Override
13 | protected Fragment createFragment() {
14 | return new ListFragmentDemo();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/ListViewActivity.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import org.robobinding.gallery.R;
4 | import org.robobinding.gallery.presentationmodel.ListViewPresentationModel;
5 |
6 | import android.os.Bundle;
7 |
8 | /**
9 | *
10 | * @since 1.0
11 | * @version $Revision: 1.0 $
12 | * @author Cheng Wei
13 | */
14 | public class ListViewActivity extends AbstractActivity {
15 | private ListViewPresentationModel presentationModel;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 |
21 | presentationModel = new ListViewPresentationModel();
22 | initializeContentView(R.layout.activity_list_view, presentationModel);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/org/robobinding/gallery/activity/MenuItemBinding.java:
--------------------------------------------------------------------------------
1 | package org.robobinding.gallery.activity;
2 |
3 | import android.view.MenuItem;
4 | import android.widget.TextView;
5 |
6 | import org.robobinding.annotation.ViewBinding;
7 | import org.robobinding.customviewbinding.CustomViewBinding;
8 |
9 | /**
10 | *
11 | * @since 1.0
12 | * @version $Revision: 1.0 $
13 | * @author Cheng Wei
14 | */
15 | @ViewBinding(simpleOneWayProperties = {"enabled", "visible"})
16 | public class MenuItemBinding extends CustomViewBinding