diff options
-rw-r--r-- | .travis.yml | 15 | ||||
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/kotlin/FlyWeight.kt | 54 | ||||
-rw-r--r-- | docs/Changelog.md | 1 | ||||
-rw-r--r-- | sample/src/main/res/xml/kau_changelog.xml | 2 |
4 files changed, 11 insertions, 61 deletions
diff --git a/.travis.yml b/.travis.yml index 721eb72..ee679b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,20 +4,20 @@ jdk: env: global: - ANDROID_API=28 - - EMULATOR_API=24 + - EMULATOR_API=19 - ANDROID_BUILD_TOOLS=28.0.3 android: components: - tools -# - android-$EMULATOR_API - platform-tools - tools - build-tools-$ANDROID_BUILD_TOOLS - android-$ANDROID_API - - extra-android-support +# - android-$EMULATOR_API - extra-android-m2repository - extra-google-m2repository -# - sys-img-armeabi-v7a-android-$EMULATOR_API +# - sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL +# - sys-img-armeabi-v7a-addon-google_apis-google-$EMULATOR_API_LEVEL licenses: - ".+" #before_script: @@ -25,8 +25,11 @@ android: #- echo "y" | android update sdk -a --no-ui --filter sys-img-armeabi-v7a-android-$EMULATOR_API #- android list targets | grep -E '^id:' | awk -F '"' '{$1=""; print $2}' # list all targets #- echo no | android create avd --force -n test -t android-$EMULATOR_API --abi armeabi-v7a -#- emulator -avd test -no-skin -no-window & +#- emulator -avd test -skin -no-audio -no-window & #- android-wait-for-emulator +#- adb shell settings put global window_animation_scale 0 & +#- adb shell settings put global transition_animation_scale 0 & +#- adb shell settings put global animator_duration_scale 0 & #- adb shell input keyevent 82 & script: - chmod +x gradlew @@ -50,7 +53,7 @@ cache: - $HOME/.gradle/wrapper/ - $HOME/.android/build-cache before_install: -- yes | sdkmanager "platforms;android-28" +- yes | sdkmanager "platforms;android-$ANDROID_API" - openssl aes-256-cbc -K $encrypted_12e8842891a3_key -iv $encrypted_12e8842891a3_iv -in files/kau.tar.enc -out kau.tar -d - tar xvf kau.tar
\ No newline at end of file diff --git a/core/src/main/kotlin/ca/allanwang/kau/kotlin/FlyWeight.kt b/core/src/main/kotlin/ca/allanwang/kau/kotlin/FlyWeight.kt deleted file mode 100644 index 165295a..0000000 --- a/core/src/main/kotlin/ca/allanwang/kau/kotlin/FlyWeight.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2018 Allan Wang - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package ca.allanwang.kau.kotlin - -/** - * Created by Allan Wang on 26/12/17. - * - * Kotlin implementation of a flyweight design pattern - * Values inside the map will be returned directly - * Otherwise, it will be created with the supplier, saved, and returned - * In the event a default is provided, the default takes precedence - */ -fun <K : Any, V : Any> flyweight(creator: (K) -> V) = FlyWeight(creator) - -class FlyWeight<K : Any, V : Any>(private val creator: (key: K) -> V) : Map<K, V> { - - private val map = mutableMapOf<K, V>() - - override val entries: Set<Map.Entry<K, V>> - get() = map.entries - override val keys: Set<K> - get() = map.keys - override val size: Int - get() = map.size - override val values: Collection<V> - get() = map.values - - override fun containsKey(key: K) = map.containsKey(key) - - override fun containsValue(value: V) = map.containsValue(value) - - override fun getOrDefault(key: K, defaultValue: V) = map.getOrDefault(key, defaultValue) - - override fun isEmpty() = map.isEmpty() - - override fun get(key: K): V { - if (!map.containsKey(key)) - map.put(key, creator(key)) - return map[key]!! - } -} diff --git a/docs/Changelog.md b/docs/Changelog.md index 283759d..e6d51d2 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -4,6 +4,7 @@ * :core: Remove anko dependency. Methods that used it now use coroutines; see the migration doc for minor changes * :core: Add default CoroutineScope implementation to KauBaseActivity * :core: Remove zip class. Coroutines and join can be used as an alternative +* :core: Delete flyweight implementation. Kotlin already has getOrPut * :mediapicker: Use video preloading instead of full async loading ## v4.0.0-alpha01 diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml index 3c49078..0283d7f 100644 --- a/sample/src/main/res/xml/kau_changelog.xml +++ b/sample/src/main/res/xml/kau_changelog.xml @@ -10,11 +10,11 @@ <item text=":core: Remove anko dependency. Methods that used it now use coroutines; see the migration doc for minor changes" /> <item text=":core: Add default CoroutineScope implementation to KauBaseActivity" /> <item text=":core: Remove zip class. Coroutines and join can be used as an alternative" /> + <item text=":core: Delete flyweight implementation. Kotlin already has getOrPut" /> <item text=":mediapicker: Use video preloading instead of full async loading" /> <item text="" /> <item text="" /> <item text="" /> - <item text="" /> <version title="v4.0.0-alpha01" /> <item text="Migrate to androidx. See migration for external dependency changes." /> |