Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation feature #7

Closed
janheinrichmerker opened this issue Feb 21, 2016 · 3 comments
Closed

Validation feature #7

janheinrichmerker opened this issue Feb 21, 2016 · 3 comments
Assignees
Milestone

Comments

@janheinrichmerker
Copy link
Owner

Would be nice to have the ability to block users from getting past a given page based on some sort of policy:

public interface PageContinuePolicy{
    boolean canGoToPage(int oldPosition, int newPosition);
}

That way we could also check for permissions and such. You could also disallow users to go back.

@AkshayChordiya
Copy link

@heinrichreimer Sure, there's a need of such policy. Hoping to see it soon. Thank you.

@Jucedik
Copy link
Contributor

Jucedik commented Mar 15, 2016

Hi.
Please apply my pull request.
I added possibility which allow to lock and unlock next/previous (and swipe left/right) navigation.

Instructions:
1. Create FragmentSlide with build option "allowNext(boolean value)" or "allowPrevious(boolean value)". Warning!!! - Your fragment should be extended from SlideFragment. E.g.:

slides.add(new FragmentSlide.Builder()
                    .background(R.color.color_custom_fragment_1)
                    .backgroundDark(R.color.color_dark_custom_fragment_1)
                    .fragment(LoginFragment.newInstance())
                    **.allowNext(false)**
                    .build());

2. Set NavigationInterface in MaterialIntroActivity by calling
setNavigationInterface(NavigationInterface navigationInterface). E.g.:

setNavigationInterface(new NavigationInterface() {
            @Override
            public boolean onNextClick(int position) {
                return slides.get(position).isAllowSlideNext();
            }

            @Override
            public boolean onPreviousClick(int position) {
                return slides.get(position).isAllowSlidePrevious();
            }

            @Override
            public void onImpossibleToNavigate(int position, int direction) {
                Toast.makeText(getApplicationContext(), R.string.toast_impossible_to_navigate, Toast.LENGTH_LONG).show();
            }
        });

3. For lock or unlock slide page you need to call allowNextSlide() or allowPreviousSlide() from your fragment (e.g.: you may call this methods after successfull user autorization). Also you may call showNextSlide() and showPreviousSlide() for imidiately go to next or previous slide.

You can see the sample code in demo files.

janheinrichmerker added a commit that referenced this issue Mar 21, 2016
Added validation feature (#7)
@janheinrichmerker
Copy link
Owner Author

Fixed by #24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants