Skip to content

Commit

Permalink
2.6.1 (#65)
Browse files Browse the repository at this point in the history
* SCALE_IN Transformer supported.

* add attrs.

* Deprecated setRoundCorner,use setRoundRect instead.

* Remove java8 config.

* Fix issue #34

* 修复Smooth模式下Indicator不刷新问题

* update readme
  • Loading branch information
zhpanvip committed Dec 12, 2019
1 parent f534957 commit caf5e93
Show file tree
Hide file tree
Showing 33 changed files with 191 additions and 411 deletions.
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -58,7 +58,7 @@ BannerViewPager supports three Indicator Styles now. It's also support you to cu
| BannerViewPager<T, VH> setAutoPlay(boolean autoPlay) | set is atuo play | default value true|
| BannerViewPager<T, VH> setInterval(int interval) | set the interval of item switch interval |The unit is millisecond,default value 3000ms |
| BannerViewPager<T, VH> setScrollDuration(int scrollDuration) | set page scroll duration | set page scroll duration |unit is millisecond,default is 500ms |
| BannerViewPager<T, VH> setRoundCorner(int radius) | set Round Corner for Banner | required SDK_INT>=LOLLIPOP(API 21) |
| BannerViewPager<T, VH> setRoundRect(int radius) | set Round Rectangle for Banner | required SDK_INT>=LOLLIPOP(API 21) |
| BannerViewPager<T, VH> setOnPageClickListener(OnPageClickListener onPageClickListener) | set item click listener | |
| BannerViewPager<T, VH> setHolderCreator(HolderCreator\<VH> holderCreator) |set Holder Creator |You must set HolderCreator for BannerViewPager,or will throw NullPointerException|
| BannerViewPager<T, VH> setIndicatorVisibility(@Visibility int visibility) | indicator visibility |default value is VISIBLE,added in version 2.4.2|
Expand Down Expand Up @@ -378,21 +378,21 @@ public class FigureIndicatorView extends BaseIndicatorView {

- [x] Fix a bug which page frozen sometimes when sliding in version 2.1.0 (2.1.0.1)

- [x] support setTransformStyle(2.1.2)
- [x] Set Transform Style Supported(2.1.2)

- [x] Migrate to Androidx(2.2.0)

- [x] Support indicator smooth slide(2.2.2)
- [x] indicator smooth slide Supported(2.2.2)

- [x] Support Dash IndicatorView(2.3.+)
- [x] Dash IndicatorView Supported(2.3.+)

- [x] Support MULTI_PAGE Style (2.4.0)
- [x] MULTI_PAGE Style Supported(2.4.0)

- [x] Optimize code and improve performance in version 2.4.3

- [x] Refactor Indicator again (2.5.0)

- [ ] Change ViewPager to ViewPager2 (3.0.0)
- [x] Fix issue #34 which Indicator smooth slide problem(2.6.1).
- [ ] Migrate to ViewPager2 (3.0.0)


## If you have any question you can scan the QR code to join the QQ group to communicate.
Expand Down
3 changes: 2 additions & 1 deletion README_CN.md
Expand Up @@ -61,7 +61,7 @@ BannerViewPager支持多种IndicatorViewStyle,同时还提供了完全自定义I
| BannerViewPager<T, VH> setAutoPlay(boolean autoPlay) | 是否开启自动轮播 | 默认值true|
| BannerViewPager<T, VH> setInterval(int interval) | 自动轮播时间间隔 |单位毫秒,默认值3000 |
| BannerViewPager<T, VH> setScrollDuration(int scrollDuration) | 设置页面滚动时间 | 设置页面滚动时间 |单位毫秒,默认值500 |
| BannerViewPager<T, VH> setRoundCorner(int radius) | 设置圆角 |默认无圆角 需要SDK_INT>=LOLLIPOP(API 21) |
| BannerViewPager<T, VH> setRoundRect(int radius) | 设置圆角 |默认无圆角 需要SDK_INT>=LOLLIPOP(API 21) |
| BannerViewPager<T, VH> setOnPageClickListener(OnPageClickListener onPageClickListener) | 设置页面点击事件 | |
| BannerViewPager<T, VH> setHolderCreator(HolderCreator\<VH> holderCreator) |设置HolderCreator |必须设置HolderCreator,否则会抛出NullPointerException|
| BannerViewPager<T, VH> setIndicatorVisibility(@Visibility int visibility) | indicator visibility |默认值VISIBLE 2.4.2 新增|
Expand Down Expand Up @@ -391,6 +391,7 @@ public class FigureIndicatorView extends BaseIndicatorView {
- [x] v2.4.3版本着重优化提升性能
- [x] 重构Indicator,~~尽量修复Indicator SMOOTH模式下滑动问题~~ (2.5.0)
- [x] 目前Indicator部分代码比较乱,还有很大很大的优化空间,后续版本将持续优化(2.5.0对Indicator再次进行了重构,重构后代码已经很整洁,但仍然有优化空间)
- [x] 修复 issue #34 Indicator 在Smooth模式下存在的问题 (2.6.1).
- [ ] ViewPager更换为ViewPager2 (3.0.0)


Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
Expand Up @@ -23,7 +23,6 @@ class PhotoViewActivity : BaseDataActivity() {
bannerViewPager.setAutoPlay(false)
.setCanLoop(false)
.setHolderCreator { PhotoViewHolder() }
.setIndicatorSlideMode(IndicatorSlideMode.SMOOTH)
.create(mDrawableList)
bannerViewPager.currentItem = 1
}
Expand Down
Expand Up @@ -30,7 +30,7 @@ class WelcomeActivity : BaseDataActivity(), HolderCreator<CustomPageViewHolder>

private val des = arrayOf("在这里\n你可以听到周围人的心声", "在这里\nTA会在下一秒遇见你", "在这里\n不再错过可以改变你一生的人")

private val transforms = intArrayOf(TransformerStyle.NONE, TransformerStyle.ACCORDION, TransformerStyle.STACK, TransformerStyle.DEPTH, TransformerStyle.ROTATE)
private val transforms = intArrayOf(TransformerStyle.NONE, TransformerStyle.ACCORDION, TransformerStyle.STACK, TransformerStyle.DEPTH, TransformerStyle.ROTATE, TransformerStyle.SCALE_IN)

private val data: List<CustomBean>
get() {
Expand All @@ -56,7 +56,7 @@ class WelcomeActivity : BaseDataActivity(), HolderCreator<CustomPageViewHolder>
mViewPager = findViewById(R.id.viewpager)
mViewPager.setAutoPlay(false)
.setCanLoop(false)
.setPageTransformerStyle(transforms[Random().nextInt(5)])
.setPageTransformerStyle(transforms[Random().nextInt(6)])
.setScrollDuration(ANIMATION_DURATION)
.setIndicatorMargin(0, 0, 0, BannerUtils.dp2px(100f))
.setIndicatorGap(resources.getDimension(R.dimen.dp_10).toInt())
Expand All @@ -66,7 +66,7 @@ class WelcomeActivity : BaseDataActivity(), HolderCreator<CustomPageViewHolder>
.setIndicatorRadius(resources.getDimension(R.dimen.dp_3).toInt(), resources.getDimension(R.dimen.dp_4_5).toInt())
.setOnPageChangeListener(object : OnPageChangeListenerAdapter() {
override fun onPageSelected(position: Int) {
BannerUtils.e("position:$position")
BannerUtils.log("position:$position")
updateUI(position)
}
})
Expand Down
Expand Up @@ -3,6 +3,7 @@
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.DividerItemDecoration;
Expand All @@ -19,8 +20,9 @@
import com.scwang.smartrefresh.header.MaterialHeader;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.zhpan.bannerview.BannerViewPager;
import com.zhpan.bannerview.constants.PageStyle;
import com.zhpan.bannerview.utils.BannerUtils;
import com.zhpan.bannerview.adapter.OnPageChangeListenerAdapter;
import com.zhpan.bannerview.constants.IndicatorSlideMode;
import com.zhpan.bannerview.indicator.IndicatorView;
import com.zhpan.idea.net.common.ResponseObserver;
import com.zhpan.idea.utils.RxUtil;

Expand All @@ -39,6 +41,8 @@ public class HomeFragment extends BaseFragment {
private CustomRecyclerView recyclerView;
private ArticleAdapter articleAdapter;
private SmartRefreshLayout mSmartRefreshLayout;
private IndicatorView mIndicatorView;
private TextView mTvTitle;

@Override
protected int getLayout() {
Expand Down Expand Up @@ -87,6 +91,8 @@ private void fetchData(boolean showLoading) {
public void onSuccess(DataWrapper response) {
mBannerViewPager.create(response.getDataBeanList());
articleAdapter.setData(response.getArticleList());
if (response.getDataBeanList().size() > 0)
mTvTitle.setText(response.getDataBeanList().get(0).getTitle());
}

@Override
Expand All @@ -108,14 +114,20 @@ private Observable<List<BannerData>> getBannerObserver() {
private void initBanner() {
mBannerViewPager
.setAutoPlay(true)
.setIndicatorSlideMode(IndicatorSlideMode.SMOOTH)
.setInterval(5000)
.setScrollDuration(1200)
// .setRevealWidth(BannerUtils.dp2px(10))
.setPageMargin(BannerUtils.dp2px(10))
.setPageStyle(PageStyle.MULTI_PAGE)
.setIndicatorView(mIndicatorView)// 这里为了设置标题故用了自定义Indicator,如果无需标题则没必要添加此行代码
.setIndicatorColor(getColor(R.color.red_normal_color), getColor(R.color.red_checked_color))
.setHolderCreator(NetViewHolder::new)
.setIndicatorMargin(0, 0, 0, (int) getResources().getDimension(R.dimen.dp_18))
.setOnPageChangeListener(new OnPageChangeListenerAdapter() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
BannerData bannerData = mBannerViewPager.getList().get(position);
mTvTitle.setText(bannerData.getTitle());
}
})
.setOnPageClickListener(this::onPageClicked);
}

Expand All @@ -127,6 +139,8 @@ private void onPageClicked(int position) {
private View getHeaderView() {
View view = LayoutInflater.from(getMContext()).inflate(R.layout.item_header_view, recyclerView, false);
mBannerViewPager = view.findViewById(R.id.banner_view);
mTvTitle = view.findViewById(R.id.tv_title);
mIndicatorView = view.findViewById(R.id.indicator_view);
return view;
}
}
Expand Up @@ -10,6 +10,7 @@
import com.example.zhpan.circleviewpager.viewholder.ImageResourceViewHolder;
import com.zhpan.bannerview.BannerViewPager;
import com.zhpan.bannerview.constants.IndicatorGravity;
import com.zhpan.bannerview.constants.IndicatorSlideMode;
import com.zhpan.bannerview.constants.IndicatorStyle;
import com.zhpan.bannerview.utils.BannerUtils;
import com.zhpan.idea.utils.ToastUtils;
Expand Down Expand Up @@ -39,7 +40,7 @@ protected void initView(Bundle savedInstanceState, View view) {
radioGroupStyle = view.findViewById(R.id.rg_indicator_style);
mViewPager = view.findViewById(R.id.banner_view);
mViewPager.setIndicatorGap(BannerUtils.dp2px(6))
.setRoundCorner(BannerUtils.dp2px(6))
.setRoundRect(BannerUtils.dp2px(6))
.setHolderCreator(() -> new ImageResourceViewHolder(0));
initRadioGroup();
}
Expand Down Expand Up @@ -72,6 +73,7 @@ private void setupTmallIndicator() {
mViewPager
.setIndicatorStyle(IndicatorStyle.DASH)
.setIndicatorGap(0)
.setIndicatorSlideMode(IndicatorSlideMode.SMOOTH)
.setIndicatorColor(getColor(R.color.white_alpha_75), getColor(R.color.white))
.setIndicatorWidth(BannerUtils.dp2px(12), BannerUtils.dp2px(12))
.setIndicatorHeight(BannerUtils.dp2px(1.5f))
Expand All @@ -83,6 +85,7 @@ private void setupRoundRectIndicator() {
.setIndicatorGravity(IndicatorGravity.CENTER)
.setIndicatorGap(BannerUtils.dp2px(4))
.setPageMargin(0)
.setIndicatorSlideMode(IndicatorSlideMode.NORMAL)
.setIndicatorHeight(BannerUtils.dp2px(4f))
.setOnPageClickListener(position -> ToastUtils.show("position:" + position))
.setIndicatorColor(getColor(R.color.red_normal_color), getColor(R.color.red_checked_color))
Expand All @@ -91,6 +94,7 @@ private void setupRoundRectIndicator() {

private void setupCircleIndicator() {
mViewPager.setIndicatorStyle(IndicatorStyle.CIRCLE)
.setIndicatorSlideMode(IndicatorSlideMode.SMOOTH)
.setIndicatorGravity(IndicatorGravity.CENTER)
.setIndicatorGap(BannerUtils.dp2px(6))
.setPageMargin(0)
Expand All @@ -103,6 +107,7 @@ private void setupDashIndicator() {
mViewPager.setIndicatorStyle(IndicatorStyle.DASH)
.setIndicatorHeight(BannerUtils.dp2px(3f))
.setIndicatorGravity(IndicatorGravity.CENTER)
.setIndicatorSlideMode(IndicatorSlideMode.NORMAL)
.setIndicatorGap(BannerUtils.dp2px(3))
.setPageMargin(0)
.setIndicatorWidth(BannerUtils.dp2px(3), BannerUtils.dp2px(10))
Expand Down
Expand Up @@ -13,6 +13,7 @@
import com.example.zhpan.circleviewpager.viewholder.ImageResourceViewHolder;
import com.zhpan.bannerview.BannerViewPager;
import com.zhpan.bannerview.constants.IndicatorGravity;
import com.zhpan.bannerview.constants.IndicatorSlideMode;
import com.zhpan.bannerview.indicator.IIndicator;
import com.zhpan.bannerview.indicator.IndicatorView;
import com.zhpan.bannerview.utils.BannerUtils;
Expand Down Expand Up @@ -51,7 +52,7 @@ protected void initView(Bundle savedInstanceState, View view) {
view.findViewById(R.id.tv_photo_view).setOnClickListener(this);
view.findViewById(R.id.btn_refresh).setOnClickListener(v -> updateData());
mViewPager.setIndicatorGap(BannerUtils.dp2px(6))
.setRoundCorner(BannerUtils.dp2px(6))
.setRoundRect(BannerUtils.dp2px(6))
.setOnPageClickListener(position -> ToastUtils.show("Position:" + position))
.setIndicatorColor(getColor(R.color.red_normal_color), getColor(R.color.red_checked_color))
.setHolderCreator(() -> new ImageResourceViewHolder(0));
Expand Down Expand Up @@ -84,6 +85,7 @@ private void initRadioGroup() {
private void setIndicatorBelowOfBanner() {
mIndicatorView.setVisibility(View.VISIBLE);
mViewPager
.setIndicatorSlideMode(IndicatorSlideMode.SMOOTH)
.setIndicatorVisibility(View.GONE)
.setIndicatorView(mIndicatorView)
.create(getMDrawableList());
Expand All @@ -93,6 +95,7 @@ private void setIndicatorBelowOfBanner() {
private void setupCustomIndicator() {
mIndicatorView.setVisibility(View.INVISIBLE);
mViewPager.setAutoPlay(false).setCanLoop(true)
.setIndicatorSlideMode(IndicatorSlideMode.NORMAL)
.setIndicatorVisibility(View.VISIBLE)
.setPageMargin(BannerUtils.dp2px(20))
.setIndicatorGravity(IndicatorGravity.END)
Expand Down
Expand Up @@ -9,6 +9,7 @@
import com.example.zhpan.circleviewpager.viewholder.ImageResourceViewHolder;
import com.zhpan.bannerview.BannerViewPager;
import com.zhpan.bannerview.annotation.APageStyle;
import com.zhpan.bannerview.constants.IndicatorSlideMode;
import com.zhpan.bannerview.constants.PageStyle;
import com.zhpan.bannerview.utils.BannerUtils;
import com.zhpan.idea.utils.ToastUtils;
Expand Down Expand Up @@ -38,6 +39,7 @@ protected void initView(Bundle savedInstanceState, View view) {
mRadioGroupPageStyle = view.findViewById(R.id.rg_page_style);
radioButton = view.findViewById(R.id.rb_multi_page);
mViewPager
.setIndicatorSlideMode(IndicatorSlideMode.SMOOTH)
.setHolderCreator(() -> new ImageResourceViewHolder(BannerUtils.dp2px(5)))
.setIndicatorColor(getColor(R.color.red_normal_color), getColor(R.color.red_checked_color))
.setOnPageClickListener(position -> ToastUtils.show("position:" + position))
Expand Down
Expand Up @@ -10,7 +10,6 @@
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.example.zhpan.circleviewpager.imageloader.transformer.BlurTransformation;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -57,9 +56,6 @@ private void setTransformation(ImageLoaderOptions options, RequestOptions reques
list.add(new RoundedCorners((int)options.getRoundCorner()));
}

if(options.isBlurImage()) {
list.add(new BlurTransformation(options.getBlurValue()));
}

for(Transformation<Bitmap> transformation : list) {
requestOptions.transform(transformation);
Expand Down

0 comments on commit caf5e93

Please sign in to comment.