Skip to content

Commit 8b74af9

Browse files
Update build.gradle
1 parent a597749 commit 8b74af9

File tree

7 files changed

+60
-55
lines changed

7 files changed

+60
-55
lines changed

build.gradle

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
1-
2-
31
buildscript {
4-
ext.kotlin_version = '1.6.20'
2+
ext.buildConfig = [
3+
'versionCode' : 1,
4+
'versionName' : "1.0.0",
5+
'compileSdkVersion': 30,
6+
'minSdkVersion' : 14,
7+
'targetSdkVersion' : 30
8+
]
9+
ext {
10+
appCompatVersion = '1.3.1'
11+
constraintLayoutVersion = '2.1.1'
12+
coreVersion = '1.7.0-alpha01'
13+
espressoVersion = '3.4.0'
14+
glideVersion = '4.12.0'
15+
kotlinVersion = "1.5.31"
16+
lifecycleVersion = '2.4.0-alpha03'
17+
junitExtVersion = '1.1.3'
18+
junitVersion = '4.13.2'
19+
materialVersion = '1.4.0'
20+
viewBindingKTXVersion = '2.0.6'
21+
}
522
repositories {
623
google()
724
jcenter()
825
}
926
dependencies {
1027
classpath 'com.android.tools.build:gradle:4.2.1'
11-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
28+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1229
}
1330
}
1431

loadingstateview-ktx/build.gradle

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ plugins {
44
}
55

66
android {
7-
compileSdkVersion 31
7+
compileSdkVersion buildConfig.compileSdkVersion
88

99
defaultConfig {
10-
minSdkVersion 21
11-
targetSdkVersion 31
12-
13-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
10+
minSdkVersion buildConfig.minSdkVersion
1411
consumerProguardFiles "consumer-rules.pro"
1512
}
1613

@@ -28,11 +25,11 @@ android {
2825

2926
kotlinOptions {
3027
jvmTarget = '1.8'
31-
freeCompilerArgs += ['-module-name', "loading_state_view_ktx",]
28+
freeCompilerArgs += ['-module-name', "loading_state_view_ktx"]
3229
}
3330
}
3431

3532
dependencies {
3633
api project(':loadingstateview')
37-
implementation 'androidx.appcompat:appcompat:1.3.1'
34+
implementation "androidx.appcompat:appcompat:$appCompatVersion"
3835
}

loadingstateview/build.gradle

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
33

44
android {
5-
compileSdkVersion 30
5+
compileSdkVersion buildConfig.compileSdkVersion
66

77
defaultConfig {
8-
minSdkVersion 14
9-
targetSdkVersion 30
10-
versionCode 1
11-
versionName "1.0"
8+
minSdkVersion buildConfig.minSdkVersion
129
}
1310

1411
buildTypes {
@@ -29,12 +26,10 @@ android {
2926

3027
kotlinOptions {
3128
jvmTarget = '1.8'
32-
freeCompilerArgs += ['-module-name', "loading_state_view",]
29+
freeCompilerArgs += ['-module-name', "loading_state_view"]
3330
}
3431
}
3532

3633
dependencies {
37-
implementation fileTree(dir: 'libs', include: ['*.jar'])
38-
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
39-
implementation 'androidx.core:core-ktx:1.5.0'
34+
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
4035
}

loadingstateview/src/main/java/com/dylanc/loadingstateview/LoadingStateView.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import android.view.ViewGroup.LayoutParams.MATCH_PARENT
2525
import android.widget.FrameLayout
2626
import android.widget.LinearLayout
2727
import androidx.constraintlayout.widget.ConstraintLayout
28-
import androidx.core.view.updateLayoutParams
29-
import java.util.*
3028

3129
/**
3230
* @author Dylan Cai
@@ -172,10 +170,10 @@ class LoadingStateView @JvmOverloads constructor(
172170
val view = getView(viewType)
173171
(view.parent as? ViewGroup)?.removeView(view)
174172
if (parent is ConstraintLayout && viewType == ViewType.CONTENT) {
175-
view.updateLayoutParams {
176-
if (view.measuredWidth == 0) width = MATCH_PARENT
177-
if (view.measuredHeight == 0) height = MATCH_PARENT
178-
}
173+
val params = view.layoutParams
174+
if (view.measuredWidth == 0) params.width = MATCH_PARENT
175+
if (view.measuredHeight == 0) params.width = MATCH_PARENT
176+
view.layoutParams = params
179177
}
180178
contentParent.addView(view)
181179
currentView = view

sample-java/build.gradle

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33

44
android {
5-
compileSdkVersion 30
5+
compileSdkVersion buildConfig.compileSdkVersion
66

77
defaultConfig {
88
applicationId "com.dylanc.loadingstateview.sample.java"
9-
minSdkVersion 21
10-
targetSdkVersion 30
11-
versionCode 2
12-
versionName "1.0.1"
9+
minSdkVersion buildConfig.minSdkVersion
10+
targetSdkVersion buildConfig.targetSdkVersion
11+
versionCode buildConfig.versionCode
12+
versionName buildConfig.versionName
1313
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1414
}
1515

@@ -33,13 +33,11 @@ android {
3333
dependencies {
3434
implementation fileTree(dir: 'libs', include: ['*.jar'])
3535
implementation project(':loadingstateview')
36-
implementation 'androidx.appcompat:appcompat:1.3.1'
37-
implementation 'androidx.recyclerview:recyclerview:1.2.1'
38-
implementation 'androidx.cardview:cardview:1.0.0'
39-
implementation 'com.google.android.material:material:1.4.0'
40-
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
41-
implementation 'com.github.bumptech.glide:glide:4.12.0'
42-
testImplementation 'junit:junit:4.13.2'
43-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
44-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
36+
implementation "androidx.appcompat:appcompat:$appCompatVersion"
37+
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
38+
implementation "com.google.android.material:material:$materialVersion"
39+
implementation "com.github.bumptech.glide:glide:$glideVersion"
40+
testImplementation "junit:junit:$junitVersion"
41+
androidTestImplementation "androidx.test.ext:junit:$junitExtVersion"
42+
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
4543
}

sample-kotlin/build.gradle

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ plugins {
44
}
55

66
android {
7-
compileSdkVersion 30
7+
compileSdkVersion buildConfig.compileSdkVersion
88

99
defaultConfig {
1010
applicationId "com.dylanc.loadingstateview.sample.kotlin"
11-
minSdkVersion 21
12-
targetSdkVersion 30
13-
versionCode 1
14-
versionName "1.0"
15-
11+
minSdkVersion buildConfig.minSdkVersion
12+
targetSdkVersion buildConfig.targetSdkVersion
13+
versionCode buildConfig.versionCode
14+
versionName buildConfig.versionName
1615
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1716
}
1817

@@ -22,25 +21,28 @@ 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
}
33+
3234
viewBinding {
3335
enabled true
3436
}
3537
}
3638

3739
dependencies {
3840
implementation project(':loadingstateview-ktx')
39-
implementation 'androidx.appcompat:appcompat:1.3.1'
40-
implementation 'com.google.android.material:material:1.4.0'
41-
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
42-
implementation 'com.github.DylanCaiCoding.ViewBindingKTX:viewbinding-base:2.0.5'
43-
testImplementation 'junit:junit:4.13.2'
44-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
45-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
41+
implementation "androidx.appcompat:appcompat:$appCompatVersion"
42+
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
43+
implementation "com.google.android.material:material:$materialVersion"
44+
implementation "com.github.DylanCaiCoding.ViewBindingKTX:viewbinding-base:$viewBindingKTXVersion"
45+
testImplementation "junit:junit:$junitVersion"
46+
androidTestImplementation "androidx.test.ext:junit:$junitExtVersion"
47+
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
4648
}

sample-kotlin/src/main/java/com/dylanc/loadingstateview/sample/kotlin/ui/MainActivity.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,4 @@ class MainActivity : BaseBindingActivity<ActivityMainBinding>() {
4848
showContentView()
4949
}, 2000)
5050
}
51-
52-
override val isDecorated = false
5351
}

0 commit comments

Comments
 (0)