Skip to content

Repository files navigation

Plot

Field binding for Android bundle. Eliminate bundle.get & bundle.put calls by using Plot.unpack(this, bundle) & Plot.pack(this) in Android lifecycle with annotation @PlotBundle on field.

Example

pack

publicclassMainActivityextendsAppCompatActivityimplementsView.OnClickListener {
@PlotBundle(key = Constant.KEYS.PLOT_INT)
IntegerplotInt = 1;
@PlotBundle(key = Constant.KEYS.PLOT_DOUBLE)
doubleplotDouble = 2;
@OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextViewplotIntText = (TextView) findViewById(R.id.plot_int);
TextViewplotDoubleText = (TextView) findViewById(R.id.plot_double);
plotIntText.setText("" + plotInt);
plotDoubleText.setText("" + plotDouble);
Buttonnext = (Button) findViewById(R.id.next);
next.setOnClickListener(this);
}
@OverridepublicvoidonClick(Viewv) {
Intentintent = newIntent(getBaseContext(), DetailActivity.class);
Bundlebundle = Plot.pack(this);
intent.putExtras(bundle);
startActivity(intent);
}
}

unpack

publicclassDetailActivityextendsAppCompatActivity {
@PlotBundle(key = Constant.KEYS.PLOT_INT)
intplotInt;
@PlotBundle(key = Constant.KEYS.PLOT_DOUBLE)
doubleplotDouble;
@OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
Plot.unpack(this, getIntent().getExtras());
TextViewplotIntText = (TextView) findViewById(R.id.plot_int);
TextViewplotDoubleText = (TextView) findViewById(R.id.plot_double);
plotIntText.setText("" + plotInt);
plotDoubleText.setText("" + plotDouble);
}
}

Support

  • Native type & object
  • Array, List, & Array List
  • Map & Hash Map
  • Parcelable & Parceler from this library

Download

Configure your project-level build.gradle to include the 'android-apt' plugin:

repositories {
maven {
url 'https://dl.bintray.com/adef145/maven/'
}
}
...
dependencies {
compile 'com.adefruandta.plot:plot:0.1.0'
}

About

Bind Android bundle to fields.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages