Skip to content

Commit

Permalink
preload (#93)
Browse files Browse the repository at this point in the history
* preload

* refactor

* Update ktlint.gradle

* Update ktlint.gradle

* Update ktlint.gradle

* fix gradle

* update license

* update

* apiDump

* update

* update
  • Loading branch information
hoc081098 authored Aug 3, 2022
1 parent f5aec34 commit d56690e
Show file tree
Hide file tree
Showing 36 changed files with 495 additions and 149 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true
[*]
indent_size=2
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
insert_final_newline=true
[*.{kt, kts}]
ij_kotlin_imports_layout=*
disabled_rules=filename
[*.xml]
indent_size=4
2 changes: 1 addition & 1 deletion .idea/copyright/MIT_License.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

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

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,4 @@ Since version `1.2.0`, `minSdkVersion` has been changed to `14`.

MIT License

Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package="com.hoc081098.example">

<application
android:name=".MyApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hoc081098/example/DemoAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/com/hoc081098/example/DemoDialogFragment.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -27,6 +27,7 @@ package com.hoc081098.example
import android.app.Dialog
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.FragmentManager
import com.hoc081098.example.databinding.DialogFragmentDemoBinding
Expand All @@ -52,9 +53,16 @@ class DemoDialogFragment : DefaultViewBindingDialogFragment() {
.create()
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
access()
}

override fun onResume() {
super.onResume()
access()
}

private fun access() {
Log.d("###", viewBinding.toString())
Log.d("###", viewBinding.textInputLayout.toString())

Expand Down
48 changes: 48 additions & 0 deletions app/src/main/java/com/hoc081098/example/MyApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* MIT License
*
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.hoc081098.example

import android.app.Application
import com.hoc081098.example.databinding.FragmentFourthBinding
import com.hoc081098.example.databinding.FragmentThirdBinding
import com.hoc081098.example.databinding.FragmentThirdIncludeBinding
import com.hoc081098.example.databinding.ItemRecyclerBinding
import com.hoc081098.viewbindingdelegate.preloadBindMethods
import com.hoc081098.viewbindingdelegate.preloadInflateMethods

class MyApp : Application() {
override fun onCreate() {
super.onCreate()

preloadBindMethods(
FragmentThirdBinding::class,
FragmentThirdIncludeBinding::class,
FragmentFourthBinding::class
)
preloadInflateMethods(
ItemRecyclerBinding::class
)
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/font/noto_sans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
~ MIT License
~
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_third.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ MIT License
~
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/dialog_fragment_demo.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ MIT License
~
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_recycler.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ MIT License
~
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_recycler_merge.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ MIT License
~
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/font_certs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
~ MIT License
~
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/preloaded_fonts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
~ MIT License
~
~ Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
~ Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.jmailen.gradle:kotlinter-gradle:3.9.0'
classpath 'org.jmailen.gradle:kotlinter-gradle:3.11.1'
classpath 'org.jetbrains.kotlinx:binary-compatibility-validator:0.11.0'
classpath "com.autonomousapps.dependency-analysis:com.autonomousapps.dependency-analysis.gradle.plugin:1.12.0"

Expand Down
5 changes: 2 additions & 3 deletions ktlint.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: 'org.jmailen.kotlinter'

kotlinter {
indentSize = 2
experimentalRules = true
}
experimentalRules = true
}
14 changes: 11 additions & 3 deletions library/api/library.api
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public final class com/hoc081098/viewbindingdelegate/ExtensionsKt {
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;
}

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

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

public final class com/hoc081098/viewbindingdelegate/internal/CacheKt {
public static final fun getInflateMethod (Ljava/lang/Class;)Ljava/lang/reflect/Method;
}

public final class com/hoc081098/viewbindingdelegate/internal/UtilsKt {
public static final fun ensureMainThread ()V
}

4 changes: 3 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlin.explicitApi = 'strict'
kotlin {
explicitApi()
}
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += '-Xexplicit-api=strict'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -27,12 +27,12 @@ package com.hoc081098.viewbindingdelegate
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.hoc081098.viewbindingdelegate.test.R as TestR
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertSame
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import com.hoc081098.viewbindingdelegate.test.R as TestR

@RunWith(AndroidJUnit4::class)
public class ActivityViewBindingExtensionsTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -27,11 +27,11 @@ package com.hoc081098.viewbindingdelegate
import androidx.fragment.app.testing.launchFragment
import androidx.lifecycle.Lifecycle
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.hoc081098.viewbindingdelegate.test.R as TestR
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertSame
import org.junit.Test
import org.junit.runner.RunWith
import com.hoc081098.viewbindingdelegate.test.R as TestR

@RunWith(AndroidJUnit4::class)
public class FragmentViewBindingExtensionsTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,8 +25,8 @@
package com.hoc081098.viewbindingdelegate

import androidx.appcompat.app.AppCompatActivity
import com.hoc081098.viewbindingdelegate.test.databinding.ActivityTestBinding
import com.hoc081098.viewbindingdelegate.test.R as TestR
import com.hoc081098.viewbindingdelegate.test.databinding.ActivityTestBinding

public class TestActivity : AppCompatActivity(TestR.layout.activity_test) {
internal val bindingReflection: ActivityTestBinding by viewBinding()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2020-2021 Petrus Nguyễn Thái Học
* Copyright (c) 2020-2022 Petrus Nguyễn Thái Học
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,8 +25,8 @@
package com.hoc081098.viewbindingdelegate

import androidx.fragment.app.Fragment
import com.hoc081098.viewbindingdelegate.test.databinding.FragmentTestBinding
import com.hoc081098.viewbindingdelegate.test.R as TestR
import com.hoc081098.viewbindingdelegate.test.databinding.FragmentTestBinding

public class TestFragment : Fragment(TestR.layout.fragment_test) {
internal val bindingReflection: FragmentTestBinding by viewBinding()
Expand Down
Loading

0 comments on commit d56690e

Please sign in to comment.