aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android-lib.gradle6
-rw-r--r--build.gradle1
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt4
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt41
-rw-r--r--gradle.properties4
-rw-r--r--mediapicker/build.gradle1
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt1
-rw-r--r--sample/src/main/res/xml/kau_changelog.xml1
8 files changed, 39 insertions, 20 deletions
diff --git a/android-lib.gradle b/android-lib.gradle
index 30dafbd..c1fb523 100644
--- a/android-lib.gradle
+++ b/android-lib.gradle
@@ -1,6 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'
+apply plugin: 'com.getkeepsafe.dexcount'
group = project.APP_GROUP
android {
@@ -27,6 +28,11 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
+ compileOptions {
+ targetCompatibility 1.8
+ sourceCompatibility 1.8
+ }
+
buildTypes {
release {
minifyEnabled false
diff --git a/build.gradle b/build.gradle
index 2de8485..73ca19e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -10,6 +10,7 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${KOTLIN}"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
+ classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt
index 24146b0..f690571 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt
@@ -1,6 +1,8 @@
package ca.allanwang.kau.logging
+import ca.allanwang.kau.BuildConfig
+
/**
* Created by Allan Wang on 2017-06-19.
*/
-object KL : KauLogger("KAU") \ No newline at end of file
+object KL : KauLogger("KAU", { BuildConfig.DEBUG }) \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
index da1c05b..e639867 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
@@ -22,12 +22,16 @@ import android.util.Log
* if (BuildConfig.DEBUG) d(message)
* }
*/
-open class KauLogger(val tag: String) {
+open class KauLogger(
+ /**
+ * Tag to be used for each log
+ */
+ val tag: String,
+ /**
+ * Toggle to dictate whether a message should be logged
+ */
+ var shouldLog: (priority: Int) -> Boolean = { true }) {
- /**
- * Global toggle to enable the whole logger
- */
- open var enabled = true
inline fun v(message: () -> Any?) = log(Log.VERBOSE, message)
@@ -37,20 +41,22 @@ open class KauLogger(val tag: String) {
inline fun e(t: Throwable? = null, message: () -> Any?) = log(Log.ERROR, message, t)
- inline fun eThrow(message: Any) = with(message.toString()) {
- log(Log.ERROR, { this }, Throwable(this))
+ inline fun eThrow(message: Any?) {
+ val msg = message?.toString() ?: return
+ log(Log.ERROR, { msg }, Throwable(msg))
}
inline fun log(priority: Int, message: () -> Any?, t: Throwable? = null) {
- if (enabled)
- logImpl(priority, message()?.toString() ?: "null", t)
+ if (shouldLog(priority))
+ logImpl(priority, message()?.toString(), t)
}
- open fun logImpl(priority: Int, message: String, t: Throwable?) {
+ open fun logImpl(priority: Int, message: String?, t: Throwable?) {
+ val msg = message ?: "null"
if (t != null)
- Log.e(tag, message, t)
+ Log.e(tag, msg, t)
else
- Log.println(priority, tag, message)
+ Log.println(priority, tag, msg)
}
/**
@@ -82,12 +88,17 @@ class KauLoggerExtension(val tag: String, val logger: KauLogger) {
inline fun e(t: Throwable? = null, message: () -> Any?) = log(Log.ERROR, message, t)
- inline fun eThrow(message: Any) = with(message.toString()) {
- log(Log.ERROR, { this }, Throwable(this))
+ inline fun eThrow(message: Any?) {
+ val msg = message?.toString() ?: return
+ log(Log.ERROR, { msg }, Throwable(msg))
}
inline fun log(priority: Int, message: () -> Any?, t: Throwable? = null) =
- logger.log(priority, { "$tag: ${message()?.toString() ?: "null"}" }, t)
+ logger.log(priority, {
+ val msg = message()?.toString()
+ if (msg == null) null
+ else "$tag: $msg"
+ }, t)
inline fun checkThread(id: Int) {
d {
diff --git a/gradle.properties b/gradle.properties
index f8f5c0b..73c4123 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -30,8 +30,8 @@ ABOUT_LIBRARIES=6.0.1
ANKO=0.10.3
BLURRY=2.1.1
CONSTRAINT_LAYOUT=1.1.0-beta4
-FAST_ADAPTER=3.0.4
-FAST_ADAPTER_COMMONS=3.0.3
+FAST_ADAPTER=3.0.5
+FAST_ADAPTER_COMMONS=3.0.5
GLIDE=4.4.0
ICONICS=3.0.0
IICON_GOOGLE=3.0.1.2
diff --git a/mediapicker/build.gradle b/mediapicker/build.gradle
index 0f90f7b..1c6884d 100644
--- a/mediapicker/build.gradle
+++ b/mediapicker/build.gradle
@@ -8,7 +8,6 @@ dependencies {
implementation project(':adapter')
api "com.github.bumptech.glide:glide:${GLIDE}"
- kapt "com.github.bumptech.glide:compiler:${GLIDE}"
implementation "jp.wasabeef:blurry:${BLURRY}"
}
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt
index 30c877b..8853c86 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt
@@ -9,7 +9,6 @@ import ca.allanwang.kau.logging.KL
class SampleApp : Application() {
override fun onCreate() {
super.onCreate()
- KL.enabled = BuildConfig.DEBUG
KPrefSample.initialize(this, "pref_sample")
}
} \ No newline at end of file
diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml
index 59914a3..a4c4f95 100644
--- a/sample/src/main/res/xml/kau_changelog.xml
+++ b/sample/src/main/res/xml/kau_changelog.xml
@@ -9,6 +9,7 @@
<version title="v3.6.1" />
<item text=":core: [Breaking] Removed private text field and introduced lazy logging functions" />
+ <item text=":adapter: Improve library item layout" />
<version title="v3.6.0" />
<item text=":adapter: Create withOnRepeatedClickListener" />