daimajia / AndroidImageSlider

An amazing and convenient Android image slider.
MIT License
5.63k stars 1.66k forks source link

Disable swipe when only one image ? #38

Closed floating-cat closed 9 years ago

floating-cat commented 10 years ago

How to disable swipe when only one image , or any workaround?

I know I can use stopAutoCycle to disable auto scrolling, but that's different.

Thanks.

AkshayChordiya commented 10 years ago

I too need it, @floating-cat thanks for creating the issue

kdgr commented 10 years ago

i need similar one. How can i disable swipe when last image ?

daimajia commented 10 years ago

I haven't solve this problem... Please wait some days.

RockerFlower commented 10 years ago

I need too.. Thanks!

B-greg commented 10 years ago

Hi, Yes me too i need the disable the swipe on the first and last image. If we can have this feature everything will be perfect.

Klafe commented 9 years ago

Hi! Is this issue resolved? Thank You!

taliptayfur commented 9 years ago

@Klafe i think this library does not developing anymore

daimajia commented 9 years ago

@Taifuru Noop, still in developing, but just too busy on works.

massimobio commented 9 years ago

This issue is actively being discussed in https://github.com/daimajia/AndroidImageSlider/issues/82

amalkronz commented 6 years ago

try this, it will stop the swiping and auto Cycle in slider, it's work for me if (imageCount < 2) { sliderShow.stopAutoCycle(); sliderShow.setPagerTransformer(false, new BaseTransformer() { @Override protected void onTransform(View view, float v) { } }); //TODO: disable indicator }

imi24 commented 3 years ago

create a boolean variable and setter in SliderLayout.java

private boolean isDisableTouchEvent = true;
public void setDisableTouchEvent(boolean disableTouchEvent) {
    isDisableTouchEvent = disableTouchEvent;
}

and replace onInterceptTouchEvent function with below

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (isDisableTouchEvent)
        return true;
    else {
        int action = ev.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                pauseAutoCycle();
                break;
        }
        return false;
    }
}

after that you can disable swipe with this slider.setDisableTouchEvent(true);