diff --git a/CHANGELOG.md b/CHANGELOG.md index 44aea63..1f06d07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,23 @@ ##### Breaking +## 1.1.0 + +##### Enhancements + +* issue4 - Remove PMD + [isuPatches]("https://github.com/isuPatches") [#4]("https://github.com/isuPatches/android-viewglu/issues/4") + +* issue3 - Update applicationId + [isuPatches]("https://github.com/isuPatches") [#3]("https://github.com/isuPatches/android-viewglu/issues/3") + +* issue2 - Support normal (non-AppCompat) Activity + [isuPatches]("https://github.com/isuPatches") [#2]("https://github.com/isuPatches/android-viewglu/issues/2") + +##### Bug Fixes + +##### Breaking + ## 1.0.0 Initial release diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 108a7e6..076f26e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -23,7 +23,7 @@ android { buildToolsVersion = BuildVersions.BUILD_TOOLS defaultConfig { - applicationId = "com.isupatches.android.viewbinding.delegates.sample" + applicationId = "com.isupatches.android.viewglu.sample" minSdk = BuildVersions.MIN_SDK targetSdk = BuildVersions.TARGET_SDK @@ -98,8 +98,11 @@ android { } dependencies { + /* + * Toggle these to test release binary vs. source code + */ // implementation(project(":viewglu")) - implementation("com.isupatches.android:viewglu:0.1.0-SNAPSHOT") { + implementation("com.isupatches.android:viewglu:1.0.0") { isChanging = true } diff --git a/buildSrc/src/main/java/com/isupatches/android/viewglu/build/Versions.kt b/buildSrc/src/main/java/com/isupatches/android/viewglu/build/Versions.kt index 7a659f7..d0ef096 100644 --- a/buildSrc/src/main/java/com/isupatches/android/viewglu/build/Versions.kt +++ b/buildSrc/src/main/java/com/isupatches/android/viewglu/build/Versions.kt @@ -37,7 +37,6 @@ object Versions { const val DEXCOUNT: String = "2.1.0-RC01" const val KTLINT_PLUGIN: String = "10.1.0" const val KTLINT: String = "0.41.0" - const val PMD: String = "6.36.0" // Documentation const val DOKKA: String = "1.5.0" diff --git a/documentation/viewglu/com.isupatches.android.viewglu/index.md b/documentation/viewglu/com.isupatches.android.viewglu/index.md index 5704a07..0d473d5 100644 --- a/documentation/viewglu/com.isupatches.android.viewglu/index.md +++ b/documentation/viewglu/com.isupatches.android.viewglu/index.md @@ -6,4 +6,4 @@ | Name | Summary | |---|---| -| [paste](paste.md) | [androidJvm]
fun <[VIEW_BINDING](paste.md)> [Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment.html).[paste](paste.md)(): [ReadWriteProperty](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.properties/-read-write-property/index.html)<[Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment.html), [VIEW_BINDING](paste.md)>
Description
Helps manage the ViewBinding for a [Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment.html) so that it is properly destroyed and not leaked.
[androidJvm]
inline fun <[VIEW_BINDING](paste.md) : ViewBinding> [AppCompatActivity](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatActivity.html).[paste](paste.md)(crossinline bindingInflater: ([LayoutInflater](https://developer.android.com/reference/kotlin/android/view/LayoutInflater.html)) -> [VIEW_BINDING](paste.md)): [Lazy](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-lazy/index.html)<[VIEW_BINDING](paste.md)>
Description
Helps to apply a ViewBinding to an [AppCompatActivity](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatActivity.html) by invoking the inflater. | +| [paste](paste.md) | [androidJvm]
fun <[VIEW_BINDING](paste.md)> [Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment.html).[paste](paste.md)(): [ReadWriteProperty](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.properties/-read-write-property/index.html)<[Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment.html), [VIEW_BINDING](paste.md)>
Description
Helps manage the ViewBinding for a [Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment.html) so that it is properly destroyed and not leaked.
[androidJvm]
inline fun <[VIEW_BINDING](paste.md) : ViewBinding> [Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html).[paste](paste.md)(crossinline bindingInflater: ([LayoutInflater](https://developer.android.com/reference/kotlin/android/view/LayoutInflater.html)) -> [VIEW_BINDING](paste.md)): [Lazy](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-lazy/index.html)<[VIEW_BINDING](paste.md)>
Description
Helps to apply a ViewBinding to an [Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html) by invoking the inflater.
[androidJvm]
inline fun <[VIEW_BINDING](paste.md) : ViewBinding> [AppCompatActivity](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatActivity.html).[paste](paste.md)(crossinline bindingInflater: ([LayoutInflater](https://developer.android.com/reference/kotlin/android/view/LayoutInflater.html)) -> [VIEW_BINDING](paste.md)): [Lazy](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-lazy/index.html)<[VIEW_BINDING](paste.md)>
Description
Helps to apply a ViewBinding to an [AppCompatActivity](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatActivity.html) by invoking the inflater. | diff --git a/documentation/viewglu/com.isupatches.android.viewglu/paste.md b/documentation/viewglu/com.isupatches.android.viewglu/paste.md index 19731e7..9f17a94 100644 --- a/documentation/viewglu/com.isupatches.android.viewglu/paste.md +++ b/documentation/viewglu/com.isupatches.android.viewglu/paste.md @@ -36,6 +36,40 @@ Patches Klinefelter 07/2021 +[androidJvm]\ +inline fun <[VIEW_BINDING](paste.md) : ViewBinding> [Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html).[paste](paste.md)(crossinline bindingInflater: ([LayoutInflater](https://developer.android.com/reference/kotlin/android/view/LayoutInflater.html)) -> [VIEW_BINDING](paste.md)): [Lazy](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-lazy/index.html)<[VIEW_BINDING](paste.md)> + +#### Description + +Helps to apply a ViewBinding to an [Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html) by invoking the inflater. + +#### Notes + + + +#### Example Usage + +

+    private val binding: ActivityMainBinding by paste(ActivityMainBinding::inflate)
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        setContentView(binding.root)
+    }
+
+ +#### Return + +Lazy + +#### Author + +Patches Klinefelter + +#### Since + +08/2021 + [androidJvm]\ fun <[VIEW_BINDING](paste.md)> [Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment.html).[paste](paste.md)(): [ReadWriteProperty](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.properties/-read-write-property/index.html)<[Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment.html), [VIEW_BINDING](paste.md)> diff --git a/documentation/viewglu/package-list b/documentation/viewglu/package-list index 7ef07b6..4c96417 100644 --- a/documentation/viewglu/package-list +++ b/documentation/viewglu/package-list @@ -1,6 +1,7 @@ $dokka.format:gfm-v1 $dokka.linkExtension:md $dokka.location:com.isupatches.android.viewglu////PointingToDeclaration/viewglu/com.isupatches.android.viewglu/index.md +$dokka.location:com.isupatches.android.viewglu//paste/android.app.Activity#kotlin.Function1[android.view.LayoutInflater,TypeParam(bounds=[androidx.viewbinding.ViewBinding])]/PointingToDeclaration/viewglu/com.isupatches.android.viewglu/paste.md $dokka.location:com.isupatches.android.viewglu//paste/androidx.appcompat.app.AppCompatActivity#kotlin.Function1[android.view.LayoutInflater,TypeParam(bounds=[androidx.viewbinding.ViewBinding])]/PointingToDeclaration/viewglu/com.isupatches.android.viewglu/paste.md $dokka.location:com.isupatches.android.viewglu//paste/androidx.fragment.app.Fragment#/PointingToDeclaration/viewglu/com.isupatches.android.viewglu/paste.md com.isupatches.android.viewglu diff --git a/gradle/pmd.gradle.kts b/gradle/pmd.gradle.kts deleted file mode 100644 index caec251..0000000 --- a/gradle/pmd.gradle.kts +++ /dev/null @@ -1,22 +0,0 @@ -import com.isupatches.android.viewglu.build.Versions - -plugins.apply(PmdPlugin::class) - -configure { - isConsoleOutput = false - toolVersion = Versions.PMD - maxFailures.set(1) - rulesMinimumPriority.set(1) - ruleSets = listOf("category/java/errorprone.xml", "category/java/bestpractices.xml") -} - -task("pmd") { - description = "Analyze code with pmd" - group = "reporting" - ignoreFailures = false - source = fileTree("src/main/java") - reports { - xml.required.set(false) - html.required.set(true) - } -} diff --git a/viewglu/src/main/java/com/isupatches/android/viewglu/ViewGlu.kt b/viewglu/src/main/java/com/isupatches/android/viewglu/ViewGlu.kt index 80648e5..c43a691 100644 --- a/viewglu/src/main/java/com/isupatches/android/viewglu/ViewGlu.kt +++ b/viewglu/src/main/java/com/isupatches/android/viewglu/ViewGlu.kt @@ -15,6 +15,7 @@ */ package com.isupatches.android.viewglu +import android.app.Activity import android.view.LayoutInflater import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment @@ -60,6 +61,40 @@ inline fun AppCompatActivity.paste( } } +/** + * #### Description + * + * Helps to apply a [ViewBinding] to an [Activity] by invoking the inflater. + * + * #### Notes + * - Uses the activity's layout inflater + * - The [LazyThreadSafetyMode] is set to NONE + * - Still requires the activity to apply the inflated binding + * + * #### Example Usage + *

+ *     private val binding: ActivityMainBinding by paste(ActivityMainBinding::inflate)
+ *
+ *     override fun onCreate(savedInstanceState: Bundle?) {
+ *         super.onCreate(savedInstanceState)
+ *         setContentView(binding.root)
+ *     }
+ * 
+ * + * @receiver [AppCompatActivity] + * @return Lazy + * + * @author Patches Klinefelter + * @since 08/2021 + */ +inline fun Activity.paste( + crossinline bindingInflater: (LayoutInflater) -> VIEW_BINDING +): Lazy { + return lazy(LazyThreadSafetyMode.NONE) { + bindingInflater.invoke(layoutInflater) + } +} + /** * #### Description *