Skip to content
Permalink
Browse files

Merge pull request #44 from ishaansrm/pageDuration

Add 'Page Duration' param
  • Loading branch information...
GIGAMOLE committed Jun 1, 2017
2 parents f68bcc4 + f068a5d commit c3aeb4773df699e54ce9b2b0428803f59db70e49
@@ -31,6 +31,7 @@ public void onViewCreated(final View view, @Nullable final Bundle savedInstanceS
horizontalInfiniteCycleViewPager.setAdapter(new HorizontalPagerAdapter(getContext(), false));

// horizontalInfiniteCycleViewPager.setScrollDuration(400);
// horizontalInfiniteCycleViewPager.setPageDuration(1000);
// horizontalInfiniteCycleViewPager.setInterpolator(
// AnimationUtils.loadInterpolator(getContext(), android.R.anim.overshoot_interpolator)
// );
@@ -31,6 +31,7 @@ public void onViewCreated(final View view, @Nullable final Bundle savedInstanceS
horizontalInfiniteCycleViewPager.setAdapter(new HorizontalPagerAdapter(getContext(), true));
//
// horizontalInfiniteCycleViewPager.setScrollDuration(500);
// horizontalInfiniteCycleViewPager.setPageDuration(1000);
// horizontalInfiniteCycleViewPager.setInterpolator(null);
// horizontalInfiniteCycleViewPager.setMediumScaled(true);
// horizontalInfiniteCycleViewPager.setMaxPageScale(1.0F);
@@ -80,6 +80,14 @@ public void setScrollDuration(final int scrollDuration) {
if (mInfiniteCycleManager != null) mInfiniteCycleManager.setScrollDuration(scrollDuration);
}

public int getPageDuration() {
return mInfiniteCycleManager == null ? 0 : mInfiniteCycleManager.getPageDuration();
}

public void setPageDuration(final int pageDuration) {
if (mInfiniteCycleManager != null) mInfiniteCycleManager.setPageDuration(pageDuration);
}

public Interpolator getInterpolator() {
return mInfiniteCycleManager == null ? null : mInfiniteCycleManager.getInterpolator();
}
@@ -111,6 +111,8 @@

// Scroll duration of snapping
private int mScrollDuration;
// Duration for which a page will be shown before moving on to next one when {@link mIsAutoScroll} is TRUE
private int mPageDuration;
// Interpolator of snapping
private Interpolator mInterpolator;

@@ -124,7 +126,7 @@
public void run() {
if (!mIsAutoScroll) return;
mViewPageable.setCurrentItem(getRealItem() + (mIsAutoScrollPositive ? 1 : -1));
mAutoScrollHandler.postDelayed(this, mScrollDuration);
mAutoScrollHandler.postDelayed(this, mPageDuration);
}
};

@@ -203,6 +205,13 @@ public void processAttributeSet(final AttributeSet attributeSet) {
DEFAULT_SCROLL_DURATION
)
);
setPageDuration(
typedArray.getInteger(
mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_page_duration :
R.styleable.HorizontalInfiniteCycleViewPager_icvp_page_duration,
DEFAULT_SCROLL_DURATION
)
);

// Retrieve interpolator
Interpolator interpolator = null;
@@ -275,6 +284,15 @@ public void setScrollDuration(final int scrollDuration) {
resetScroller();
}

public int getPageDuration() {
return mPageDuration;
}

public void setPageDuration(final int pageDuration) {
mPageDuration = pageDuration;
resetScroller();
}

public Interpolator getInterpolator() {
return mInterpolator;
}
@@ -80,6 +80,14 @@ public void setScrollDuration(final int scrollDuration) {
if (mInfiniteCycleManager != null) mInfiniteCycleManager.setScrollDuration(scrollDuration);
}

public int getPageDuration() {
return mInfiniteCycleManager == null ? 0 : mInfiniteCycleManager.getPageDuration();
}

public void setPageDuration(final int pageDuration) {
if (mInfiniteCycleManager != null) mInfiniteCycleManager.setPageDuration(pageDuration);
}

public Interpolator getInterpolator() {
return mInfiniteCycleManager == null ? null : mInfiniteCycleManager.getInterpolator();
}
@@ -7,6 +7,7 @@
<attr name="icvp_max_page_scale" format="float"/>
<attr name="icvp_medium_scaled" format="boolean"/>
<attr name="icvp_scroll_duration" format="integer"/>
<attr name="icvp_page_duration" format="integer"/>
<attr name="icvp_interpolator" format="reference"/>

<declare-styleable name="HorizontalInfiniteCycleViewPager">
@@ -16,6 +17,7 @@
<attr name="icvp_max_page_scale"/>
<attr name="icvp_medium_scaled"/>
<attr name="icvp_scroll_duration"/>
<attr name="icvp_page_duration"/>
<attr name="icvp_interpolator"/>
</declare-styleable>

@@ -26,6 +28,7 @@
<attr name="icvp_max_page_scale"/>
<attr name="icvp_medium_scaled"/>
<attr name="icvp_scroll_duration"/>
<attr name="icvp_page_duration"/>
<attr name="icvp_interpolator"/>
</declare-styleable>

0 comments on commit c3aeb47

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.