AndroidImageSlider icon indicating copy to clipboard operation
AndroidImageSlider copied to clipboard

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

Open deimian86 opened this issue 9 years ago • 17 comments

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.

deimian86 avatar Mar 19 '15 16:03 deimian86

I also think that this is a must have feature.

Keep up the great work!

gloushkov avatar Mar 19 '15 20:03 gloushkov

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.

deimian86 avatar Mar 20 '15 09:03 deimian86

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.

jschleppy avatar May 05 '15 20:05 jschleppy

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) {

                    }
                });
            }

felipe-silvestre-morais avatar Jun 17 '15 20:06 felipe-silvestre-morais

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

confile avatar Sep 02 '15 16:09 confile

+1 please provide this feature!

steffimueller avatar Sep 02 '15 16:09 steffimueller

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

romangromov avatar Oct 27 '15 09:10 romangromov

Is there any workaround for that?

confile avatar Oct 27 '15 16:10 confile

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 avatar Nov 06 '15 06:11 dgngulcan

I donnot want it cycle,just one-way

whoyouni avatar Mar 07 '16 12:03 whoyouni

@dgngulcan Thanks! Its works!

gmikhail avatar May 03 '16 15:05 gmikhail

+1 definitely a must have feature!

sgzsh269 avatar May 27 '16 01:05 sgzsh269

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

jemsnaban avatar Aug 31 '16 07:08 jemsnaban

@dgngulcan Thanks a lot for this.

ashishg656 avatar Apr 21 '17 19:04 ashishg656

Thanks @dgngulcan

Joe-Mobarak avatar Dec 06 '17 16:12 Joe-Mobarak

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 avatar Jul 03 '19 06:07 aruns2896

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

aruns2896 avatar Jul 03 '19 06:07 aruns2896