Android Wizard


Source link: https://github.com/PaNaVTEC/Wizard

#Android Wizard

##Sample app

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

dependencies {

  compile 'me.panavtec:wizard:1.2' 
}

##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);

wizard = new Wizard.Builder(this, 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(this, new WizardPage1(), new WizardPage2(), new WizardPage3())

.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)

.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(this, new WizardPage1())

.containerId(R.id.my_container)

###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.

###Blocking Fragment

Do you need to block the back navigation of your wizard in determinate steps? It's so easy, just override "allowsBackNavigation" in your WizardPage and add this in your activity:

@Override public void onBackPressed() {

  if (wizard.onBackPressed()) {

super.onBackPressed();

  
}
 
}

###Listeners You can declare listeners for page changed and for wizard finished events:

WizardPage[] wizardPages = {
 new WizardPage1(), new WizardPage2(), new WizardPage3() 
}
; new Wizard.Builder(this, wizardPages)

.containerId(android.R.id.content)

.pageListener(new WizardPageListener() {

 @Override

 public void onPageChanged(int currentPageIndex, WizardPage page) {

  //Your code for page changed

 
}

}
)

.wizardListener(new WizardListener() {

 @Override

 public void onWizardFinished() {

  //Your code for wizard finished

 
}

}
)

.build();

###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, page)

 .containerId(android.R.id.content)

 .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();
 
}

Developed by

Christian Panadero Martinez - http://panavtec.me - @PaNaVTEC

License

Copyright 2015 Christian Panadero Martinez  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

AutoCompleteTextView for android with KMP algorithm.

A component to make shaped ImageViews.

A custom indicator for ViewPager.

A custom wavy line view for android.

Simplest library to implement rest client APIs using okhttp3 in your app.

Library that enables TextView of ImageView to show loading animation while waiting for the text and image get loaded.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes