Skip to content
Ruben Gees edited this page Sep 17, 2015 · 3 revisions

Specific implementation details for an Option

Option example

Option(String title) / Option(int titleResource)

Constructs an Option with the specified title.

Option(String title, boolean isActivated) / Option(int titleResource, boolean isActivated)

Constructs an Option with the specified title and the specified activation state. If isActivated is true, the Checkbox will be checked, once the user navigates to the Slide with this Option.

init(Context context, int position)

A method which is used internally to resolve resources. Don't call this method yourself.

Example

Build an Option like this:

Option option = new Option("Enable Feature A", true);

Then add it to a Slide:

Slide slide = new Slide().withTitle("Feature A").withOption(option)
                         .withImage(R.drawable.image_feature_a).withColor(R.color.yellow);

In this example, we assume the created Slide is the second one which results in the index 1.

The next step is to read the users choices once he finished the intro. You need to do so following:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == IntroductionBuilder.INTRODUCTION_REQUEST_CODE &&
            resultCode == RESULT_OK) {

        for (Option option : data.<Option>getParcelableArrayListExtra(IntroductionActivity.
                OPTION_RESULT)) {
            if(option.getPosition() == 1){
                if(option.isActivated()){
                    //Enable Feature A.
                }else{
                    //Disable Feature A.
                }
            }else{
                //Handle other Options.
            }
        }
    }else{
        //Disable Feature A.
        //Handle other request codes.
    }
}