diff --git a/.gitignore b/.gitignore index 39fb081a..63cb77a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ *.iml .gradle /local.properties -/.idea/workspace.xml -/.idea/libraries +.idea .DS_Store /build /captures diff --git a/app/build.gradle b/app/build.gradle index d453cec1..77f669f4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -48,7 +48,7 @@ dependencies { testImplementation 'junit:junit:4.12' implementation 'com.github.bumptech.glide:glide:4.9.0' implementation 'com.github.chrisbanes:PhotoView:2.1.0' -// implementation 'com.github.zhpanvip:BannerViewPager:2.3.5' +// implementation 'com.github.zhpanvip:BannerViewPager:2.5.0' implementation project(path: ':bannerview') implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0' diff --git a/app/src/main/java/com/example/zhpan/circleviewpager/activity/MainActivity.kt b/app/src/main/java/com/example/zhpan/circleviewpager/activity/MainActivity.kt index c322f4a5..6f9e2f7a 100644 --- a/app/src/main/java/com/example/zhpan/circleviewpager/activity/MainActivity.kt +++ b/app/src/main/java/com/example/zhpan/circleviewpager/activity/MainActivity.kt @@ -25,16 +25,16 @@ class MainActivity : AppCompatActivity() { private fun initData() { val mAdapter = AdapterFragmentPager(supportFragmentManager) - vp_fragment!!.adapter = mAdapter - vp_fragment!!.disableTouchScroll(true) - vp_fragment!!.offscreenPageLimit = 2 - vp_fragment!!.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + vp_fragment?.adapter = mAdapter + vp_fragment?.disableTouchScroll(true) + vp_fragment?.offscreenPageLimit = 2 + vp_fragment?.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { } override fun onPageSelected(position: Int) { - rg_tab!!.check(getCheckedId(position)) + rg_tab?.check(getCheckedId(position)) } override fun onPageScrollStateChanged(state: Int) { @@ -54,15 +54,15 @@ class MainActivity : AppCompatActivity() { } private fun setListener() { - rg_tab!!.setOnCheckedChangeListener { group, checkedId -> + rg_tab?.setOnCheckedChangeListener { group, checkedId -> if (checkedId == R.id.rb_home) { - vp_fragment!!.setCurrentItem(AdapterFragmentPager.PAGE_HOME, false) + vp_fragment?.setCurrentItem(AdapterFragmentPager.PAGE_HOME, false) } else if (checkedId == R.id.rb_find) { - vp_fragment!!.setCurrentItem(AdapterFragmentPager.PAGE_FIND, false) + vp_fragment?.setCurrentItem(AdapterFragmentPager.PAGE_FIND, false) } else if (checkedId == R.id.rb_add) { - vp_fragment!!.setCurrentItem(AdapterFragmentPager.PAGE_OTHERS, false) + vp_fragment?.setCurrentItem(AdapterFragmentPager.PAGE_OTHERS, false) } } } diff --git a/app/src/main/java/com/example/zhpan/circleviewpager/activity/WelcomeActivity.kt b/app/src/main/java/com/example/zhpan/circleviewpager/activity/WelcomeActivity.kt index e0c5ad5f..7564e5bf 100644 --- a/app/src/main/java/com/example/zhpan/circleviewpager/activity/WelcomeActivity.kt +++ b/app/src/main/java/com/example/zhpan/circleviewpager/activity/WelcomeActivity.kt @@ -79,7 +79,7 @@ class WelcomeActivity : BaseDataActivity(), HolderCreator } private fun updateUI(position: Int) { - tv_describe!!.text = des[position] + tv_describe?.text = des[position] val translationAnim = ObjectAnimator.ofFloat(tv_describe, "translationX", -120f, 0f) translationAnim.duration = ANIMATION_DURATION.toLong() translationAnim.interpolator = DecelerateInterpolator() @@ -89,13 +89,13 @@ class WelcomeActivity : BaseDataActivity(), HolderCreator animatorSet.playTogether(translationAnim, alphaAnimator1) animatorSet.start() - if (position == mViewPager.list.size - 1 && btn_start!!.visibility == View.GONE) { - btn_start!!.visibility = View.VISIBLE + if (position == mViewPager.list.size - 1 && btn_start?.visibility == View.GONE) { + btn_start?.visibility = View.VISIBLE ObjectAnimator .ofFloat(btn_start, "alpha", 0f, 1f) .setDuration(ANIMATION_DURATION.toLong()).start() } else { - btn_start!!.visibility = View.GONE + btn_start?.visibility = View.GONE } } diff --git a/bannerview/src/main/java/com/zhpan/bannerview/indicator/DashIndicatorView.java b/bannerview/src/main/java/com/zhpan/bannerview/indicator/DashIndicatorView.java index e4804a1d..9165c0c2 100644 --- a/bannerview/src/main/java/com/zhpan/bannerview/indicator/DashIndicatorView.java +++ b/bannerview/src/main/java/com/zhpan/bannerview/indicator/DashIndicatorView.java @@ -91,11 +91,6 @@ private void drawSliderStyle(Canvas canvas) { canvas.drawRect(left, 0, left + maxWidth, getSliderHeight(), mPaint); } - public DashIndicatorView setSliderHeight(float sliderHeight) { - this.sliderHeight = sliderHeight; - return this; - } - public float getSliderHeight() { if (getIndicatorOptions().getSliderHeight() > 0) { return getIndicatorOptions().getSliderHeight(); diff --git a/bannerview/src/main/java/com/zhpan/bannerview/indicator/IndicatorView.java b/bannerview/src/main/java/com/zhpan/bannerview/indicator/IndicatorView.java index b7adf246..54513091 100644 --- a/bannerview/src/main/java/com/zhpan/bannerview/indicator/IndicatorView.java +++ b/bannerview/src/main/java/com/zhpan/bannerview/indicator/IndicatorView.java @@ -7,7 +7,7 @@ import androidx.annotation.Nullable; import com.zhpan.bannerview.indicator.drawer.BaseDrawer; -import com.zhpan.bannerview.indicator.drawer.DrawerController; +import com.zhpan.bannerview.indicator.drawer.DrawerProxy; import com.zhpan.bannerview.manager.IndicatorOptions; /** @@ -20,7 +20,7 @@ */ public class IndicatorView extends BaseIndicatorView implements IIndicator { - private DrawerController mDrawerController; + private DrawerProxy mDrawerProxy; public IndicatorView(Context context) { this(context, null); @@ -32,25 +32,25 @@ public IndicatorView(Context context, @Nullable AttributeSet attrs) { public IndicatorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mDrawerController = new DrawerController(getIndicatorOptions()); + mDrawerProxy = new DrawerProxy(getIndicatorOptions()); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); - BaseDrawer.MeasureResult measureResult = mDrawerController.measure(widthMeasureSpec, heightMeasureSpec); + BaseDrawer.MeasureResult measureResult = mDrawerProxy.onMeasure(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(measureResult.getMeasureWidth(), measureResult.getMeasureHeight()); } @Override public void setIndicatorOptions(IndicatorOptions indicatorOptions) { super.setIndicatorOptions(indicatorOptions); - mDrawerController.setIndicatorOptions(indicatorOptions); + mDrawerProxy.setIndicatorOptions(indicatorOptions); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); - mDrawerController.draw(canvas); + mDrawerProxy.onDraw(canvas); } } diff --git a/bannerview/src/main/java/com/zhpan/bannerview/indicator/drawer/DrawerController.java b/bannerview/src/main/java/com/zhpan/bannerview/indicator/drawer/DrawerProxy.java similarity index 76% rename from bannerview/src/main/java/com/zhpan/bannerview/indicator/drawer/DrawerController.java rename to bannerview/src/main/java/com/zhpan/bannerview/indicator/drawer/DrawerProxy.java index 1806af50..b1456e27 100644 --- a/bannerview/src/main/java/com/zhpan/bannerview/indicator/drawer/DrawerController.java +++ b/bannerview/src/main/java/com/zhpan/bannerview/indicator/drawer/DrawerProxy.java @@ -10,14 +10,14 @@ /** *
  *   Created by zhpan on 2019/11/23.
- *   Description: Indicator Drawer Controller.
+ *   Description: Indicator Drawer Proxy.
  * 
*/ -public class DrawerController { +public class DrawerProxy implements IDrawer{ private IDrawer mIDrawer; - public DrawerController(IndicatorOptions indicatorOptions) { + public DrawerProxy(IndicatorOptions indicatorOptions) { init(indicatorOptions); } @@ -36,11 +36,13 @@ public void setIndicatorOptions(IndicatorOptions indicatorOptions) { init(indicatorOptions); } - public BaseDrawer.MeasureResult measure(int widthMeasureSpec, int heightMeasureSpec) { + @Override + public BaseDrawer.MeasureResult onMeasure(int widthMeasureSpec, int heightMeasureSpec) { return mIDrawer.onMeasure(widthMeasureSpec, heightMeasureSpec); } - public void draw(Canvas canvas) { + @Override + public void onDraw(Canvas canvas) { mIDrawer.onDraw(canvas); } }