From ecb80edf7c981fb0a57c4c9cc137a713ed90370f Mon Sep 17 00:00:00 2001 From: JiangSong Date: Thu, 1 Nov 2018 19:40:19 +0800 Subject: [PATCH] change minSdkVersion to 14 --- build.gradle | 2 +- .../main/java/com/loopeer/shadow/ShadowView.kt | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index a8febf8..7ebf5db 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ ext { configs = [ compileSdkVersion: 27, buildToolsVersion: '27.0.2', - minSdkVersion : 17, + minSdkVersion : 14, targetSdkVersion : 27, versionCode : 1, versionName : '1.0.0', diff --git a/shadow/src/main/java/com/loopeer/shadow/ShadowView.kt b/shadow/src/main/java/com/loopeer/shadow/ShadowView.kt index 8756532..c9594de 100644 --- a/shadow/src/main/java/com/loopeer/shadow/ShadowView.kt +++ b/shadow/src/main/java/com/loopeer/shadow/ShadowView.kt @@ -7,6 +7,7 @@ import android.graphics.drawable.Drawable import android.graphics.drawable.RippleDrawable import android.os.Build import android.support.v4.content.ContextCompat +import android.support.v4.view.ViewCompat import android.util.AttributeSet import android.view.Gravity import android.view.View @@ -16,10 +17,12 @@ import android.widget.FrameLayout open class ShadowView @JvmOverloads constructor(context: Context?, attributeSet: AttributeSet? = null, defStyleInt: Int = 0) : ViewGroup(context, attributeSet, defStyleInt) { - private val DEFAULT_CHILD_GRAVITY = Gravity.TOP or Gravity.START + companion object { + private const val DEFAULT_CHILD_GRAVITY = Gravity.TOP or Gravity.START + private const val SIZE_UNSET = -1 + private const val SIZE_DEFAULT = 0 + } - private var SIZE_UNSET = -1 - private var SIZE_DEFAULT = 0 private var foregroundDraw: Drawable? = null private val selfBounds = Rect() private val overlayBounds = Rect() @@ -141,7 +144,7 @@ open class ShadowView @JvmOverloads constructor(context: Context?, attributeSet: bgPaint.style = Paint.Style.FILL setLayerType(LAYER_TYPE_SOFTWARE, null) setWillNotDraw(false) - background = null + ViewCompat.setBackground(this, null) } private fun updatePaintShadow() { @@ -173,7 +176,7 @@ open class ShadowView @JvmOverloads constructor(context: Context?, attributeSet: heightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, MeasureSpec.EXACTLY) } val child = getChildAt(0) - if (child.visibility !== View.GONE) { + if (child.visibility != View.GONE) { measureChildWithMargins(child, widthSpec, 0, heightSpec, 0) val lp = child.layoutParams as LayoutParams maxWidth = @@ -240,7 +243,7 @@ open class ShadowView @JvmOverloads constructor(context: Context?, attributeSet: gravity = DEFAULT_CHILD_GRAVITY } - val layoutDirection = layoutDirection + val layoutDirection = ViewCompat.getLayoutDirection(this) val absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection) val verticalGravity = gravity and Gravity.VERTICAL_GRAVITY_MASK