Current count of the page in TextSlider?
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.
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.
Ok, thanks your advise, I'll add some new method today. :-D btw, welcome to contribute your code.
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.
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.
Oh, I think I get your point.
Hi, bro. Is this that you really need?
https://github.com/daimajia/AndroidImageSlider/blob/master/library%2Fsrc%2Fmain%2Fjava%2Fcom%2Fdaimajia%2Fslider%2Flibrary%2FSliderLayout.java#L595-L602
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);
}
The code you provided seems have some small bugs..
I'll check tomorrow and add setCurrenPosition method . Thanks.
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. :)
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.
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.
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....
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():- https://github.com/daimajia/AndroidImageSlider/issues/17#issuecomment-48127466 setCurrentPosition(): https://github.com/daimajia/AndroidImageSlider/issues/17#issuecomment-48113680
Thanks for this library and continuous support. :+1:
Ok, I'll add these two methods today. :-D Thanks your support too.
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.
So, before i solve this problem, i will not add these two method to release version considering the bugs.
Hi, did you get a chance to work on the setCurrentPosition method. It get stuck for atleast 20 seconds when called.
Hi all , I'm looking for setCurrentPosition function too. Any tips or suggestions, would be grateful. :)
pull request here, https://github.com/daimajia/AndroidImageSlider/pull/52 I help implement two methods to control slide position (prev & next).
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.