Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Library #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:4.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.novoda:bintray-release:0.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\:https://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\:https://services.gradle.org/distributions/gradle-6.1.1-all.zip
9 changes: 7 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.novoda.bintray-release'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 10
versionName "1.1.2"
versionName "2.0.0"
}
buildTypes {
release {
Expand All @@ -21,15 +22,19 @@ dependencies {
implementation 'io.supercharge:shimmerlayout:2.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

publish {
userOrg = 'ethanhua'
groupId = 'com.ethanhua'
artifactId = 'skeleton'
publishVersion = '1.1.2'
publishVersion = '2.0.0'
bintrayUser = 'ethanhua'
bintrayKey = ''
desc = 'a library provider a easy way to show skeleton loading view'
website = 'https://github.com/ethanhua/Skeleton'
}
repositories {
mavenCentral()
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package com.ethanhua.skeleton

import android.support.annotation.ArrayRes
import android.support.annotation.ColorRes
import android.support.annotation.IntRange
import android.support.annotation.LayoutRes
import android.support.v4.content.ContextCompat
import android.support.v7.widget.RecyclerView

/**
* Created by ethanhua on 2017/7/29.
*/
class RecyclerViewSkeletonScreen private constructor(builder: Builder) : SkeletonScreen {
private val recyclerView: RecyclerView?
private val actualAdapter: RecyclerView.Adapter<*>?
private val skeletonAdapter: SkeletonAdapter?
private val recyclerViewFrozen: Boolean?

init {
recyclerView = builder.recyclerView
actualAdapter = builder.actualAdapter
skeletonAdapter = SkeletonAdapter()
skeletonAdapter.itemCount = builder.itemCount
skeletonAdapter.setLayoutReference(builder.itemResID)
skeletonAdapter.setArrayOfLayoutReferences(builder.itemsResIDArray)
skeletonAdapter.shimmer(builder.shimmer)
skeletonAdapter.setShimmerColor(builder.shimmerColor)
skeletonAdapter.setShimmerAngle(builder.shimmerAngle)
skeletonAdapter.setShimmerDuration(builder.shimmerDuration)
recyclerViewFrozen = builder.frozen
}


override fun show() {
recyclerView?.adapter = skeletonAdapter
if (recyclerView?.isComputingLayout == false && recyclerViewFrozen == true) {
recyclerView.isLayoutFrozen = true
}
}

override fun hide() {
recyclerView?.adapter = actualAdapter
}

class Builder(val recyclerView: RecyclerView) {

var actualAdapter: RecyclerView.Adapter<*>? = null
private set
var shimmer = true
private set
var itemCount = 10
private set
var itemResID = R.layout.layout_default_item_skeleton
private set
var itemsResIDArray: IntArray? = null
private set
var shimmerColor: Int
private set
var shimmerDuration = 1000
private set
var shimmerAngle = 20
private set
var frozen = true
private set


/**
* @param adapter the target recyclerView actual adapter
*/
fun adapter(adapter: RecyclerView.Adapter<*>?) = apply {
this.actualAdapter = adapter
}

/**
* @param itemCount the child item count in recyclerView
*/
fun count(itemCount: Int) = apply {
this.itemCount = itemCount
}

/**
* @param shimmer whether show shimmer animation
*/
fun shimmer(shimmer: Boolean) = apply {
this.shimmer = shimmer
}

/**
* the duration of the animation , the time it will take for the highlight to move from one end of the layout
* to the other.
*
* @param shimmerDuration Duration of the shimmer animation, in milliseconds
*/
fun duration(shimmerDuration: Int) = apply {
this.shimmerDuration = shimmerDuration
}

/**
* @param shimmerColor the shimmer color
*/
fun color(@ColorRes shimmerColor: Int) = apply {
this.shimmerColor = ContextCompat.getColor(recyclerView.context, shimmerColor)
}

/**
* @param shimmerAngle the angle of the shimmer effect in clockwise direction in degrees.
*/
fun angle(@IntRange(from = 0, to = 30) shimmerAngle: Int) = apply {
this.shimmerAngle = shimmerAngle
}

/**
* @param skeletonLayoutResID the loading skeleton layoutResID
*/
fun load(@LayoutRes skeletonLayoutResID: Int) = apply {
this.itemResID = skeletonLayoutResID
}

/**
* @param skeletonLayoutResIDs the loading array of skeleton layoutResID
*/
fun loadArrayOfLayouts(@ArrayRes skeletonLayoutResIDs: IntArray) = apply {
this.itemsResIDArray = skeletonLayoutResIDs
}

/**
* @param frozen whether frozen recyclerView during skeleton showing
* @return
*/
fun frozen(frozen: Boolean) = apply {
this.frozen = frozen
}

fun show(): RecyclerViewSkeletonScreen {
val recyclerViewSkeleton = RecyclerViewSkeletonScreen(this)
recyclerViewSkeleton.show()
return recyclerViewSkeleton
}

init {
shimmerColor = ContextCompat.getColor(recyclerView.context, R.color.shimmer_color)
}
}


}
24 changes: 0 additions & 24 deletions library/src/main/java/com/ethanhua/skeleton/ShimmerViewHolder.java

This file was deleted.

Loading