Vitamin Saber

Additional

Language
Java
Version
N/A
Created
Mar 19, 2015
Updated
Jun 22, 2015 (Retired)
Owner
w2ji
Contributors
Stéphane Nicolas (stephanenicolas)
w2ji
2
Activity
Badge
Generate
Download
Source code

Blurb

Vitamin Saber

Vitamin Saber provides resource injection for Android (@InjectResource(resId)). It is annotation processor based and will provide all the speed you need on Android by avoiding reflection.

The code was originally a fork of the Extra dependency library Dart.

Usages

Injecting into activity or fragment:

class ExampleActivity extends Activity {
  @InjectResource(R.string.hello) String str1;
  @InjectResource(R.color.red) int color;

  @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simple_activity);
    VitaminSaber.inject(this);
  }
}

Injecting into object class:

public class SampleObject {
    @InjectResource (R.string.app_name) public String appName;

    public SampleObject (Context context){
        VitaminSaber.inject(context, this);
    }
}

Supported Resource Types

    anim,
    animator,
    array,
    attr, <- Not supported
    bool,
    color,
    dimen,
    drawable,
    fraction, <- Not supported
    integer,
    interpolator, <- Not supported
    layout,
    menu, <- Not supported
    mipmap, <- Not supported
    plurals, <- Not supported
    raw, <- Not supported
    string,
    style, <- Not supported
    xml

Gradle Dependency

Add the following lines to your gradle dependency

compile "com.w2ji.vitaminsaber:vitaminsaber:1.0.2"