Git Product home page Git Product logo

Comments (12)

blipinsk avatar blipinsk commented on June 8, 2024

Which pages do you want to restrict access to?

blipinsk_flippablestackview__an_android_library_introducing_a_stack_of_views_with_the_first_item_being_flippable_

from flippablestackview.

KaushikNathMIT avatar KaushikNathMIT commented on June 8, 2024

The pages should be available.
The user should not be able to swipe away a particular page to access the next page.
Changing of pages is done programmatically.

from flippablestackview.

blipinsk avatar blipinsk commented on June 8, 2024

Ok, so if changing of pages is done only programmatically, then the only thing you need to do is to disable touch in the FlippableStackView (hint: it's just a ViewPager). You can do that for example by extending FlippableStackView and applying the mechanisms from here.

from flippablestackview.

KaushikNathMIT avatar KaushikNathMIT commented on June 8, 2024

I have tried to use the setOnTouchListener()

flippableStackView.initStack(4, StackPageTransformer.Orientation.HORIZONTAL);
myadapter = new CustomAdapter(questionArray, posPointArray, negPointArray,   getSupportFragmentManager(), viewPagerFragments);
flippableStackView.setAdapter(myadapter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        flippableStackView.setCurrentItem(0);
 }
 flippableStackView.setOnTouchListener(new View.OnTouchListener() {
     @Override
     public boolean onTouch(View view, MotionEvent motionEvent) {
         return true;
     }
});`

But it doesnot seem to work. I can still swap from one page to another.

from flippablestackview.

blipinsk avatar blipinsk commented on June 8, 2024

Use the one approach I sent you in the link (you will have to extend the FlippableStackView).

from flippablestackview.

KaushikNathMIT avatar KaushikNathMIT commented on June 8, 2024

I fixed it by using this line before returning true from the onTouch() function flippableStackView.setCurrentItem(flippableStackView.getCurrentItem());

from flippablestackview.

blipinsk avatar blipinsk commented on June 8, 2024

That's interesting that you used the least reliable of the approaches from the StackOverflow thread (look at the first comment under the answer), and you used a random "solution" to make it barely work, instead of just going with a simple, elegant and solid solution (the one I pointed you to). Out of curiosity: why didn't you try the other approach?

from flippablestackview.

KaushikNathMIT avatar KaushikNathMIT commented on June 8, 2024

I couldn't use the better solution, because I can't extend the
FlippableStackView class. I am already extending the AppCompatActivity
class.
I actually have no idea how can I implement the way as u have mentioned.

On Fri 23 Sep, 2016, 7:29 PM Bartek Lipinski, [email protected]
wrote:

That's interesting that you used the least reliable of the approaches from
the StackOverflow thread (look at the first comment under the answer
http://stackoverflow.com/a/13392198/1993204), and you used a random
"solution" to make it barely work, instead of just going with a simple,
elegant and solid solution (the one I pointed you to). Out of curiosity:
why didn't you try the other approach?


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
#24 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AO7EUe8g2Z9_XCel_hWlp5QlCFcZCfshks5qs9s7gaJpZM4KEyHF
.

from flippablestackview.

blipinsk avatar blipinsk commented on June 8, 2024

You should've just said that you're not sure how to extend a FlippableStackView class, I'd be happy to help you with that. Just create another class in your package, name it e.g. DisableableFlippableStackView and use the following code as it's contents:

public class DisableableFlippableStackView extends FlippableStackView {

    private boolean pagingEnabled;

    public DisableableFlippableStackView(Context context) {
        super(context);
        setupView();
    }

    public DisableableFlippableStackView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setupView();
    }

    private void setupView() {
        this.pagingEnabled = true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (this.pagingEnabled) {
            return super.onTouchEvent(event);
        }

        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (this.pagingEnabled) {
            return super.onInterceptTouchEvent(event);
        }

        return false;
    }

    public void setPagingEnabled(boolean enabled) {
        this.pagingEnabled = enabled;
    }
}

And use DisableableFlippableStackView instead of FlippableStackView in your layout xml.

from flippablestackview.

KaushikNathMIT avatar KaushikNathMIT commented on June 8, 2024

Thank you so much
It worked!!!!

from flippablestackview.

blipinsk avatar blipinsk commented on June 8, 2024

👍

from flippablestackview.

fenggit avatar fenggit commented on June 8, 2024

👍

I need your help,How to dynamically set the page only up or down?Thank you

from flippablestackview.

Related Issues (20)

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.