Git Product home page Git Product logo

why-not-image-carousel's Introduction

Hi there ๐Ÿ‘‹

Assalamu Aalaikum, Peace to You!

I'm a Learner, App Developer, Blogger, Coder, and Linux ๐Ÿง Lover.

Currently working in Android/Kotlin with Jetpack Compose โšก and iOS with SwiftUI ๐Ÿš€

GitHub User's stars Stack Overflow reputation LinkedIn Twitter Follow

ImaginativeShohag's Stats

ImaginativeShohag's Streak

ImaginativeShohag's Top Languages

Check out ImaginativeShohag's profile on stardev.io

๐Ÿ˜Ž Notable Repositories:

  • Oops! No Internet! - A simple no Internet dialog and snackbar, which will automatically appear and disappear based on Internet connectivity status.
  • Why Not! Image Carousel! - An easy, super simple and customizable image carousel view for Android.
  • Simple MVVM - A simple Android MVVM pattern example and template.
  • Why Not Compose! - A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!
  • Why Not SwiftUI! - A collection of Swift, SwiftUI and iOS goodies.

why-not-image-carousel's People

Contributors

alvarosanzrodrigo avatar fin1te avatar imaginativeshohag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

why-not-image-carousel's Issues

Change indicator color/tint

Please add an attribute to change indicator color. I have tried foregroundTint an backgroundTint but it's not changing the color.

Loop slider no supported

Hi there , first i'm sorry for my bad English!
i'm using this library and it is good , but LOOP slide is not supported. can you make this possible please?
i want like this:
img1 > img2 > img3 > img4 > img1 > img2 ...

Images not loading with ViewBinding

Images are not loading when trying to find the carousel with viewBinding, example

class MainActivity : AppCompatActivity() {

    val listaImagenes = mutableListOf<CarouselItem>()
    private lateinit var binding:ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        binding = ActivityMainBinding.inflate(layoutInflater)
        listaImagenes.add(CarouselItem(imageUrl = "https://imgcla.lavoz.com.ar/files/imagecache/ficha_aviso_mobile_462_253/avisos/aviso_auto/aviso-auto-ford-ka-7528636.jpg"))
        binding.carousel.addData(listaImagenes)
    }
}

Output

Screen Shot 2021-03-13 at 5 01 22 PM

Could not find implmention(build.gradle)

Hi ,I've just seen this amazing library,but I've encountered problems when importing it.
Could not find org.imaginativeworld.whynotimagecarousel:whynotimagecarousel:1.2.1. Required by: project :app

Anything I'm doing wrong?

Crash on empty data source

When calling .setData(list) with empty list - for example when users update pictures in the gallery - library crashes with the following error.

Originally when Carousel started empty - it shows empty picture as expected, when later setiing some pictures and set it again with empty list following error is thrown.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: fit.jeem.stage, PID: 15814
    java.lang.ArithmeticException: divide by zero
        at org.imaginativeworld.whynotimagecarousel.adapter.InfiniteCarouselAdapter.getRealDataPosition(InfiniteCarouselAdapter.kt:38)
        at org.imaginativeworld.whynotimagecarousel.ImageCarousel$initListeners$1.onScrolled(ImageCarousel.kt:819)
        at androidx.recyclerview.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:5347)
        at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:4405)
        at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4031)
        at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4578)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1873)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1873)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1873)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
        at android.view.View.layout(View.java:21912)
        at android.view.ViewGroup.layout(ViewGroup.java:6260)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)

app crashes

Hello Shohag you are very broad hearted . This carousel looks amazing but it crashes while lunching. Is there any mistake I did.

Using currentPosition is changing items infinite

I'm using this after setting data, but it change position fast and keep doing it for all positions like it's working with autoPlay = true.

The carousel is setted like this::
binding.cardListL.carousel.autoPlay = false
binding.cardListL.carousel.infiniteCarousel = true

Captura de Pantalla 2021-12-30 a la(s) 12 41 02

Does not work autoPlay after the slide.

  1. Setup autoPlay = true
  2. Have more than 1 image.

We are waiting for 1 slide auto-scrolling, we move our finger to the next slide, and auto-scrolling does not work anymore. It starts working if you click on the slide.

Wrong position index

I receive Wrong position indexes on onScrollStateChanged !
The values are about the MAX_SIZE of integer (1073741823) !!
I should use position-1073741823 to make it work! (position 0 is OK)

What's the issue?

Image load from drawable

Hello Team,

super job, i like it.

can you please say me, how can i load from drawable, also not from URL?

I try following but not working

  String s1 = "drawable://" + R.drawable.s1;
    String s2 = "drawable://" + R.drawable.s2;

    for (int i = 1; i <= max; i++) {
        if (i % 2 == 0) {
            list.add(
                    new CarouselItem(
                            s1,
                            "Image " + i + " of " + max
                    )
            );
        } else {

.......
..........

thanks

Using carousel in a RecyclerView

Hi, I'm trying to use this awesome library in a RecyclerView. Almost everything is ok but after the RecyclerView item - that contains a carousel in it - gets unbound and then again comes in the view and shows up, the CircleIndicator2 view gets disappeared.
I also got this error: The first view is not found! Maybe the app is in the background. and found out it's because of the infinite scrolling being enabled and turning it off apparently prevents the error but I actually want to use the infinite scrolling feature.
I think these two are related. I don't know if the carousel is ok to be used in the RecyclerView or not but I want to know if there is anyway to solve this problem?

Request to Correct Grammatical Error in Library Documentation

In the documentation for the library, there is a minor grammatical error in the line "The library is now supported infinite carousel." This error can cause confusion for users and negatively impact the overall quality of the documentation. I kindly request a correction to the wording to accurately reflect the functionality of the infinite carousel feature.

c# example for click listener

can you give us an example for this code

// Item click listener
carousel.onItemClickListener = object : OnItemClickListener {
    override fun onClick(position: Int, carouselItem: CarouselItem) {
        // ...
    }

    override fun onLongClick(position: Int, dataObject: CarouselItem) {
        // ...
    }

}

on c#?
thanks

Manifest merger failed

Cool Stuff you got here ,
Why not give it a try?

You see ... I tried adding this inside project's app.gradle

implementation 'me.relex:circleindicator:2.1.4'
    implementation 'com.github.ImaginativeShohag:Why-Not-Image-Carousel:v1.1.0'

And this is the error it produces when added and synced ...

ERROR: Manifest merger failed : uses-sdk:minSdkVersion 19 cannot be smaller than version 21 declared in library [com.github.ImaginativeShohag:Why-Not-Image-Carousel:v1.1.0] C:\Users\<CurrentUser>\.gradle\caches\transforms-2\files-2.1\a29be6796303cd41d21e68d8a6dd501a\Why-Not-Image-Carousel-v1.1.0\AndroidManifest.xml as the library might be using APIs not available in 19
	Suggestion: use a compatible library with a minSdk of at most 19,
		or increase this project's minSdk version to at least 21,
		or use tools:overrideLibrary="org.imaginativeworld.whynotimagecarousel" to force usage (may lead to runtime failures)

What could possibly be the issue? Should I use tools:overrideLibrary="org.imaginativeworld.whynotimagecarousel"

PS: I have already migrated to Android X

Can we use lib using AppCompat as Base Theme

Hello ... Thanks a lot for awesom lib. I have checked several lib but this one is supperb.

I'm using this library it works fine then I found that if we used @style/Theme.AppCompat.Light.NoActionBar then it gives error #15 but if we used @style/Theme.MaterialComponents.Light.NoActionBar then we can resolved the issue.

In my case I have several dependency on my project for AppCompat Theme. I tried to change it to MaterialComponents but it break by app design (mostly happen on InputTextLayout).

Can we used this library by using AppCompat Theme. If there any work arround I would love to do it, any how I want to use this lib in my project.

Please let me know about it.

Thanks

Setting "infiniteCarousel" programmatically should reinitialize the adapter

Hello,

I noticed there is a problem while loading photos that are dynamically changing and when the photo list may contain only one item. So, for example, when the photos are pulled from some API.

Consider such a case:
When the photo list contains only one item, you programmatically change the "infiniteCarousel" flag to "false", because there is no point in looping one photo infinitely, so the carousel should behave like one static photo.

Otherwise, when the photo list contains more than one item, you set the "infiniteCarousel" flag to "true", because that is the default and desired behavior.

The problem is that changing this flag programmatically does not reinitialize the adapter, thus this change is not noticed by the carousel at all (in terms of displaying photos).
After changing "infiniteCarousel" flag, you need to change another variable (imageScaleType, imagePlaceholder or autoWidthFixing) if you want this change to take place. I mean invoking initAdapter() method.

I think that changing the "infiniteCarousel" flag programmatically should reinitialize the adapter, so the carousel can behave as I described.

Thank you in advance for your feedback and have a great day!

Best regards,
varchar20

[Question] When Position is 0 and left swipe, can i move it to the rear?

[Environment]
Android Target SDK: 30
Why-Not-Image_Carousel version: 2.0.2
Three Carousel items.

When Position is 0 (received from CarouselOnScrollListener), there is a conditions that blocks left swipe performed.
I want to move it to the rear when Position is 0.
Is there any way to fix it?

Getting black spaces in corners

Hi, First of all the library is awesome. I love how easy it is to implement it. As you can see my problem from the attachment. There are weird black spaces that fills up and becomes a sharp edged rectangle. But I wanted rounded corners. Can you please provide me a solution on how to fix this?

Edit: If i use image with rounded corners, it fills the gap with black color as seen in the attachment
if i use image with sharp corners like normal images then the carouel view has straight pointy corners and not the rounded corner style.

I have used the same "Theme.MaterialComponents.Light.NoActionBar" as my app theme.

Please let me know if i need to share any file for reference to fix the issue.

image_corners

Autoplay: Autoplay stop work after recycle in recycleView.

After scroll recycle view autoplay stop to work.

style:

    <item name="autoPlay">true</item>
    <item name="autoPlayDelay">1500</item>
    <item name="carouselType">SHOWCASE</item>
    <item name="scaleOnScroll">true</item>
    <item name="infiniteCarousel">true</item>
    <item name="showBottomShadow">false</item>
    <item name="showCaption">false</item>
    <item name="showIndicator">false</item>
    <item name="showNavigationButtons">false</item>
    <item name="showTopShadow">false</item>
    <item name="touchToPause">true</item>
    <item name="carouselGravity">CENTER</item>
    <item name="scalingFactor">0.25</item>

OnBind

           carousel.registerLifecycle(lifecycle)
           carousel.setData(establishment.listImages) //listImages as CarouselItem

Video example
https://user-images.githubusercontent.com/62159705/212760201-e043c51c-837b-4bd1-afe3-ae27c7d8bde6.mp4

Console error
E/ImageCarousel: The first view is not found! Maybe the app is in the background.

InvocationTargetException crashes

Crashes on open with InvocationTargetException Error for view
Process: com.team.shareware, PID: 29716

android.view.InflateException: Binary XML file line #57 in com.team.shareware:layout/product_card_layout: Binary XML file line #57 in com.team.shareware:layout/product_card_layout: Error inflating class org.imaginativeworld.whynotimagecarousel.ImageCarousel
Caused by: android.view.InflateException: Binary XML file line #57 in com.team.shareware:layout/product_card_layout: Error inflating class org.imaginativeworld.whynotimagecarousel.ImageCarousel
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
    at android.view.LayoutInflater.createView(LayoutInflater.java:858)

Auto play not wokring

Auto play with various numbers of delay didn't work, I was trying on android 10 real device

 carousel.autoPlayDelay = 150
 carousel.autoPlay = true

Autoplay not working properly on RTL layout

If the carouselGravity sets to START it will try to scroll to the next item then go back to the first item immediately.
If the carouselGravity sets to CENTER the distance between items is messed up.

Pause auto sliding when touching image

Hi guys,

thanks Mahmudul Hasan for your simple and awesome image slider,

I want to pause the auto sliding until i release my finger from the slider, there is a way to do this with this lib??

thanks

Url with authentication header

Hi! i need to load images from a URL that needs an authentication heather, its is posible some way? or its it possible to add a custom CarouselAdapter? thanks!

Thumbnails

Hello,

is it possible to view thumbnails of the images?

Thank you

addData() function should be named submitData() or setData()

I've looked at the implementation

ImageCarousel.kt

fun addData(data: List<CarouselItem>) {
        adapter?.apply {
            addAll(data)
            [email protected] = data
            [email protected] = data.size
            initOnScrollStateChange()
        }
    }

CarouselAdapter.kt

fun addAll(dataList: List<CarouselItem>) {
        this.dataList.clear()

        this.dataList.addAll(dataList)
        notifyDataSetChanged()
    }

As you can see that calling addData will not just adding data, but clear all previous data too. It should be called setData, submitData, or maybe replaceData.

Or you can have both, addData and setData.

After reseting new list with setData indicator not showing

Hi
Thanks for the library
When we set data at first time, it correctly shows indicator at first position, but if we reset new data with the same setData method, indicator gets hidden, and shows after manual scrolling

First time
Screen Shot 2021-10-17 at 12 50 42 AM

Second time
Screen Shot 2021-10-17 at 12 50 51 AM

Loading animation

Is there any way to implement loading animation when loading images?

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.