Skip to content

Commit

Permalink
Deprecated setLifecycleRegistry method,use registerLifecycleObserver …
Browse files Browse the repository at this point in the history
…instead.
  • Loading branch information
zhpanvip committed Nov 23, 2022
1 parent d99f59c commit 0c7c969
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ArticleAdapter(
.setIndicatorGravity(IndicatorGravity.END)
.setInterval(2000)
.setAdapter(DataBindingSampleAdapter())
.setLifecycleRegistry(context.lifecycle)
.registerLifecycleObserver(context.lifecycle)
.create()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void initHorizontalBanner() {
mViewPagerHorizontal
.setScrollDuration(600)
.setOffScreenPageLimit(2)
.setLifecycleRegistry(getLifecycle())
.registerLifecycleObserver(getLifecycle())
.setIndicatorStyle(IndicatorStyle.CIRCLE)
.setIndicatorSlideMode(IndicatorSlideMode.WORM)
.setInterval(3000)
Expand Down Expand Up @@ -190,7 +190,7 @@ private void initVerticalBanner() {
.setAutoPlay(true)
.setScrollDuration(500)
.stopLoopWhenDetachedFromWindow(true)
.setLifecycleRegistry(getLifecycle())
.registerLifecycleObserver(getLifecycle())
.setIndicatorStyle(IndicatorStyle.ROUND_RECT)
.setIndicatorSlideMode(IndicatorSlideMode.SCALE)
.setIndicatorSliderGap(getResources().getDimensionPixelOffset(R.dimen.dp_4))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected void initView(Bundle savedInstanceState, View view) {
mViewPager = view.findViewById(R.id.banner_view);
mViewPager.setIndicatorSliderGap(BannerUtils.dp2px(6))
.setScrollDuration(800)
.setLifecycleRegistry(getLifecycle())
.registerLifecycleObserver(getLifecycle())
.setIndicatorGravity(IndicatorGravity.CENTER)
.setOnPageClickListener(
(clickedView, position) -> ToastUtils.showShort("position:" + position))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void initView(Bundle savedInstanceState, @NonNull View view) {
view.findViewById(R.id.tv_photo_view).setOnClickListener(this);
mViewPager.setIndicatorSliderGap(BannerUtils.dp2px(6))
.setIndicatorView(mIndicatorView)
.setLifecycleRegistry(getLifecycle())
.registerLifecycleObserver(getLifecycle())
.setRoundCorner(getResources().getDimensionPixelOffset(R.dimen.dp_10))
.setOnPageClickListener((clickedView, position) -> {
ToastUtils.showShort("position:" + position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PageFragment : BaseFragment() {

private fun initBVP() {
mViewPager.apply {
setLifecycleRegistry(lifecycle)
registerLifecycleObserver(lifecycle)
adapter = ViewBindingSampleAdapter(resources.getDimensionPixelOffset(dimen.dp_8))
setIndicatorSlideMode(IndicatorSlideMode.SCALE)
setIndicatorSliderColor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1062,11 +1062,20 @@ public BannerViewPager<T> registerOnPageChangeCallback(
return this;
}

/**
* @deprecated use {@link #registerLifecycleObserver(Lifecycle)} instead.
*/
@Deprecated
public BannerViewPager<T> setLifecycleRegistry(Lifecycle lifecycleRegistry) {
lifecycleRegistry.addObserver(this);
return this;
}

public BannerViewPager<T> registerLifecycleObserver(Lifecycle lifecycleRegistry) {
lifecycleRegistry.addObserver(this);
return this;
}

public BannerViewPager<T> removeLifecycleRegistry(Lifecycle lifecycleRegistry) {
lifecycleRegistry.removeObserver(this);
return this;
Expand Down

0 comments on commit 0c7c969

Please sign in to comment.