Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: LarsWerkman/SkeletonLoading
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.5
Choose a base ref
...
head repository: LarsWerkman/SkeletonLoading
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 12 commits
  • 28 files changed
  • 1 contributor

Commits on Apr 23, 2020

  1. prepare next release

    Lars Werkman committed Apr 23, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    8009ce4 View commit details
  2. fixes single-line not drawing

    Lars Werkman committed Apr 23, 2020
    Copy the full SHA
    7d838b0 View commit details

Commits on Apr 24, 2020

  1. Reattach DoOnRedraw when textview get detached before it has been per…

    …formed
    Lars Werkman committed Apr 24, 2020
    Copy the full SHA
    d917f8a View commit details

Commits on Jun 17, 2020

  1. made some small api changes and added KDocs

    Lars Werkman committed Jun 17, 2020
    Copy the full SHA
    a63cc66 View commit details
  2. update gradle versions

    Lars Werkman committed Jun 17, 2020
    Copy the full SHA
    60f9189 View commit details
  3. improved the README

    Lars Werkman committed Jun 17, 2020
    Copy the full SHA
    f131045 View commit details
  4. version release

    Lars Werkman committed Jun 17, 2020
    Copy the full SHA
    dc4cd7d View commit details

Commits on Jun 18, 2020

  1. prepare next snapshot release

    Lars Werkman committed Jun 18, 2020
    Copy the full SHA
    ad01321 View commit details
  2. Copy the full SHA
    fa319a9 View commit details
  3. Removed default bind function in favour of extension function to avoi…

    …d Ambiguous method call in Java
    Lars Werkman committed Jun 18, 2020
    Copy the full SHA
    2fdbb07 View commit details
  4. version release

    Lars Werkman committed Jun 18, 2020
    Copy the full SHA
    e2dca9a View commit details
  5. prepare next snapshot release

    Lars Werkman committed Jun 18, 2020
    Copy the full SHA
    5bd8816 View commit details
Showing with 396 additions and 187 deletions.
  1. +1 −1 LICENSE
  2. +69 −2 README.md
  3. +1 −1 build.gradle
  4. BIN docs/static/example_dark.gif
  5. BIN docs/static/example_light.gif
  6. +1 −1 gradle.properties
  7. +2 −2 gradle/wrapper/gradle-wrapper.properties
  8. +1 −1 sample/build.gradle
  9. +6 −6 sample/src/main/java/com/larswerkman/skeletonloading/sample/MainActivity.kt
  10. +0 −24 ...ations/src/androidTest/java/com/larswerkman/skeletonloading/animations/ExampleInstrumentedTest.kt
  11. +11 −0 ...etonloading-animations/src/main/java/com/larswerkman/skeletonloading/animations/AlphaAnimation.kt
  12. +0 −3 skeletonloading-animations/src/main/res/values/strings.xml
  13. +0 −17 ...tonloading-animations/src/test/java/com/larswerkman/skeletonloading/animations/ExampleUnitTest.kt
  14. +1 −1 skeletonloading-views/build.gradle
  15. +0 −24 skeletonloading-views/src/androidTest/java/com/larswerkman/views/ExampleInstrumentedTest.kt
  16. +15 −0 skeletonloading-views/src/main/java/com/larswerkman/views/SkeletonImageView.kt
  17. +82 −5 skeletonloading-views/src/main/java/com/larswerkman/views/SkeletonTextView.kt
  18. +26 −4 skeletonloading-views/src/main/java/com/larswerkman/views/SkeletonView.kt
  19. +0 −2 skeletonloading-views/src/main/java/com/larswerkman/views/internal/DrawableWrapper.kt
  20. +7 −2 skeletonloading-views/src/main/java/com/larswerkman/views/internal/RoundedDrawableWrapper.kt
  21. +0 −17 skeletonloading-views/src/test/java/com/larswerkman/views/ExampleUnitTest.kt
  22. +0 −24 skeletonloading/src/androidTest/java/com/larswerkman/skeletonloading/ExampleInstrumentedTest.kt
  23. +24 −0 skeletonloading/src/main/java/com/larswerkman/skeletonloading/ISkeletonView.kt
  24. +47 −9 skeletonloading/src/main/java/com/larswerkman/skeletonloading/SkeletonAnimation.kt
  25. +50 −7 skeletonloading/src/main/java/com/larswerkman/skeletonloading/SkeletonBinder.kt
  26. +52 −14 skeletonloading/src/main/java/com/larswerkman/skeletonloading/SkeletonLoading.kt
  27. +0 −3 skeletonloading/src/main/res/values/strings.xml
  28. +0 −17 skeletonloading/src/test/java/com/larswerkman/skeletonloading/ExampleUnitTest.kt
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2020 Lars Werkman

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
71 changes: 69 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
# SkeletonLoading
# SkeletonLoading

A simple library to add Skeleton-loading animations to existing layouts and screens.
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.larswerkman/skeletonloading/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.larswerkman/skeletonloading/)


A simple way to add Drawable based skeleton loading to your Android app.

* Completely compatible with your current layout
* No custom TextViews or any other views needed.
* Lifecycle aware
* Easily extendable
* Build in Kotlin!

 
 

![](docs/static/example_light.gif)
![](docs/static/example_dark.gif)

## Example

```kotlin
class MainActivity : Activity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val loading = SkeletonLoading(
getDrawable(R.drawable.skeleton)!!,
AlphaAnimation(.1f, .6f)
)

loading.register(this)

val binder = loading.create {
sample_text_view.skeleton(SkeletonTextView.TextWidth.LINES, 1.2).bind()
}

binder.show()
}
}
```

## Download
```groovy
dependencies {
implementation 'com.larswerkman:skeletonloading:0.0.7'
implementation 'com.larswerkman:skeletonloading-views:0.0.7'
implementation 'com.larswerkman:skeletonloading-animations:0.0.7'
}
```

## License

```text
Copyright 2020 Lars Werkman
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.
```
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath "com.vanniktech:gradle-maven-publish-plugin:0.11.1"
}
Binary file added docs/static/example_dark.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/example_light.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.larswerkman
VERSION_NAME=0.0.5
VERSION_NAME=0.0.8-SNAPSHOT

POM_DESCRIPTION=Skeleton loading for Android views.

4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Jan 02 22:35:21 CET 2020
#Wed Jun 17 10:58:11 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation project(path: ':skeletonloading')
Original file line number Diff line number Diff line change
@@ -10,19 +10,19 @@ import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

private lateinit var loading: SkeletonLoading

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

loading = SkeletonLoading(this, R.drawable.skeleton, AlphaAnimation(.1f, .6f))
val loading = SkeletonLoading(
getDrawable(R.drawable.skeleton)!!,
AlphaAnimation(.1f, .6f)
)

loading.register(this)

val binder = loading.create {
bind(sample_text_view.skeleton(SkeletonTextView.TextWidth.LINES, 1.2))
bind(sample_view.skeleton(8F))
bind(sample_image_view.skeleton(8F))
sample_text_view.skeleton(SkeletonTextView.TextWidth.LINES, 1.2).bind()
}

sample_text_view.setOnClickListener {

This file was deleted.

Original file line number Diff line number Diff line change
@@ -7,14 +7,25 @@ import com.larswerkman.skeletonloading.SkeletonAnimation
import java.util.concurrent.TimeUnit
import kotlin.math.roundToInt

/**
* Animates the skeleton loading drawables alpha value.
*
* @param start value between 0 ... 1 to which it will animate from
* @param end value between 1 ... 0 to which it will animate to
* @param duration pair denoting the duration of the animation
* @param interpolator defines the rate of change of the animation
* @param repeat if the animation should repeat forever
*/
class AlphaAnimation(
@FloatRange(from = 0.0, to = 1.0) start: Float,
@FloatRange(from = 0.0, to = 1.0) end: Float,
duration: Pair<Long, TimeUnit> = Pair(1, TimeUnit.SECONDS),
interpolator: TimeInterpolator? = null,
repeat: Boolean = true
) : SkeletonAnimation(start, end, duration, interpolator, repeat) {

override fun animate(drawable: Drawable, progress: Float) {
drawable.alpha = (progress * 255f).roundToInt()
}

}
3 changes: 0 additions & 3 deletions skeletonloading-animations/src/main/res/values/strings.xml

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion skeletonloading-views/build.gradle
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ android {

dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
api 'androidx.core:core-ktx:1.2.0'
api 'androidx.core:core-ktx:1.3.0'
api project(path: ':skeletonloading')
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -6,16 +6,31 @@ import com.larswerkman.skeletonloading.ISkeletonView
import com.larswerkman.skeletonloading.SkeletonAnimation
import com.larswerkman.views.internal.RoundedDrawableWrapper

/**
* Convenient method of creating a [SkeletonImageView] instance for a [ImageView]
*
* @param radius extra radius that can be added to the skeleton drawable
*/
fun ImageView.skeleton(radius: Float = 0F): ISkeletonView {
return SkeletonImageView(this, radius)
}

/**
* Basic skeleton implementation for [ImageView]'s
*
* @param view to be put in a loading state
* @param radius extra radius that can be added to the skeleton drawable
*/
class SkeletonImageView(
private val view: ImageView,
private val radius: Float = 0F
) : ISkeletonView {

private lateinit var drawable: Drawable

/**
* state of the [ImageView] before the loading state is shown.
*/
private var image: Drawable? = null

override fun setup(drawable: Drawable) {
Loading