Skip to content

Commit 3adb7cf

Browse files
authored
Merge pull request #5 from Devlight/feature/release_1_0_3
release 1.0.3 pull request
2 parents 9d4d582 + ca9d7d2 commit 3adb7cf

File tree

5 files changed

+56
-53
lines changed

5 files changed

+56
-53
lines changed

app/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
plugins {
22
id 'com.android.application'
33
id 'kotlin-android'
4-
id 'kotlin-android-extensions'
54
}
65

76
android {
8-
compileSdkVersion 29
7+
compileSdkVersion 30
98

109
defaultConfig {
1110
applicationId "devlight.io.xtreeivi.cornercutlinearlayout.example"
1211
minSdkVersion 21
13-
targetSdkVersion 29
12+
targetSdkVersion 30
1413
versionCode 1
1514
versionName "1.0"
1615
}
@@ -28,12 +27,14 @@ android {
2827
kotlinOptions {
2928
jvmTarget = '1.8'
3029
}
30+
31+
buildFeatures {
32+
viewBinding true
33+
}
3134
}
3235

3336
dependencies {
3437
implementation project(':cornercutlinearlayout')
35-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
36-
implementation 'androidx.core:core-ktx:1.3.0-beta01'
37-
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
38-
implementation 'com.google.android.material:material:1.2.0-alpha05'
38+
implementation "androidx.core:core-ktx:1.5.0-alpha05"
39+
implementation "com.google.android.material:material:1.3.0-alpha03"
3940
}

app/src/main/java/io/devlight/xtreeivi/sample/MainActivity.kt

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
44
import android.graphics.*
55
import android.os.Bundle
66
import android.os.Handler
7+
import android.os.Looper
78
import android.view.View
89
import android.view.ViewGroup
910
import android.view.animation.CycleInterpolator
@@ -13,20 +14,22 @@ import androidx.appcompat.app.AppCompatActivity
1314
import androidx.core.view.*
1415
import com.google.android.material.math.MathUtils
1516
import io.devlight.xtreeivi.cornercutlinearlayout.CornerCutLinearLayout
17+
import io.devlight.xtreeivi.sample.databinding.ActivityShowcaseBinding
1618
import io.devlight.xtreeivi.sample.extensions.*
17-
import kotlinx.android.synthetic.main.activity_showcase.*
1819
import kotlin.math.hypot
1920
import kotlin.math.min
2021
import kotlin.math.roundToInt
2122
import kotlin.math.sqrt
2223

2324
class MainActivity : AppCompatActivity() {
2425

25-
private val handler = Handler()
26+
private lateinit var viewBinding: ActivityShowcaseBinding
27+
28+
private val handler = Handler(Looper.getMainLooper())
2629
private lateinit var runnable: Runnable
2730
private val lineCountRunnable = object : Runnable {
2831
override fun run() {
29-
with(txt_showcase_custom_view_area_provider ?: return) {
32+
with(viewBinding.txtShowcaseCustomViewAreaProvider) {
3033
maxLines = maxLines.let {
3134
if ((it + 1) <= 5) it + 1
3235
else 1
@@ -38,14 +41,15 @@ class MainActivity : AppCompatActivity() {
3841

3942
override fun onCreate(savedInstanceState: Bundle?) {
4043
super.onCreate(savedInstanceState)
41-
setContentView(R.layout.activity_showcase)
44+
viewBinding = ActivityShowcaseBinding.inflate(layoutInflater)
45+
setContentView(viewBinding.root)
4246

4347
//region Custom Corner Cut
4448
val inset = resources.displayMetrics.density * 8
4549
val eyeRadius = resources.displayMetrics.density * 3
4650
val halfOpenMouthAngle = 35.0F
4751
val pacmanMouthPath = Path()
48-
ccll_showcase_custom_lt_rb.setCornerCutProvider { _, cutout, cutEdge, rectF ->
52+
viewBinding.ccllShowcaseCustomLtRb.setCornerCutProvider { _, cutout, cutEdge, rectF ->
4953
when (cutEdge) {
5054
CornerCutLinearLayout.CornerCutFlag.START_TOP -> {
5155
rectF.inset(inset, inset)
@@ -99,7 +103,7 @@ class MainActivity : AppCompatActivity() {
99103
var lastMillis = -1L
100104
var isClockwise = true
101105
val rotationDuration = 2000L
102-
ccll_showcase_custom_lt_exceed_bounds.setCornerCutProvider(
106+
viewBinding.ccllShowcaseCustomLtExceedBounds.setCornerCutProvider(
103107
{ view, _, _, _ ->
104108
val matrix = Matrix()
105109
val pb = view.paddedBounds
@@ -142,15 +146,15 @@ class MainActivity : AppCompatActivity() {
142146
currentRotationAngle = maxMouthOpenHalfAngle
143147
isClockwise = false
144148
}
145-
ccll_showcase_custom_lt_exceed_bounds?.invalidateCornerCutPath()
149+
viewBinding.ccllShowcaseCustomLtExceedBounds.invalidateCornerCutPath()
146150
handler.removeCallbacks(this)
147151
handler.postDelayed(this, 32L)
148152
}
149153
}
150154
//endregion
151155

152156
//region Custom Child Corner Cut
153-
ccll_showcase_custom_child_cut_provider.setChildCornerCutProvider { view, cutout, _, rectF, _, _ ->
157+
viewBinding.ccllShowcaseCustomChildCutProvider.setChildCornerCutProvider { view, cutout, _, rectF, _, _ ->
154158
//rectF.inset(-40.0F, 0.0F)
155159
cutout.moveTo(rectF.centerX(), rectF.top)
156160
cutout.arcTo(
@@ -187,7 +191,7 @@ class MainActivity : AppCompatActivity() {
187191
true
188192
}
189193

190-
ccll_showcase_custom_child_cut_provider_mixed.setChildCornerCutProvider(
194+
viewBinding.ccllShowcaseCustomChildCutProviderMixed.setChildCornerCutProvider(
191195
{ _: CornerCutLinearLayout, _: Path, cutSide: Int, rectF: RectF, _: View?, _: View? ->
192196
val matrix = Matrix()
193197
when (cutSide) {
@@ -251,7 +255,7 @@ class MainActivity : AppCompatActivity() {
251255
}
252256
)
253257

254-
ccll_showcase_custom_view_area_provider.setCustomViewAreaProvider { view, path, rectF ->
258+
viewBinding.ccllShowcaseCustomViewAreaProvider.setCustomViewAreaProvider { view, path, rectF ->
255259
val offset = view[0].marginEnd
256260
val cornerRadius = rectF.height() / 4.0F
257261
val tailCircleRadius = cornerRadius / 2.0F
@@ -321,7 +325,7 @@ class MainActivity : AppCompatActivity() {
321325
val tempPath = Path()
322326
val tempRectF = RectF()
323327

324-
ccll_showcase_custom_view_area_provider_2.setCustomViewAreaProvider { view, path, _ ->
328+
viewBinding.ccllShowcaseCustomViewAreaProvider2.setCustomViewAreaProvider { view, path, _ ->
325329
view.forEach {
326330
tempPath.rewind()
327331
if (it is CornerCutLinearLayout) {
@@ -352,7 +356,7 @@ class MainActivity : AppCompatActivity() {
352356
}
353357
}
354358

355-
ccll_showcase_custom_view_area_provider_2_child_1.addCustomCutoutProvider { _, cutout, rectF ->
359+
viewBinding.ccllShowcaseCustomViewAreaProvider2Child1.addCustomCutoutProvider { _, cutout, rectF ->
356360
val width = rectF.width()
357361
val height = rectF.height()
358362
cutout.moveTo(rectF.centerX(), rectF.top)
@@ -371,7 +375,7 @@ class MainActivity : AppCompatActivity() {
371375
val waveLineHeight = resources.getDimension(R.dimen.offset_48)
372376
val halfWaveLineHeight = waveLineHeight / 2.0F
373377
val halfWaveLineCutWidth = waveLineCutWidth / 2.0F
374-
ccll_showcase_custom_view_area_provider_2.addCustomCutoutProvider { _, cutout, rectF ->
378+
viewBinding.ccllShowcaseCustomViewAreaProvider2.addCustomCutoutProvider { _, cutout, rectF ->
375379
cutout.moveTo(rectF.left, rectF.centerY() - halfWaveLineCutWidth)
376380
cutout.lineTo(
377381
rectF.left + rectF.width() / 4.0F,
@@ -396,7 +400,7 @@ class MainActivity : AppCompatActivity() {
396400
}
397401

398402

399-
ccll_showcase_custom_view_area_provider_2.doOnNonNullSizeLayout {
403+
viewBinding.ccllShowcaseCustomViewAreaProvider2.doOnNonNullSizeLayout {
400404
val firstChild = it[0]
401405
val lastChild = it[2]
402406
val middleChild = it[1]
@@ -442,7 +446,7 @@ class MainActivity : AppCompatActivity() {
442446
.setInterpolator(CycleInterpolator(0.5F))
443447
.setDuration(4000L)
444448
.setUpdateListener {
445-
ccll_showcase_custom_view_area_provider_2.invalidateCornerCutPath()
449+
viewBinding.ccllShowcaseCustomViewAreaProvider2.invalidateCornerCutPath()
446450
}
447451
.withEndAction {
448452
animateLastChild()
@@ -456,33 +460,33 @@ class MainActivity : AppCompatActivity() {
456460
//endregion
457461

458462
//region Cut Properties
459-
ccll_showcase_depth_and_length.doOnNonNullSizeLayout {
463+
viewBinding.ccllShowcaseDepthAndLength.doOnNonNullSizeLayout {
460464
val depth =
461-
(ccll_showcase_depth_and_length.width - ccll_showcase_depth_and_length.paddingEnd - ccll_showcase_depth_and_length.childEndSideCornerCutDepth / 2.0F).roundToInt()
462-
v_showcase_bounds_depth_offset?.updateLayoutParams<FrameLayout.LayoutParams> {
465+
(viewBinding.ccllShowcaseDepthAndLength.width - viewBinding.ccllShowcaseDepthAndLength.paddingEnd - viewBinding.ccllShowcaseDepthAndLength.childEndSideCornerCutDepth / 2.0F).roundToInt()
466+
viewBinding.vShowcaseBoundsDepthOffset.updateLayoutParams<FrameLayout.LayoutParams> {
463467
marginStart = depth
464468
}
465469
}
466470

467-
ccll_showcase_depth_and_length_offset.doOnNonNullSizeLayout {
468-
ccll_showcase_depth_and_length_offset.childEndSideCornerCutDepthOffset =
471+
viewBinding.ccllShowcaseDepthAndLengthOffset.doOnNonNullSizeLayout {
472+
viewBinding.ccllShowcaseDepthAndLengthOffset.childEndSideCornerCutDepthOffset =
469473
it.paddedBounds.width() - it.childStartSideCornerCutDepth
470474
}
471475

472-
v_showcase_max_cut.duplicateViewSizeContinuously(
473-
ccll_showcase_max_cut,
474-
transformWidth = { (ccll_showcase_max_cut.paddedBounds.width() / 2).roundToInt() },
475-
transformHeight = { (ccll_showcase_max_cut.paddedBounds.height() / 2).roundToInt() },
476+
viewBinding.vShowcaseMaxCut.duplicateViewSizeContinuously(
477+
viewBinding.ccllShowcaseMaxCut,
478+
transformWidth = { (viewBinding.ccllShowcaseMaxCut.paddedBounds.width() / 2).roundToInt() },
479+
transformHeight = { (viewBinding.ccllShowcaseMaxCut.paddedBounds.height() / 2).roundToInt() },
476480
)
477481

478-
v_showcase_max_cut_equal.duplicateViewSizeContinuously(
479-
ccll_showcase_max_cut_equal,
482+
viewBinding.vShowcaseMaxCutEqual.duplicateViewSizeContinuously(
483+
viewBinding.ccllShowcaseMaxCutEqual,
480484
transformWidth = {
481-
ccll_showcase_max_cut_equal.paddedBounds.let { min(it.width(), it.height()) / 2 }
485+
viewBinding.ccllShowcaseMaxCutEqual.paddedBounds.let { min(it.width(), it.height()) / 2 }
482486
.roundToInt()
483487
},
484488
transformHeight = {
485-
ccll_showcase_max_cut_equal.paddedBounds.let { min(it.width(), it.height()) / 2 }
489+
viewBinding.ccllShowcaseMaxCutEqual.paddedBounds.let { min(it.width(), it.height()) / 2 }
486490
.roundToInt()
487491
},
488492
)
@@ -514,8 +518,8 @@ class MainActivity : AppCompatActivity() {
514518
playAnimation()
515519
}
516520
}
517-
ccll_showcase_max_cut.doOnNonNullSizeLayout(action)
518-
ccll_showcase_max_cut_equal.doOnNonNullSizeLayout(action)
521+
viewBinding.ccllShowcaseMaxCut.doOnNonNullSizeLayout(action)
522+
viewBinding.ccllShowcaseMaxCutEqual.doOnNonNullSizeLayout(action)
519523
//endregion
520524

521525
//region Custom Divider
@@ -548,9 +552,9 @@ class MainActivity : AppCompatActivity() {
548552
diamondDotDividerPath.close()
549553
diamondDotDividerPath.offset(-triangleBaseWidth / 2.0F, 0.0F)
550554

551-
ccll_showcase_custom_divider_provider.doOnNonNullSizeLayout {
552-
val pb = ccll_showcase_custom_divider_provider.paddedBounds
553-
ccll_showcase_custom_divider_provider.customDividerProviderPaint.shader =
555+
viewBinding.ccllShowcaseCustomDividerProvider.doOnNonNullSizeLayout {
556+
val pb = viewBinding.ccllShowcaseCustomDividerProvider.paddedBounds
557+
viewBinding.ccllShowcaseCustomDividerProvider.customDividerProviderPaint.shader =
554558
RadialGradient(
555559
pb.centerX(),
556560
pb.centerY(),
@@ -561,7 +565,7 @@ class MainActivity : AppCompatActivity() {
561565
)
562566
}
563567

564-
ccll_showcase_custom_divider_provider.setCustomDividerProvider { _, dividerPath, dividerPaint, showDividerFlag, dividerTypeIndex, rectF ->
568+
viewBinding.ccllShowcaseCustomDividerProvider.setCustomDividerProvider { _, dividerPath, dividerPaint, showDividerFlag, dividerTypeIndex, rectF ->
565569
when (showDividerFlag) {
566570
CornerCutLinearLayout.CustomDividerShowFlag.CONTAINER_BEGINNING -> {
567571
dividerPaint.style = Paint.Style.STROKE
@@ -632,7 +636,7 @@ class MainActivity : AppCompatActivity() {
632636
true
633637
)
634638

635-
ccll_showcase_custom_divider_provider_mixed.setCustomDividerProvider { _, dividerPath, dividerPaint, showDividerFlag, dividerTypeIndex, rectF ->
639+
viewBinding.ccllShowcaseCustomDividerProviderMixed.setCustomDividerProvider { _, dividerPath, dividerPaint, showDividerFlag, dividerTypeIndex, rectF ->
636640
when (showDividerFlag) {
637641
CornerCutLinearLayout.CustomDividerShowFlag.MIDDLE -> {
638642
dividerPaint.style = Paint.Style.STROKE
@@ -753,9 +757,7 @@ class MainActivity : AppCompatActivity() {
753757

754758
override fun onPause() {
755759
super.onPause()
756-
if (::runnable.isInitialized) {
757-
handler.removeCallbacks(runnable)
758-
}
760+
if (::runnable.isInitialized) handler.removeCallbacks(runnable)
759761
handler.removeCallbacks(lineCountRunnable)
760762
}
761763
}

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
3-
ext.kotlin_version = "1.4-M1"
3+
ext.kotlin_version = "1.4.20-RC"
44
repositories {
55
google()
66
jcenter()
77
maven { url = "https://dl.bintray.com/kotlin/kotlin-eap" }
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:4.1.0-alpha05'
10+
classpath "com.android.tools.build:gradle:4.2.0-alpha16"
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

cornercutlinearlayout/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
plugins {
22
id 'com.android.library'
33
id 'kotlin-android'
4-
id 'kotlin-android-extensions'
54
}
65

76
android {
8-
compileSdkVersion 29
7+
compileSdkVersion 30
98

109
defaultConfig {
1110
minSdkVersion 21
12-
targetSdkVersion 29
11+
targetSdkVersion 30
1312
versionCode 1
1413
versionName "1.0"
1514

@@ -22,17 +21,18 @@ android {
2221
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2322
}
2423
}
24+
2525
compileOptions {
2626
sourceCompatibility JavaVersion.VERSION_1_8
2727
targetCompatibility JavaVersion.VERSION_1_8
2828
}
29+
2930
kotlinOptions {
3031
jvmTarget = '1.8'
3132
}
3233
}
3334

3435
dependencies {
3536
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
36-
implementation 'androidx.core:core-ktx:1.3.0-alpha02'
37-
implementation 'androidx.appcompat:appcompat:1.2.0-alpha03'
37+
implementation "androidx.core:core-ktx:1.5.0-alpha05"
3838
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

0 commit comments

Comments
 (0)