Skip to content

Commit d56690e

Browse files
authored
preload (#93)
* preload * refactor * Update ktlint.gradle * Update ktlint.gradle * Update ktlint.gradle * fix gradle * update license * update * apiDump * update * update
1 parent f5aec34 commit d56690e

36 files changed

+495
-149
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
[*]
3+
indent_size=2
4+
end_of_line=lf
5+
charset=utf-8
6+
trim_trailing_whitespace=true
7+
insert_final_newline=true
8+
[*.{kt, kts}]
9+
ij_kotlin_imports_layout=*
10+
disabled_rules=filename
11+
[*.xml]
12+
indent_size=4

.idea/copyright/MIT_License.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/deploymentTargetDropDown.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
3+
Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,4 @@ Since version `1.2.0`, `minSdkVersion` has been changed to `14`.
298298

299299
MIT License
300300

301-
Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
301+
Copyright (c) 2020-2022 Petrus Nguyễn Thái Học

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package="com.hoc081098.example">
44

55
<application
6+
android:name=".MyApp"
67
android:allowBackup="true"
78
android:icon="@mipmap/ic_launcher"
89
android:label="@string/app_name"

app/src/main/java/com/hoc081098/example/DemoAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
4+
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

app/src/main/java/com/hoc081098/example/DemoDialogFragment.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
4+
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -27,6 +27,7 @@ package com.hoc081098.example
2727
import android.app.Dialog
2828
import android.os.Bundle
2929
import android.util.Log
30+
import android.view.View
3031
import androidx.appcompat.app.AlertDialog
3132
import androidx.fragment.app.FragmentManager
3233
import com.hoc081098.example.databinding.DialogFragmentDemoBinding
@@ -52,9 +53,16 @@ class DemoDialogFragment : DefaultViewBindingDialogFragment() {
5253
.create()
5354
}
5455

56+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
57+
access()
58+
}
59+
5560
override fun onResume() {
5661
super.onResume()
62+
access()
63+
}
5764

65+
private fun access() {
5866
Log.d("###", viewBinding.toString())
5967
Log.d("###", viewBinding.textInputLayout.toString())
6068

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
package com.hoc081098.example
26+
27+
import android.app.Application
28+
import com.hoc081098.example.databinding.FragmentFourthBinding
29+
import com.hoc081098.example.databinding.FragmentThirdBinding
30+
import com.hoc081098.example.databinding.FragmentThirdIncludeBinding
31+
import com.hoc081098.example.databinding.ItemRecyclerBinding
32+
import com.hoc081098.viewbindingdelegate.preloadBindMethods
33+
import com.hoc081098.viewbindingdelegate.preloadInflateMethods
34+
35+
class MyApp : Application() {
36+
override fun onCreate() {
37+
super.onCreate()
38+
39+
preloadBindMethods(
40+
FragmentThirdBinding::class,
41+
FragmentThirdIncludeBinding::class,
42+
FragmentFourthBinding::class
43+
)
44+
preloadInflateMethods(
45+
ItemRecyclerBinding::class
46+
)
47+
}
48+
}

app/src/main/res/font/noto_sans.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
~ MIT License
44
~
5-
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
5+
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
66
~
77
~ Permission is hereby granted, free of charge, to any person obtaining a copy
88
~ of this software and associated documentation files (the "Software"), to deal

app/src/main/res/layout/activity_third.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?><!--
22
~ MIT License
33
~
4-
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
4+
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
55
~
66
~ Permission is hereby granted, free of charge, to any person obtaining a copy
77
~ of this software and associated documentation files (the "Software"), to deal

app/src/main/res/layout/dialog_fragment_demo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?><!--
22
~ MIT License
33
~
4-
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
4+
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
55
~
66
~ Permission is hereby granted, free of charge, to any person obtaining a copy
77
~ of this software and associated documentation files (the "Software"), to deal

app/src/main/res/layout/item_recycler.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?><!--
22
~ MIT License
33
~
4-
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
4+
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
55
~
66
~ Permission is hereby granted, free of charge, to any person obtaining a copy
77
~ of this software and associated documentation files (the "Software"), to deal

app/src/main/res/layout/item_recycler_merge.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?><!--
22
~ MIT License
33
~
4-
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
4+
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
55
~
66
~ Permission is hereby granted, free of charge, to any person obtaining a copy
77
~ of this software and associated documentation files (the "Software"), to deal

app/src/main/res/values/font_certs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
~ MIT License
44
~
5-
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
5+
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
66
~
77
~ Permission is hereby granted, free of charge, to any person obtaining a copy
88
~ of this software and associated documentation files (the "Software"), to deal

app/src/main/res/values/preloaded_fonts.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
~ MIT License
44
~
5-
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
5+
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
66
~
77
~ Permission is hereby granted, free of charge, to any person obtaining a copy
88
~ of this software and associated documentation files (the "Software"), to deal

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ buildscript {
99
dependencies {
1010
classpath "com.android.tools.build:gradle:7.2.1"
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12-
classpath 'org.jmailen.gradle:kotlinter-gradle:3.9.0'
12+
classpath 'org.jmailen.gradle:kotlinter-gradle:3.11.1'
1313
classpath 'org.jetbrains.kotlinx:binary-compatibility-validator:0.11.0'
1414
classpath "com.autonomousapps.dependency-analysis:com.autonomousapps.dependency-analysis.gradle.plugin:1.12.0"
1515

ktlint.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apply plugin: 'org.jmailen.kotlinter'
22

33
kotlinter {
4-
indentSize = 2
5-
experimentalRules = true
6-
}
4+
experimentalRules = true
5+
}

library/api/library.api

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public final class com/hoc081098/viewbindingdelegate/ExtensionsKt {
2020
public static synthetic fun viewBinding$default (Landroidx/fragment/app/Fragment;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/hoc081098/viewbindingdelegate/impl/FragmentViewBindingDelegate;
2121
}
2222

23-
public final class com/hoc081098/viewbindingdelegate/UtilsKt {
24-
public static final fun ensureMainThread ()V
25-
public static final fun getInflateMethod (Ljava/lang/Class;)Ljava/lang/reflect/Method;
23+
public final class com/hoc081098/viewbindingdelegate/PreloadKt {
24+
public static final fun preloadBindMethods (Landroid/content/Context;[Lkotlin/reflect/KClass;)V
25+
public static final fun preloadInflateMethods (Landroid/content/Context;[Lkotlin/reflect/KClass;)V
2626
}
2727

2828
public abstract interface class com/hoc081098/viewbindingdelegate/ViewBindingDialogFragment {
@@ -75,3 +75,11 @@ public final class com/hoc081098/viewbindingdelegate/impl/FragmentViewBindingDel
7575
public final fun from (Landroidx/fragment/app/Fragment;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lcom/hoc081098/viewbindingdelegate/impl/FragmentViewBindingDelegate;
7676
}
7777

78+
public final class com/hoc081098/viewbindingdelegate/internal/CacheKt {
79+
public static final fun getInflateMethod (Ljava/lang/Class;)Ljava/lang/reflect/Method;
80+
}
81+
82+
public final class com/hoc081098/viewbindingdelegate/internal/UtilsKt {
83+
public static final fun ensureMainThread ()V
84+
}
85+

library/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ android {
3434
sourceCompatibility JavaVersion.VERSION_1_8
3535
targetCompatibility JavaVersion.VERSION_1_8
3636
}
37-
kotlin.explicitApi = 'strict'
37+
kotlin {
38+
explicitApi()
39+
}
3840
kotlinOptions {
3941
jvmTarget = '1.8'
4042
freeCompilerArgs += '-Xexplicit-api=strict'

library/src/androidTest/java/com/hoc081098/viewbindingdelegate/ActivityViewBindingExtensionsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
4+
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -27,12 +27,12 @@ package com.hoc081098.viewbindingdelegate
2727
import androidx.test.ext.junit.rules.ActivityScenarioRule
2828
import androidx.test.ext.junit.rules.activityScenarioRule
2929
import androidx.test.ext.junit.runners.AndroidJUnit4
30+
import com.hoc081098.viewbindingdelegate.test.R as TestR
3031
import org.junit.Assert.assertNotNull
3132
import org.junit.Assert.assertSame
3233
import org.junit.Rule
3334
import org.junit.Test
3435
import org.junit.runner.RunWith
35-
import com.hoc081098.viewbindingdelegate.test.R as TestR
3636

3737
@RunWith(AndroidJUnit4::class)
3838
public class ActivityViewBindingExtensionsTest {

library/src/androidTest/java/com/hoc081098/viewbindingdelegate/FragmentViewBindingExtensionsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
4+
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -27,11 +27,11 @@ package com.hoc081098.viewbindingdelegate
2727
import androidx.fragment.app.testing.launchFragment
2828
import androidx.lifecycle.Lifecycle
2929
import androidx.test.ext.junit.runners.AndroidJUnit4
30+
import com.hoc081098.viewbindingdelegate.test.R as TestR
3031
import org.junit.Assert.assertNotNull
3132
import org.junit.Assert.assertSame
3233
import org.junit.Test
3334
import org.junit.runner.RunWith
34-
import com.hoc081098.viewbindingdelegate.test.R as TestR
3535

3636
@RunWith(AndroidJUnit4::class)
3737
public class FragmentViewBindingExtensionsTest {

library/src/androidTest/java/com/hoc081098/viewbindingdelegate/TestActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
4+
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -25,8 +25,8 @@
2525
package com.hoc081098.viewbindingdelegate
2626

2727
import androidx.appcompat.app.AppCompatActivity
28-
import com.hoc081098.viewbindingdelegate.test.databinding.ActivityTestBinding
2928
import com.hoc081098.viewbindingdelegate.test.R as TestR
29+
import com.hoc081098.viewbindingdelegate.test.databinding.ActivityTestBinding
3030

3131
public class TestActivity : AppCompatActivity(TestR.layout.activity_test) {
3232
internal val bindingReflection: ActivityTestBinding by viewBinding()

library/src/androidTest/java/com/hoc081098/viewbindingdelegate/TestFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
4+
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -25,8 +25,8 @@
2525
package com.hoc081098.viewbindingdelegate
2626

2727
import androidx.fragment.app.Fragment
28-
import com.hoc081098.viewbindingdelegate.test.databinding.FragmentTestBinding
2928
import com.hoc081098.viewbindingdelegate.test.R as TestR
29+
import com.hoc081098.viewbindingdelegate.test.databinding.FragmentTestBinding
3030

3131
public class TestFragment : Fragment(TestR.layout.fragment_test) {
3232
internal val bindingReflection: FragmentTestBinding by viewBinding()

0 commit comments

Comments
 (0)