Giter Site home page Giter Site logo

msoftware / wizard Goto Github PK

View Code? Open in Web Editor NEW

This project forked from panavtec/wizard

0.0 2.0 0.0 205 KB

Wizard Encapsulates navigation operations between fragments of an activity using BackStack.

Home Page: http://panavtec.me

License: Apache License 2.0

Java 100.00%

wizard's Introduction

#Android Wizard Android Arsenal Logo

##Importing to your project Add this dependency to your build.gradle file:

NOT PUBLISHED YET
dependencies {
    compile 'me.panavtec.wizard:1.0.0'

##Basic usage

Create a WizardPage for each fragment you need to present, the only mandatory method to override is "createFragment()":

public class WizardPage1 extends WizardPage<Fragment1> {
    @Override public Fragment1 createFragment() {
        return new Fragment1();
    }
}

Create a wizard in your activity in this way:

@Override protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        new Wizard.Builder()
                .activity(this)
                .pageList(new WizardPage[]{
                        new WizardPage1(),
                })
                .build();
...

And call init:

wizard.init();

Now the wizard is initalized, to use navigation just call, "navigatePrevious", "navigateNext" or "returnToFirst". You can get the current fragment by calling "getCurrentFragment"

##Advanced usage

###Animation transitions You can declare animations for entering/exiting fragments when creating Wizard in this way:

new Wizard.Builder()
                .activity(this)
                .containerId(android.R.id.content)
                .enterAnimation(R.anim.card_slide_right_in)
                .exitAnimation(R.anim.card_slide_left_out)
                .popEnterAnimation(R.anim.card_slide_left_in)
                .popExitAnimation(R.anim.card_slide_right_out)
                .pageList(new WizardPage[]{
                        new WizardPage1(),
                        new WizardPage2(),
                        new WizardPage3()
                })
                .build();

This xml animations are uploaded to the sample project.

###Provide a custom container for fragment navigation if you don't set the containerId attribute, Wizard uses android.R.id.content by default but you can personalize a custom container by calling:

new Wizard.Builder()
                .activity(this)
                .containerId(R.id.my_container)
                .pageList(new WizardPage[]{
                        new WizardPage1(),
                })

###Customize ActionBar in navigation In the wizard page you can override method "setupActionBar" to customize your actionbar on each navigated fragment, ex:

@Override public void setupActionBar(ActionBar supportActionBar) {
        super.setupActionBar(supportActionBar);
        supportActionBar.hide();
    }

In this example when the fragment is navigated, the actionbar will be hidden.

###Option menu in Actionbar

If you have a Fragment that uses actionbar option menus, you can override "hasOptionMenu" and return true to invalidate the option menus when navigating.

###Dagger Tips If you are using Dagger in your project I suggest to use Wizard in this way. ActivityModule:

@Provides @Singleton Wizard provideWizard(ActionBarActivity activity,
                                              SampleWizardPage page) {
        return new Wizard.Builder()
                .activity(activity)
                .containerId(android.R.id.content)
                .pageList(new WizardPage[]{
                        page,
                        ...
                })
                .build();
    }
    
    @Provides @Singleton SampleWizardPage provideSampleWizardPage(ActionBarActivity activity) {
        return new SampleWizardPage(activity);
    }

    

Activity:

@Inject Wizard wizard;

@Override protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        wizard.init();
        }

Fragment:

@Inject Wizard wizard;

@Override protected void someOnClickAction() {
        wizard.navigateNext();
        }

wizard's People

Contributors

panavtec avatar srodrigo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.