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

Disable slide (not autocycle) when theres only one image? #82

Open
deimian86 opened this issue Mar 19, 2015 · 17 comments
Open

Disable slide (not autocycle) when theres only one image? #82

deimian86 opened this issue Mar 19, 2015 · 17 comments

Comments

@deimian86
Copy link

How can I stop (and restart) the swipe gestures of a SliderLayout? I've got dinamic scenarios where I use a SliderLayout with only one image and sometimes with multiple images, or multiple images could be added dinamically.

When theres only one image I put the visibility of the indicators to View.GONE but I can still swipping the image. Is there a way to stop the swipe?

Thanks a lot for this amazing library and your work.

@gloushkov
Copy link

I also think that this is a must have feature.

Keep up the great work!

@deimian86
Copy link
Author

I overlap an ImageView with the first image over the Slider and change visibility when I receive the rest of the images, but it's only a patch.

@jschleppy
Copy link

This, and the fact that simply removing and adding slides dynamically makes it freak out and slide around a bunch on initializing is why I must ditch the use of this plugin. Great otherwise, look forward to this request being fulfilled.

zhouqiangWang added a commit to zhouqiangWang/AndroidImageSlider that referenced this issue May 6, 2015
zhouqiangWang added a commit to zhouqiangWang/AndroidImageSlider that referenced this issue May 8, 2015


2. Modify PagerIndicator show wrong numbers of indicators when call removeSliderAt
3. modify ViewPager scroll logic when SliderAdapter data change.  avoid slide around a bunch on initializing after removing or adding slides dynamically
zhouqiangWang added a commit to zhouqiangWang/AndroidImageSlider that referenced this issue May 17, 2015
1. When removing slider, there will be a white blank area
2. When there is only one image, it will still able to scroll.
@felipe-silvestre-morais

I'm waiting for this feature too.
For while I did a workaround:

I created a ghost view in my layout

<FrameLayout
    android:id="@+id/container_layout"
    android:background="@color/gray_hard_text"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <LinearLayout
                android:id="@+id/my_tickets_header"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/gray_hint">

            <com.daimajia.slider.library.SliderLayout
                android:id="@+id/adp_my_tickets_banner_slider"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>

    <FrameLayout
        android:id="@+id/ghost_view_workaround"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone">

    </FrameLayout>

</FrameLayout>

In code, I check if my list has one element, if yes, I set the visibility to VISIBLE and set a listener to onclick

if (purchase.getOrder().getTickets().size() < 2) {
                viewHolder.findViewById(R.id.ghost_view_workaround).setVisibility(View.VISIBLE);
                viewHolder.findViewById(R.id.ghost_view_workaround).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                });
            }

@confile
Copy link

confile commented Sep 2, 2015

@daimajia It would be great if you could implement this feature. Thanks! Great work.

@steffimueller
Copy link

+1 please provide this feature!

@romangromov
Copy link

Why this is not yet supported? That's a pity..

@confile
Copy link

confile commented Oct 27, 2015

Is there any workaround for that?

@dgngulcan
Copy link

I've found a workaround I guess, this makes it unable to swipe but not sure if it will be stable :)

if (imageCount < 2) {
            sliderShow.stopAutoCycle();
            sliderShow.setPagerTransformer(false, new BaseTransformer() {
                @Override
                protected void onTransform(View view, float v) {
                }
            });
           //TODO: disable indicator
}

@whoyouni
Copy link

whoyouni commented Mar 7, 2016

I donnot want it cycle,just one-way

@gmikhail
Copy link

gmikhail commented May 3, 2016

@dgngulcan Thanks! Its works!

@sgzsh269
Copy link

sgzsh269 commented May 27, 2016

+1 definitely a must have feature!

@jemsnaban
Copy link

how to make it one way slider, it will stuck on last item and not cycling to the first item. thank you

@ashishg656
Copy link

@dgngulcan Thanks a lot for this.

@Joe-Mobarak
Copy link

Thanks @dgngulcan

@aruns2896
Copy link

I've found a workaround I guess, this makes it unable to swipe but not sure if it will be stable :)

if (imageCount < 2) {
            sliderShow.stopAutoCycle();
            sliderShow.setPagerTransformer(false, new BaseTransformer() {
                @Override
                protected void onTransform(View view, float v) {
                }
            });
           //TODO: disable indicator
}

@dgngulcan But it's affecting the other images when we using it with recycler views that is because the recycler view inflating the views in which the transformation has been done.

@aruns2896
Copy link

@dgngulcan Can you have any solution for that using in recycler view???
Eagerly waiting for reply.............

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

No branches or pull requests