From 92c5a7c665636c7af4c1f497c41657653ae80326 Mon Sep 17 00:00:00 2001 From: angcyo Date: Fri, 28 Apr 2023 23:27:27 +0800 Subject: [PATCH] + IDslItem / banner item --- build.gradle | 1 - demo/build.gradle | 7 + demo/src/main/AndroidManifest.xml | 3 + .../com/angcyo/dslitem/demo/MainActivity.kt | 18 + .../dslitem/demo/dslitem/SingleImageItem.kt | 34 ++ .../src/main/res/layout/item_single_image.xml | 12 + .../src/main/java/com/angcyo/item/AnimEx.kt | 317 +----------------- .../src/main/java/com/angcyo/item/LibEx.kt | 45 ++- .../angcyo/item/base/RAnimationListener.kt | 21 ++ dslitem2/build.gradle | 3 + .../java/com/angcyo/item2/DslBannerItem.kt | 9 +- .../java/com/angcyo/item2/ILoopAdapterItem.kt | 17 + .../item2/widget/recycler/LoopRecyclerView.kt | 1 - .../item2/widget/recycler/LoopSnapHelper.kt | 7 +- .../src/main/res/values/attr_border_view.xml | 15 + .../{item2_colors.xml => item2_values.xml} | 0 16 files changed, 184 insertions(+), 326 deletions(-) create mode 100644 demo/src/main/java/com/angcyo/dslitem/demo/dslitem/SingleImageItem.kt create mode 100644 demo/src/main/res/layout/item_single_image.xml create mode 100644 dslitem/src/main/java/com/angcyo/item/base/RAnimationListener.kt create mode 100644 dslitem2/src/main/java/com/angcyo/item2/ILoopAdapterItem.kt create mode 100644 dslitem2/src/main/res/values/attr_border_view.xml rename dslitem2/src/main/res/values/{item2_colors.xml => item2_values.xml} (100%) diff --git a/build.gradle b/build.gradle index d42302d..1d04c86 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,6 @@ buildscript { repositories { google() mavenCentral() - } dependencies { classpath 'com.android.tools.build:gradle:7.4.2' diff --git a/demo/build.gradle b/demo/build.gradle index d1691b2..1f35fbf 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-parcelize' +apply plugin: 'kotlin-kapt' android { compileSdk Integer.parseInt(C_SDK) @@ -36,4 +37,10 @@ dependencies { implementation project(":dslitem") implementation project(":dslitem2") + + def glide_version = "4.15.1" + //https://muyangmin.github.io/glide-docs-cn/ + //https://github.com/bumptech/glide + implementation "com.github.bumptech.glide:glide:$glide_version" + kapt "com.github.bumptech.glide:compiler:$glide_version" } diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index f846dec..bc64c36 100644 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -1,6 +1,9 @@ + + + (R.id.recycler_view)?.initDslAdapter { render { + DslBannerItem()() { + itemHeight = 200 * dpi + renderNestedAdapter { + SingleImageItem()() { + itemImageUri = + "https://scpic.chinaz.net/files/default/imgs/2023-04-26/22c25fc6b5b32280.jpg" + } + SingleImageItem()() { + itemImageUri = + "https://scpic.chinaz.net/files/default/imgs/2023-04-26/927afbe5af4fec22.jpg" + } + } + } + DslBaseEditItem()() { itemEditText = this::class.java.simpleName editItemConfig._lastEditSelectionStart = itemEditText?.length ?: -1 diff --git a/demo/src/main/java/com/angcyo/dslitem/demo/dslitem/SingleImageItem.kt b/demo/src/main/java/com/angcyo/dslitem/demo/dslitem/SingleImageItem.kt new file mode 100644 index 0000000..765f4ad --- /dev/null +++ b/demo/src/main/java/com/angcyo/dslitem/demo/dslitem/SingleImageItem.kt @@ -0,0 +1,34 @@ +package com.angcyo.dslitem.demo.dslitem + +import com.angcyo.dsladapter.DslAdapterItem +import com.angcyo.dsladapter.DslViewHolder +import com.angcyo.dslitem.demo.R +import com.bumptech.glide.Glide + +/** + * Email:angcyo@126.com + * @author angcyo + * @date 2023/04/28 + */ +class SingleImageItem : DslAdapterItem() { + + var itemImageUri: String? = null + + init { + itemLayoutId = R.layout.item_single_image + } + + override fun onItemBind( + itemHolder: DslViewHolder, + itemPosition: Int, + adapterItem: DslAdapterItem, + payloads: List + ) { + super.onItemBind(itemHolder, itemPosition, adapterItem, payloads) + + itemHolder.img(R.id.lib_image_view)?.let { + Glide.with(itemHolder.itemView).load(itemImageUri).centerCrop().into(it) + } + } + +} \ No newline at end of file diff --git a/demo/src/main/res/layout/item_single_image.xml b/demo/src/main/res/layout/item_single_image.xml new file mode 100644 index 0000000..d5eebcb --- /dev/null +++ b/demo/src/main/res/layout/item_single_image.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/dslitem/src/main/java/com/angcyo/item/AnimEx.kt b/dslitem/src/main/java/com/angcyo/item/AnimEx.kt index 0a85e2a..c540213 100644 --- a/dslitem/src/main/java/com/angcyo/item/AnimEx.kt +++ b/dslitem/src/main/java/com/angcyo/item/AnimEx.kt @@ -1,27 +1,21 @@ package com.angcyo.item import android.animation.* -import android.annotation.TargetApi import android.content.Context import android.graphics.Camera import android.graphics.Matrix import android.graphics.Rect import android.os.Build -import android.util.Property import android.view.View -import android.view.ViewAnimationUtils import android.view.animation.* import androidx.annotation.AnimRes import androidx.annotation.AnimatorRes import androidx.annotation.RequiresApi -import androidx.core.animation.addListener -import androidx.core.view.ViewCompat -import androidx.core.view.doOnPreDraw +import com.angcyo.dsladapter.mH +import com.angcyo.dsladapter.mW import com.angcyo.item.Anim.ANIM_DURATION -import com.angcyo.library.animation.YRotateAnimation -import com.angcyo.library.app -import com.angcyo.library.component.MatrixEvaluator -import com.angcyo.library.component.RAnimationListener +import com.angcyo.item.base.LibInitProvider +import com.angcyo.item.base.RAnimationListener import java.lang.ref.WeakReference /** @@ -38,29 +32,29 @@ object Anim { } /**从指定资源id中, 加载动画[Animation]*/ -fun animationOf(context: Context = app(), @AnimRes id: Int): Animation? { +fun animationOf(context: Context = LibInitProvider.contentProvider, @AnimRes id: Int): Animation? { try { if (id == 0 || id == -1) { return null } return AnimationUtils.loadAnimation(context, id) } catch (e: Exception) { - //e.printStackTrace() - L.w(e.message) + e.printStackTrace() return null } } /**从指定资源id中, 加载动画[Animator]*/ -fun animatorOf(context: Context = app(), @AnimatorRes id: Int): Animator? { +fun animatorOf( + context: Context = LibInitProvider.contentProvider, @AnimatorRes id: Int +): Animator? { try { if (id == 0 || id == -1) { return null } return AnimatorInflater.loadAnimator(context, id) } catch (e: Exception) { - //e.printStackTrace() - L.w(e.message) + e.printStackTrace() return null } } @@ -212,60 +206,6 @@ fun Animation.onAnimationEnd(onEnd: (animation: Animation) -> Unit = {}) { }) } -/** - * 揭露动画 - * https://developer.android.com/training/animation/reveal-or-hide-view#Reveal - * */ -@TargetApi(Build.VERSION_CODES.LOLLIPOP) -fun View.reveal(action: RevealConfig.() -> Unit = {}) { - this.doOnPreDraw { - val config = RevealConfig() - if (config.centerX == 0) { - config.centerX = this.measuredWidth / 2 - } - if (config.centerY == 0) { - config.centerY = this.measuredHeight / 2 - } - if (config.endRadius == 0f) { - config.endRadius = c(config.centerX.toDouble(), config.centerY.toDouble()).toFloat() - } - - //第一次获取基础数据 - config.action() - - ViewAnimationUtils.createCircularReveal( - this, - config.centerX, - config.centerY, - config.startRadius, - config.endRadius - ).apply { - duration = config.duration - - config.animator = this - //第二次获取动画数据 - config.action() - start() - } - } -} - -data class RevealConfig( - var animator: Animator? = null, - - //如果为0, 则默认是视图的中心 - var centerX: Int = 0, - var centerY: Int = 0, - - //动画开始的半径 - var startRadius: Float = 0f, - //如果为0, 默认是视图的对角半径 - var endRadius: Float = 0f, - - //动画时长 - var duration: Long = ANIM_DURATION -) - /**颜色渐变动画*/ fun colorAnimator( fromColor: Int, @@ -300,100 +240,6 @@ fun colorAnimator( return colorAnimator } -/**一组颜色变化的动画*/ -fun colorListAnimator( - colorList: List, - infinite: Boolean = false, - interpolator: Interpolator = LinearInterpolator(), - duration: Long = colorList.size() * 1000L, - onEnd: (cancel: Boolean) -> Unit = {}, - config: ValueAnimator.() -> Unit = {}, - onUpdate: (animator: ValueAnimator, color: Int) -> Unit -): ValueAnimator { - //是否需要反序 - var reverse = false - val animator = ValueAnimator.ofFloat(0f, 1f) - animator.addUpdateListener { animation -> - val section = colorList.size() - if (section <= 1) { - onUpdate(animation, colorList[0]) - } else { - //每一段能运行的时间 - val sectionTime = duration / (section - 1) - //当前在那一段 - val time = animation.currentPlayTime * 1f % duration //取模调整时间 - val currentStep: Int = (time / sectionTime).floor().toInt() - - //获取需要变化的颜色 - val startColor: Int - val endColor: Int - if (reverse) { - val startIndex = section - currentStep - 1 - endColor = colorList[startIndex] - startColor = colorList.getOrNull(startIndex - 1) ?: colorList.first() - } else { - startColor = colorList[currentStep] - endColor = colorList.getOrNull(currentStep + 1) ?: colorList.last() - } - - //当前的进度 - val animatedValue = animation.animatedValue as Float - val sectionProgress = 1f / (section - 1) - val currentProgress: Float = - interpolator.getInterpolation(animatedValue % sectionProgress / sectionProgress) - - onUpdate(animation, evaluateColor(currentProgress, startColor, endColor)) - } - } - animator.addListener(object : RAnimatorListener() { - - override fun onAnimationRepeat(animation: Animator) { - super.onAnimationRepeat(animation) - if (animator.repeatMode == ValueAnimator.REVERSE) { - reverse = !reverse - } - } - - override fun _onAnimatorFinish(animator: Animator, fromCancel: Boolean) { - super._onAnimatorFinish(animator, fromCancel) - onEnd(fromCancel) - } - }) - animator.interpolator = LinearInterpolator() - animator.duration = duration - if (infinite) { - animator.repeatCount = ValueAnimator.INFINITE - animator.repeatMode = ValueAnimator.REVERSE - } - animator.config() - animator.start() - return animator -} - -/**背景变化动画*/ -fun View.bgColorAnimator( - fromColor: Int, - toColor: Int, - infinite: Boolean = false, - interpolator: Interpolator = LinearInterpolator(), - duration: Long = ANIM_DURATION, - onEnd: (cancel: Boolean) -> Unit = {}, - config: ValueAnimator.() -> Unit = {} -): ValueAnimator { - //背景动画 - return colorAnimator( - fromColor, - toColor, - infinite, - interpolator, - duration, - onEnd, - config - ) { _, color -> - setBackgroundColor(color) - } -} - /** * 抖动 放大缩小 */ @@ -416,50 +262,8 @@ fun View.scaleAnimator( ) { scaleX = fromX scaleY = fromY - animate() - .scaleX(toX) - .scaleY(toY) - .setInterpolator(interpolator) - .setDuration(ANIM_DURATION) - .withEndAction { onEnd() } - .start() -} - -/**[Matrix]改变动画*/ -fun matrixAnimator( - startMatrix: Matrix, - endMatrix: Matrix, - duration: Long = ANIM_DURATION, - interpolator: Interpolator? = DecelerateInterpolator(), - finish: (isCancel: Boolean) -> Unit = {}, - block: (Matrix) -> Unit -): ValueAnimator { - return ObjectAnimator.ofObject(MatrixEvaluator(), startMatrix, endMatrix).apply { - this.duration = duration - this.interpolator = interpolator - this.addUpdateListener { - block(it.animatedValue as Matrix) - } - this.addListener(onEnd = { finish(false) }, onCancel = { finish(true) }) - start() - } -} - -fun matrixAnimatorFraction( - startMatrix: Matrix, - endMatrix: Matrix, - duration: Long = ANIM_DURATION, - interpolator: Interpolator? = DecelerateInterpolator(), - block: (matrix: Matrix, fraction: Float) -> Unit -): ValueAnimator { - return ObjectAnimator.ofObject(MatrixEvaluator(), startMatrix, endMatrix).apply { - this.duration = duration - this.interpolator = interpolator - addUpdateListener { - block(it.animatedValue as Matrix, it.animatedFraction) - } - start() - } + animate().scaleX(toX).scaleY(toY).setInterpolator(interpolator).setDuration(ANIM_DURATION) + .withEndAction { onEnd() }.start() } /**[Rect]动画*/ @@ -499,76 +303,9 @@ fun rectAnimatorFraction( } } -/**clip动画, 从左到右展开显示 - * [com.angcyo.library.ex.AnimEx.clipBoundsAnimator] - * */ -@RequiresApi(Build.VERSION_CODES.LOLLIPOP) -fun View.clipBoundsAnimatorFromLeft( - start: Rect = Rect(0, 0, 0, mH()), - end: Rect = Rect(0, 0, mW(), mH()), - duration: Long = ANIM_DURATION, - interpolator: Interpolator = LinearInterpolator(), - onEndAction: () -> Unit = {} -): ObjectAnimator = clipBoundsAnimator(start, end, duration, interpolator, onEndAction) - -/**clip动画, 从右到左隐藏 - * [com.angcyo.library.ex.AnimEx.clipBoundsAnimator] - * */ -@RequiresApi(Build.VERSION_CODES.LOLLIPOP) -fun View.clipBoundsAnimatorFromRightHide( - start: Rect = Rect(0, 0, mW(), mH()), - end: Rect = Rect(0, 0, 0, mH()), - duration: Long = ANIM_DURATION, - interpolator: Interpolator = LinearInterpolator(), - onEndAction: () -> Unit = {} -): ObjectAnimator = clipBoundsAnimator(start, end, duration, interpolator, onEndAction) - -/**clip动画 - * [androidx.transition.ChangeClipBounds] - * */ -@RequiresApi(Build.VERSION_CODES.LOLLIPOP) -fun View.clipBoundsAnimator( - start: Rect = Rect(mW() / 2, mH() / 2, mW() / 2, mH() / 2), - end: Rect = Rect(0, 0, mW(), mH()), - duration: Long = ANIM_DURATION, - interpolator: Interpolator = LinearInterpolator(), - onEndAction: () -> Unit = {} -): ObjectAnimator { - ViewCompat.setClipBounds(this, start) - val evaluator = RectEvaluator(Rect()) - val animator: ObjectAnimator = ObjectAnimator.ofObject( - this, object : Property(Rect::class.java, "clipBounds") { - override fun get(view: View?): Rect? { - return ViewCompat.getClipBounds(view!!) - } - - override fun set(view: View?, clipBounds: Rect?) { - ViewCompat.setClipBounds(view!!, clipBounds) - } - }, - evaluator, start, end - ) - animator.addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator) { - ViewCompat.setClipBounds(this@clipBoundsAnimator, null) - if (end.width() <= 0 || end.height() <= 0) { - visibility = View.GONE - } - onEndAction() - } - }) - animator.duration = duration - animator.interpolator = interpolator - animator.start() - setAnimator(animator) - return animator -} - /**清空属性动画的相关属性*/ fun View.clearAnimatorProperty( - scale: Boolean = true, - translation: Boolean = true, - alpha: Boolean = true + scale: Boolean = true, translation: Boolean = true, alpha: Boolean = true ) { if (scale) { scaleX = 1f @@ -644,9 +381,7 @@ fun rotateCameraAnimator( * [to] 到多少角度 * */ fun View.rotateXAnimator( - from: Float = 0f, - to: Float = 180f, - config: AnimatorConfig.() -> Unit = { + from: Float = 0f, to: Float = 180f, config: AnimatorConfig.() -> Unit = { animatorDuration = 1_000 } ): ValueAnimator { @@ -666,9 +401,7 @@ fun View.rotateXAnimator( /**Y轴旋转动画*/ fun View.rotateYAnimator( - from: Float = 0f, - to: Float = 180f, - config: AnimatorConfig.() -> Unit = { + from: Float = 0f, to: Float = 180f, config: AnimatorConfig.() -> Unit = { animatorDuration = 1_000 } ): ValueAnimator { @@ -686,26 +419,6 @@ fun View.rotateYAnimator( } } -/**Y轴旋转动画*/ -fun View.rotateYAnimation( - from: Float = 0f, - to: Float = 180f, - config: YRotateAnimation.() -> Unit = { - duration = 1_000 - } -): Animation { - val animation = YRotateAnimation() - animation.from = from - animation.to = to - animation.repeatCount = ValueAnimator.INFINITE - animation.repeatMode = ValueAnimator.REVERSE - - animation.config() - - startAnimation(animation) - return animation -} - /**无限循环*/ fun Animation.infinite(mode: Int = ValueAnimator.RESTART) { //repeatMode = ValueAnimator.REVERSE diff --git a/dslitem/src/main/java/com/angcyo/item/LibEx.kt b/dslitem/src/main/java/com/angcyo/item/LibEx.kt index 3cec3ce..eda960b 100644 --- a/dslitem/src/main/java/com/angcyo/item/LibEx.kt +++ b/dslitem/src/main/java/com/angcyo/item/LibEx.kt @@ -1,8 +1,12 @@ package com.angcyo.item import android.content.Context +import android.graphics.Canvas import android.graphics.Paint +import android.graphics.Rect +import android.graphics.RectF import android.graphics.drawable.Drawable +import android.os.Build import android.os.Handler import android.os.Looper import android.text.InputFilter @@ -87,10 +91,7 @@ fun TextView.setLeftIco(id: Int) { fun TextView.setLeftIco(drawable: Drawable?) { val compoundDrawables: Array = compoundDrawables setCompoundDrawablesWithIntrinsicBounds( - drawable, - compoundDrawables[1], - compoundDrawables[2], - compoundDrawables[3] + drawable, compoundDrawables[1], compoundDrawables[2], compoundDrawables[3] ) } @@ -101,10 +102,7 @@ fun TextView.setRightIco(@DrawableRes id: Int) { fun TextView.setRightIco(drawable: Drawable?) { val compoundDrawables: Array = compoundDrawables setCompoundDrawablesWithIntrinsicBounds( - compoundDrawables[0], - compoundDrawables[1], - drawable, - compoundDrawables[3] + compoundDrawables[0], compoundDrawables[1], drawable, compoundDrawables[3] ) } @@ -163,8 +161,7 @@ fun TextView?.string(trim: Boolean = true): String { /**只要文本改变就通知*/ fun EditText.onTextChange( - defaultText: CharSequence? = string(), - shakeDelay: Long = -1L,//去频限制, 负数表示不开启 + defaultText: CharSequence? = string(), shakeDelay: Long = -1L,//去频限制, 负数表示不开启 listener: (CharSequence) -> Unit ) { addTextChangedListener(object : SingleTextWatcher() { @@ -208,8 +205,7 @@ fun Any?.getMember(member: String): Any? { } fun Any?.getMember( - cls: Class<*>, - member: String + cls: Class<*>, member: String ): Any? { var result: Any? = null try { @@ -415,8 +411,31 @@ fun EditText.restoreSelection(start: Int, stop: Int) { } } -fun Collection<*>?.size() = this?.size ?: 0 +fun View.save(canvas: Canvas, paint: Paint? = null): Int { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + canvas.saveLayer(0f, 0f, width.toFloat(), height.toFloat(), paint) + } else { + canvas.saveLayer( + 0f, 0f, width.toFloat(), height.toFloat(), paint, Canvas.ALL_SAVE_FLAG + ) + } +} + +fun View.viewRect(result: RectF = RectF()): RectF { + result.set(0f, 0f, measuredWidth.toFloat(), measuredHeight.toFloat()) + return result +} +fun View.viewRect(result: Rect = Rect()): Rect { + result.set(0, 0, measuredWidth, measuredHeight) + return result +} + +fun View.drawRect(rect: Rect) { + rect.set(paddingLeft, paddingTop, measuredWidth - paddingRight, measuredHeight - paddingBottom) +} + +fun Collection<*>?.size() = this?.size ?: 0 /**判断2个列表中的数据是否改变过*/ fun Collection?.isChange(other: List?): Boolean { diff --git a/dslitem/src/main/java/com/angcyo/item/base/RAnimationListener.kt b/dslitem/src/main/java/com/angcyo/item/base/RAnimationListener.kt new file mode 100644 index 0000000..8cb68a1 --- /dev/null +++ b/dslitem/src/main/java/com/angcyo/item/base/RAnimationListener.kt @@ -0,0 +1,21 @@ +package com.angcyo.item.base + +import android.view.animation.Animation + +/** + * + * Email:angcyo@126.com + * @author angcyo + * @date 2019/12/31 + * Copyright (c) 2019 ShenZhen O&M Cloud Co., Ltd. All rights reserved. + */ +open class RAnimationListener : Animation.AnimationListener { + override fun onAnimationRepeat(animation: Animation) { + } + + override fun onAnimationEnd(animation: Animation) { + } + + override fun onAnimationStart(animation: Animation) { + } +} \ No newline at end of file diff --git a/dslitem2/build.gradle b/dslitem2/build.gradle index 1e75885..ec6f7f7 100644 --- a/dslitem2/build.gradle +++ b/dslitem2/build.gradle @@ -23,4 +23,7 @@ dependencies { //https://github.com/angcyo/ViewPagerLayoutManager //api 'rouchuan.viewpagerlayoutmanager:viewpagerlayoutmanager:2.0.22' api 'com.github.angcyo:ViewPagerLayoutManager:2.1.3' + + //https://mvnrepository.com/artifact/androidx.appcompat/appcompat + implementation 'androidx.appcompat:appcompat:1.6.1' } diff --git a/dslitem2/src/main/java/com/angcyo/item2/DslBannerItem.kt b/dslitem2/src/main/java/com/angcyo/item2/DslBannerItem.kt index 2de5554..65ff958 100644 --- a/dslitem2/src/main/java/com/angcyo/item2/DslBannerItem.kt +++ b/dslitem2/src/main/java/com/angcyo/item2/DslBannerItem.kt @@ -1,5 +1,6 @@ package com.angcyo.item2 +import android.widget.LinearLayout import androidx.recyclerview.widget.RecyclerView import com.angcyo.dsladapter.DslAdapterItem import com.angcyo.dsladapter.DslViewHolder @@ -33,6 +34,8 @@ open class DslBannerItem : DslNestedRecyclerItem() { maxAlpha = 1f minAlpha = 1f } + + itemHeight = LinearLayout.LayoutParams.WRAP_CONTENT } val pagerLayoutManager: ViewPagerLayoutManager? @@ -46,11 +49,7 @@ open class DslBannerItem : DslNestedRecyclerItem() { payloads: List ) { super.onBindNestedRecyclerView( - recyclerView, - itemHolder, - itemPosition, - adapterItem, - payloads + recyclerView, itemHolder, itemPosition, adapterItem, payloads ) val drawableIndicator: DrawableIndicator? = itemHolder.v(R.id.lib_drawable_indicator) diff --git a/dslitem2/src/main/java/com/angcyo/item2/ILoopAdapterItem.kt b/dslitem2/src/main/java/com/angcyo/item2/ILoopAdapterItem.kt new file mode 100644 index 0000000..ccea4d6 --- /dev/null +++ b/dslitem2/src/main/java/com/angcyo/item2/ILoopAdapterItem.kt @@ -0,0 +1,17 @@ +package com.angcyo.item2 + +import com.angcyo.dsladapter.item.IDslItem +import com.leochuan.AutoPlaySnapHelper + +/** + * + * Email:angcyo@126.com + * @author angcyo + * @date 2020/03/18 + * Copyright (c) 2019 ShenZhen O&M Cloud Co., Ltd. All rights reserved. + */ +interface ILoopAdapterItem : IDslItem { + + /**获取轮播图循环间隔时长, 毫秒*/ + fun getLoopInterval(): Int = AutoPlaySnapHelper.TIME_INTERVAL +} \ No newline at end of file diff --git a/dslitem2/src/main/java/com/angcyo/item2/widget/recycler/LoopRecyclerView.kt b/dslitem2/src/main/java/com/angcyo/item2/widget/recycler/LoopRecyclerView.kt index 66f9303..fe557fa 100644 --- a/dslitem2/src/main/java/com/angcyo/item2/widget/recycler/LoopRecyclerView.kt +++ b/dslitem2/src/main/java/com/angcyo/item2/widget/recycler/LoopRecyclerView.kt @@ -4,7 +4,6 @@ import android.content.Context import android.util.AttributeSet import android.view.MotionEvent import android.view.View -import com.angcyo.github.widget.recycler.LoopSnapHelper import com.angcyo.item2.R import com.angcyo.widget.recycler.DslRecyclerView import com.leochuan.AutoPlaySnapHelper diff --git a/dslitem2/src/main/java/com/angcyo/item2/widget/recycler/LoopSnapHelper.kt b/dslitem2/src/main/java/com/angcyo/item2/widget/recycler/LoopSnapHelper.kt index 53e325a..fc2471d 100644 --- a/dslitem2/src/main/java/com/angcyo/item2/widget/recycler/LoopSnapHelper.kt +++ b/dslitem2/src/main/java/com/angcyo/item2/widget/recycler/LoopSnapHelper.kt @@ -1,10 +1,10 @@ -package com.angcyo.github.widget.recycler +package com.angcyo.item2.widget.recycler import android.view.animation.DecelerateInterpolator import android.view.animation.Interpolator import androidx.recyclerview.widget.RecyclerView import com.angcyo.dsladapter.DslAdapter -import com.angcyo.github.dslitem.ILoopAdapterItem +import com.angcyo.item2.ILoopAdapterItem import com.leochuan.AutoPlaySnapHelper import com.leochuan.ViewPagerLayoutManager @@ -15,8 +15,7 @@ import com.leochuan.ViewPagerLayoutManager * @date 2020/03/18 * Copyright (c) 2019 ShenZhen O&M Cloud Co., Ltd. All rights reserved. */ -class LoopSnapHelper(val interval: Int, direction: Int) : - AutoPlaySnapHelper(interval, direction) { +class LoopSnapHelper(val interval: Int, direction: Int) : AutoPlaySnapHelper(interval, direction) { var loopInterpolator: Interpolator? = DecelerateInterpolator() diff --git a/dslitem2/src/main/res/values/attr_border_view.xml b/dslitem2/src/main/res/values/attr_border_view.xml new file mode 100644 index 0000000..c871289 --- /dev/null +++ b/dslitem2/src/main/res/values/attr_border_view.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dslitem2/src/main/res/values/item2_colors.xml b/dslitem2/src/main/res/values/item2_values.xml similarity index 100% rename from dslitem2/src/main/res/values/item2_colors.xml rename to dslitem2/src/main/res/values/item2_values.xml