public class OnboardingFragmentCompat extends Fragment implements OnboardingFragmentInterface
When you use the Component API with the Android Support Library, the OnboardingFragmentCompat
displays important advice for correctly photographing a document.
Note: Your Activity hosting this Fragment must extend the android.support.v7.app.AppCompatActivity
and use an AppCompat Theme.
Include the OnboardingFragmentCompat
into your layout either directly with <fragment>
in your Activity's layout or using the android.support.v4.app.FragmentManager
.
The default way of showing the Onboarding Screen is as an overlay above the camera preview with a semi-transparent background.
By default an empty last page is added to enable the revealing of the camera preview before the Onboarding Screen is dismissed.
If you would like to display a different number of pages, you can use the OnboardingFragmentCompat.createInstance(ArrayList)
or OnboardingFragmentCompat.createInstanceWithoutEmptyLastPage(ArrayList)
factory method and provide a list of OnboardingPage
objects.
If you would like to disable the appending of the empty last page, you can use the OnboardingFragmentCompat.createInstanceWithoutEmptyLastPage(ArrayList)
or the OnboardingFragmentCompat.createInstanceWithoutEmptyLastPage()
factory method.
An OnboardingFragmentListener
instance must be available until the OnboardingFragmentCompat
is attached to an activity. Failing to do so will throw an exception.
The listener instance can be provided either implicitly by making the hosting Activity implement
the OnboardingFragmentListener
interface or explicitly by setting the listener using
OnboardingFragmentCompat.setListener(OnboardingFragmentListener)
.
Your Activity is automatically set as the listener in OnboardingFragmentCompat.onCreate(Bundle)
.
See the OnboardingActivity
for details.
Constructor and Description |
---|
OnboardingFragmentCompat() |
Modifier and Type | Method and Description |
---|---|
static OnboardingFragmentCompat |
createInstance(java.util.ArrayList pages)
Factory method for creating a new instance of the Fragment using the provided list of
onboarding pages.
|
static OnboardingFragmentCompat |
createInstanceWithoutEmptyLastPage()
Factory method for creating a new instance of the Fragment without appending an empty page to
the default pages.
|
static OnboardingFragmentCompat |
createInstanceWithoutEmptyLastPage(java.util.ArrayList pages)
Factory method for creating a new instance of the Fragment using the provided list of
onboarding pages.
|
PagerAdapter |
getViewPagerAdapter(java.util.List pages) |
void |
setListener(OnboardingFragmentListener listener)
Set a listener for onboarding events.
|
void |
showAlertDialog(java.lang.String message,
java.lang.String positiveButtonTitle,
DialogInterface.OnClickListener positiveButtonClickListener,
java.lang.String negativeButtonTitle,
DialogInterface.OnClickListener negativeButtonClickListener,
DialogInterface.OnCancelListener cancelListener) |
public static OnboardingFragmentCompat createInstanceWithoutEmptyLastPage(java.util.ArrayList pages)
Factory method for creating a new instance of the Fragment using the provided list of onboarding pages.
This method prevents the appending of an empty page to your pages.
If you don't need a custom number of pages and wish to use the default behaviour, you can use
the default constructor of OnboardingFragmentCompat
.
pages
- the pages to be shownpublic static OnboardingFragmentCompat createInstance(java.util.ArrayList pages)
Factory method for creating a new instance of the Fragment using the provided list of onboarding pages.
If you would like to prevent the appending of an empty page, you can use the OnboardingFragmentCompat.createInstanceWithoutEmptyLastPage(ArrayList)
factory method.
If you don't need a custom number of pages and wish to use the default behaviour, you can use
the default constructor of OnboardingFragmentCompat
.
pages
- the pages to be shownpublic static OnboardingFragmentCompat createInstanceWithoutEmptyLastPage()
Factory method for creating a new instance of the Fragment without appending an empty page to the default pages.
If you wish to use the default behaviour, you can use the default constructor of OnboardingFragmentCompat
.
public PagerAdapter getViewPagerAdapter(java.util.List pages)
public void setListener(OnboardingFragmentListener listener)
OnboardingFragmentInterface
Set a listener for onboarding events.
By default the hosting Activity is expected to implement
the OnboardingFragmentListener
. In case that is not feasible you may set the
listener using this method.
Note: the listener is expected to be available until the fragment is attached to an activity. Make sure to set the listener before that.
setListener
in interface OnboardingFragmentInterface
listener
- OnboardingFragmentListener
instancepublic void showAlertDialog(java.lang.String message, java.lang.String positiveButtonTitle, DialogInterface.OnClickListener positiveButtonClickListener, java.lang.String negativeButtonTitle, DialogInterface.OnClickListener negativeButtonClickListener, DialogInterface.OnCancelListener cancelListener)