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

Current count of the page in TextSlider? #17

Closed
Chirag-Galani opened this issue Jul 4, 2014 · 28 comments
Closed

Current count of the page in TextSlider? #17

Chirag-Galani opened this issue Jul 4, 2014 · 28 comments

Comments

@Chirag-Galani
Copy link

I am loading all images using Picasso into TextSlider. I want to set wallpaper using onSliderClick(BaseSliderView slider) method. But, there is no such method.
I am storing all the URLs in an array. So, i need the current position so that I can pass it in array and save the particular image.

@Chirag-Galani Chirag-Galani changed the title How to get the current count of the image? Current count of the image in TextSlider? Jul 4, 2014
@Chirag-Galani Chirag-Galani changed the title Current count of the image in TextSlider? Current count of the page in TextSlider? Jul 4, 2014
@Chirag-Galani
Copy link
Author

I managed to solve the issue by using the below workaround:
mDemoSlider2.getCurrentSlider().getUrl()
I get the URL directly instead of the array count.
If possible could you code a method that will return the current page count?
Thanks for the library.

@daimajia
Copy link
Owner

daimajia commented Jul 5, 2014

Ok, thanks your advise, I'll add some new method today. :-D
btw, welcome to contribute your code.

@daimajia
Copy link
Owner

daimajia commented Jul 5, 2014

Hi, bro. I think you can use this method:

textSliderView.setOnSliderClickListener(new BaseSliderView.OnSliderClickListener() {
                @Override
                public void onSliderClick(BaseSliderView slider) {

                }
            })

And I added a new method getCurrentSlider.

@Chirag-Galani
Copy link
Author

Thanks for the new method. I'll look into its code and implementation. But, the code u mentioned wouldn't work for me as i plan to save the current slide's image via options in menu. If i implement that code, only the last picture is selected each time. As the text slider object which i pass from the method points only to the last image.

@daimajia
Copy link
Owner

daimajia commented Jul 6, 2014

Oh, I think I get your point.

@Chirag-Galani
Copy link
Author

Yeah. Thanks for that.
And now , i tried implementing setCurrentPosition() via the below code in SlideLayout with reference to ViewPagerEx. This method when called hangs the app for 15 seconds. Also, Sometimes crashes.
But, it does the job after a delay of more than 15-20 seconds and it doesn't load the picture from URL via Picasso at that Instance. If I move to next image and come back the image appears.
Hoping for a solution.
Thanks.

public void setCurrentPosition(int position,boolean smoothScroll) {

    if(getRealAdapter() == null)
        throw new IllegalStateException("You did not set a slider adapter");
    mViewPager.setCurrentItem(position,smoothScroll);

}

@daimajia
Copy link
Owner

daimajia commented Jul 6, 2014

The code you provided seems have some small bugs..
I'll check tomorrow and add setCurrenPosition method . Thanks.

@Chirag-Galani
Copy link
Author

Ok Thanks mate
I had some query, why are pauseAutoCycle() and RecoverAutoCycle() private methods?
The pauseAutoCycle() method can be used to pause the cycle if another activity opens upon it. If pause is not used then the cycle continues to move on infinitely in background. Thus, loosing the original image which was loaded behind the over-ridding activity.
As a temporary workaround we can use getCurrentPosition() method before opening another activity via menu OnClickListener and store it as an integer. And, later we can use setCurrentPosition() to jump to the particular slide. Though, it will be a comparatively expensive operation in terms of resources due to Infinite AutoCycle.

This below code if you find bug-free can be placed in SliderLayout.java for getting the current state of the AutoCycle. It will help in changing the text from "Start AutoCycle" to "Stop AutoCycle" dynamically as per the result in the Menu .

    public boolean getAutoCycleState() {

           return mCycling;

    } 

Thank you for this awesome library. I have messaged you on hangouts. If you don't mind we can interact there also. :)

@Chirag-Galani
Copy link
Author

Is it possible that the Cycle stops after loosing Focus and starts again after user returns to the TextSlider? I tried below code but it didn't work

mDemoSlider.setOnFocusChangeListener(new OnFocusChangeListener() {  

    public void onFocusChange(View v, boolean hasFocus) {
        if(!hasFocus)
       {
            mDemoSlider.stopAutoCycle();  
                //  mDemoSlider.pauseAutoCycle();
       }
      else  if(hasFocus)
       {
            mDemoSlider.startAutoCycle();  
                //  mDemoSlider.RecoverAutoCycle();   
       }
    }
});

I used both the commented and the original methods after changing the access specifiers to public in SliderLayout but it didn't work. Hope you find a solution to this.
Thanks.

@daimajia
Copy link
Owner

daimajia commented Jul 7, 2014

You can use these two methods startAutoCycle, stopAutoCycle instead of pauseAutoCycle and recoverAutoCycle.
pauseAutoCycle is used when user touch the slider, slider should be paused.
recoverAutoCycle is used to recover cycle when user finger leaves, it will wait 6 seconds to recover the cycle.

@daimajia
Copy link
Owner

daimajia commented Jul 7, 2014

I also noticed that the slider will continue to move even it's in background....
but
I don't have any good methods to handle it....

@Chirag-Galani
Copy link
Author

Ok mate no issues. Even, I am trying to find a workaround for the same.
Now, can you add getAutoCycleState() and setCurrentPosition() methods in the library with reference to the below links (previous comments). They might be buggy.

getAutoCycleState():- #17 (comment)
setCurrentPosition(): #17 (comment)

Thanks for this library and continuous support. 👍

@daimajia
Copy link
Owner

daimajia commented Jul 9, 2014

Ok, I'll add these two methods today. :-D
Thanks your support too.

@daimajia
Copy link
Owner

daimajia commented Jul 9, 2014

Hi buddy.
I spent whole afternoon to add these methods, while, I found that setCurrentItem is buggy... there is some weird behaviors.. I may spend more time on it.

@daimajia
Copy link
Owner

daimajia commented Jul 9, 2014

So, before i solve this problem, i will not add these two method to release version considering the bugs.

@nitin84india
Copy link

Hi, did you get a chance to work on the setCurrentPosition method. It get stuck for atleast 20 seconds when called.

@RichardHan
Copy link
Contributor

Hi all ,
I'm looking for setCurrentPosition function too.
Any tips or suggestions, would be grateful. :)

@RichardHan
Copy link
Contributor

pull request here, #52
I help implement two methods to control slide position (prev & next).

@daimajia
Copy link
Owner

Hey guys, @Chirag-Galani @nitin84india @RichardHan @johnjohndoe @shekibobo :

I'm so sorry for being silent on this issue, cause I'm really busy last few month.

I spent 15 minutes to add the new method setCurrentPosition, hope you can enjoy it.

@daimajia
Copy link
Owner

If any problem, feel free to contact me.

@RichardHan
Copy link
Contributor

thx , good job,

@nitin84india
Copy link

Thank You! :)

@nitin84india
Copy link

Hi, I found an issue when using setCurrentPosition method when you traverse backwards. Suppose I am at slide no 1 and called .setCurrentPosition method to set current slide index to 5, it will work, but if I call .setCurrentPosition from 5th index to say 3rd then the application hangs. I'm getting the following error in doing so:
E/dalvikvm﹕ Fatal spin-on-suspend, dumping threads

@Arunkrishna008
Copy link

hai,

i want to get current image slider position

@akashk2512
Copy link

akashk2512 commented Feb 11, 2017

Hi,
I have 5 Images in array and I want to show all images one by one. But I am getting same Image in every slider. it's loading last image url... Please help me....
for (String url : BookingReq.getSelectedBooking().getBikeImagesBefore()) {
Log.d("ImagesLoopGet",url);
textSliderView.description("")
.image(url)
imageSlider.stopAutoCycle();
imageSlider.addSlider(textSliderView);
}

@Arunkrishna008
Copy link

Arunkrishna008 commented Feb 13, 2017 via email

@akashk2512
Copy link

akashk2512 commented Feb 15, 2017 via email

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

6 participants