Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Idea
/.idea

# Built application files
*.apk
*.ap_
Expand Down
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.41'
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -19,7 +18,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

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\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
28 changes: 21 additions & 7 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'

group='com.erkutaras.statelayout'

android {
compileSdkVersion 28
compileSdkVersion 31

defaultConfig {
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 31
versionCode 26
versionName "1.4.4"

Expand All @@ -23,13 +23,27 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
}
repositories {
mavenCentral()

project.afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = 'com.erkutaras.statelayout'
artifactId = 'StateLayout'
version = '1.4.4'
}
}
}
}
4 changes: 3 additions & 1 deletion library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<manifest package="com.erkutaras.statelayout"/>
<manifest package="com.erkutaras.statelayout">

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ class StateLayout: FrameLayout {
}
}

fun getInfoLayout(): View? {
return infoLayout
}

companion object {
@JvmStatic
fun provideLoadingStateInfo() = StateInfo(state = LOADING)
Expand Down
1 change: 1 addition & 0 deletions lottie-ext/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
53 changes: 53 additions & 0 deletions lottie-ext/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'maven-publish'

group='com.erkutaras.statelayout'

android {
compileSdkVersion 31

defaultConfig {
minSdkVersion 16
targetSdkVersion 31
versionCode 26
versionName "1.4.4"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

dataBinding {
enabled true
}
}

dependencies {
implementation project(':library')
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
api 'com.airbnb.android:lottie:4.2.2'
}

project.afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = 'com.erkutaras.statelayout'
artifactId = 'LottieExt'
version = '1.4.4'
}
}
}
}
21 changes: 21 additions & 0 deletions lottie-ext/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
5 changes: 5 additions & 0 deletions lottie-ext/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.erkutaras.statelayout.lottieext">


</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.erkutaras.statelayout.lottieext

import android.view.View
import com.airbnb.lottie.LottieAnimationView
import com.erkutaras.statelayout.StateLayout

fun StateLayout.infoLottie(assetName: String): StateLayout {
getInfoLayout()?.findViewById<LottieAnimationView>(R.id.imageView_state_layout_info)?.run {
setAnimation(assetName)
visibility = View.VISIBLE
}
return this
}

fun StateLayout.infoLottie(rawRes: Int): StateLayout {
getInfoLayout()?.findViewById<LottieAnimationView>(R.id.imageView_state_layout_info)?.run {
setAnimation(rawRes)
visibility = View.VISIBLE
}
return this
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.erkutaras.statelayout.lottieext.databinding

import androidx.databinding.BindingAdapter
import com.erkutaras.statelayout.StateLayout
import com.erkutaras.statelayout.lottieext.infoLottie

@BindingAdapter("sl_infoLottieAsset")
fun setInfoLottieAsset(view: StateLayout, assetName: String) {
view.infoLottie(assetName)
}

@BindingAdapter("sl_infoLottieRawRes")
fun setInfoLottieRawRes(view: StateLayout, rawRes: Int) {
view.infoLottie(rawRes)
}
27 changes: 17 additions & 10 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 28
compileSdkVersion 31
defaultConfig {
applicationId "com.erkutaras.statelayout.sample"
minSdkVersion 14
targetSdkVersion 28
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -19,15 +19,22 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
viewBinding {
enabled true
}
}

dependencies {
implementation project(':library')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0-alpha06'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0-rc01'
implementation project(':lottie-ext')
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.android.material:material:1.6.0-alpha02'
implementation 'androidx.vectordrawable:vectordrawable:1.2.0-alpha02'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
37 changes: 25 additions & 12 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.erkutaras.statelayout.sample"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest
package="com.erkutaras.statelayout.sample"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
Expand All @@ -13,18 +14,30 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".StateLayoutSampleActivity"
android:label="StateLayout - Simple Usage">

<activity
android:name=".StateLayoutSampleActivity"
android:label="StateLayout - Simple Usage"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".CustomSampleActivity"
android:label="StateLayout - Custom Usage"/>
<activity android:name=".AnimationLoadingSampleActivity"
android:label="StateLayout - Animation Loading"/>

<activity
android:name=".CustomSampleActivity"
android:label="StateLayout - Custom Usage" />

<activity
android:name=".AnimationLoadingSampleActivity"
android:label="StateLayout - Animation Loading" />

<activity
android:name=".InfoLottieSampleActivity"
android:label="StateLayout - Lottie" />
</application>

</manifest>
1 change: 1 addition & 0 deletions sample/src/main/assets/like_heart.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"4.6.6","fr":25,"ip":0,"op":50,"w":18,"h":18,"nm":"2.0 A-首页-inline播放","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"形状图层 1","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[9,9,0]},"a":{"a":0,"k":[0,0,0]},"s":{"a":0,"k":[3.0405405405405403,3.0405405405405403,100]}},"ao":0,"shapes":[{"d":1,"ty":"el","s":{"a":1,"k":[{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0"],"t":2,"s":[0,0],"e":[29,29]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0"],"t":7,"s":[29,29],"e":[0,0]},{"t":16}]},"p":{"a":1,"k":[{"i":{"x":0.52,"y":1},"o":{"x":0.6,"y":0},"n":"0p52_1_0p6_0","t":1,"s":[0,0],"e":[0,189],"to":[0,31.5],"ti":[0,-40]},{"i":{"x":0.38,"y":1},"o":{"x":0.333,"y":0},"n":"0p38_1_0p333_0","t":6,"s":[0,189],"e":[0,240],"to":[0,40],"ti":[0,-8.5]},{"t":15}]},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"fl","c":{"a":0,"k":[0.2901960784313726,0.5647058823529412,0.8862745098039215,1]},"o":{"a":0,"k":100},"r":1,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"rp","c":{"a":0,"k":8,"ix":1},"o":{"a":0,"k":0,"ix":2},"m":1,"ix":3,"tr":{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":45,"ix":4},"so":{"a":0,"k":100,"ix":5},"eo":{"a":0,"k":100,"ix":6},"nm":"变换"},"nm":"中继器 1","mn":"ADBE Vector Filter - Repeater"}],"ip":0,"op":250,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"Explosion Vol.1 08 / 1","cl":"1","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[9,9,0]},"a":{"a":0,"k":[-120.395,32.605,0]},"s":{"a":1,"k":[{"i":{"x":[0,0,0.667],"y":[1.002,1.002,0.667]},"o":{"x":[1,1,0.333],"y":[0,0,0.333]},"n":["0_1p002_1_0","0_1p002_1_0","0p667_0p667_0p333_0p333"],"t":2,"s":[0,0,100],"e":[2.9189189189189184,2.9189189189189184,100]},{"t":14}]}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[367.211,367.211]},"p":{"a":0,"k":[0,0]},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"st","c":{"a":0,"k":[0.2901960784313726,0.5647058823529412,0.8862745098039215,1]},"o":{"a":0,"k":100},"w":{"a":1,"k":[{"i":{"x":[0.297],"y":[1]},"o":{"x":[0.588],"y":[0]},"n":["0p297_1_0p588_0"],"t":2,"s":[240],"e":[0]},{"t":14}]},"lc":1,"lj":1,"ml":4,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[-120.395,32.605],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":30,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"“喜欢”轮廓","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0,"x":"var $bm_rt;\n$bm_rt = transform.rotation;"},"p":{"a":0,"k":[9,9,0],"x":"var $bm_rt;\n$bm_rt = transform.position;"},"a":{"a":0,"k":[25,22.5,0]},"s":{"a":1,"k":[{"i":{"x":[0.48,0.48,0.667],"y":[1,1,0.667]},"o":{"x":[0.333,0.333,0.167],"y":[0.115,0.115,0.167]},"n":["0p48_1_0p333_0p115","0p48_1_0p333_0p115","0p667_0p667_0p167_0p167"],"t":0,"s":[12.162162162162161,12.162162162162161,100],"e":[7.2972972972972965,7.2972972972972965,100]},{"i":{"x":[0.516,0.516,0.667],"y":[1,1,0.667]},"o":{"x":[0.264,0.264,0.333],"y":[0,0,0.333]},"n":["0p516_1_0p264_0","0p516_1_0p264_0","0p667_0p667_0p333_0p333"],"t":2,"s":[7.2972972972972965,7.2972972972972965,100],"e":[15.81081081081081,15.81081081081081,100]},{"i":{"x":[0.605,0.605,0.667],"y":[1.005,1.005,0.667]},"o":{"x":[0.373,0.373,0.333],"y":[0,0,0.333]},"n":["0p605_1p005_0p373_0","0p605_1p005_0p373_0","0p667_0p667_0p333_0p333"],"t":7,"s":[15.81081081081081,15.81081081081081,100],"e":[12.162162162162161,12.162162162162161,100]},{"i":{"x":[0.663,0.663,0.833],"y":[0.978,0.978,0.833]},"o":{"x":[0.32,0.32,0.167],"y":[0,0,0.167]},"n":["0p663_0p978_0p32_0","0p663_0p978_0p32_0","0p833_0p833_0p167_0p167"],"t":11,"s":[12.162162162162161,12.162162162162161,100],"e":[12.77027027027027,12.77027027027027,100]},{"i":{"x":[0.64,0.64,0.833],"y":[0.973,0.973,0.833]},"o":{"x":[0.29,0.29,0.167],"y":[0.002,0.002,0.167]},"n":["0p64_0p973_0p29_0p002","0p64_0p973_0p29_0p002","0p833_0p833_0p167_0p167"],"t":14,"s":[12.77027027027027,12.77027027027027,100],"e":[12.162162162162161,12.162162162162161,100]},{"t":19}]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[7.401,0],[2.068,-3.674],[4.874,0],[0,-6.245],[-0.912,-0.537],[-0.234,0],[-0.209,0.124],[0,14.79]],"o":[[-4.875,0],[-2.067,-3.674],[-7.402,0],[0,14.79],[0.209,0.124],[0.234,0],[0.912,-0.537],[0,-6.245]],"v":[[11.176,-20.5],[0,-14.302],[-11.175,-20.5],[-23,-7.795],[-0.676,20.315],[0,20.5],[0.676,20.315],[23,-7.795]],"c":true}},"nm":"路径 1","mn":"ADBE Vector Shape - Group"},{"ty":"fl","c":{"a":0,"k":[0.2901960784313726,0.5647058823529412,0.8862745098039215,1]},"o":{"a":0,"k":100},"r":1,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"st","c":{"a":0,"k":[0.2901960784313726,0.5647058823529412,0.8862745098039215,1]},"o":{"a":0,"k":100},"w":{"a":0,"k":3.6},"lc":2,"lj":2,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[25,22.5],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":250,"st":0,"bm":0,"sr":1}]}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Toast
import com.erkutaras.statelayout.StateLayout
import kotlinx.android.synthetic.main.activity_state_layout_sample.*
import com.erkutaras.statelayout.sample.databinding.ActivityAnimationLoadingSampleBinding

/**
* Created by erkutaras on 2.02.2019.
Expand All @@ -17,23 +17,26 @@ private const val WEB_URL = "https://github.com/erkutaras"

class AnimationLoadingSampleActivity : SampleBaseActivity(), StateLayout.OnStateLayoutListener {

private lateinit var binding: ActivityAnimationLoadingSampleBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_animation_loading_sample)
binding = ActivityAnimationLoadingSampleBinding.inflate(layoutInflater)
setContentView(binding.root)

webView.webViewClient = SampleWebViewClient(stateLayout, this)
webView.loadUrl(WEB_URL)
binding.webView.webViewClient = SampleWebViewClient(binding.stateLayout, this)
binding.webView.loadUrl(WEB_URL)
}

override fun getMenuResId(): Int = R.menu.menu_animation_loading

override fun onStateLayoutInfoButtonClick() {
webView.loadUrl(WEB_URL)
binding.webView.loadUrl(WEB_URL)
Toast.makeText(this, "Refreshing Page...", Toast.LENGTH_SHORT).show()
}

override fun onBackPressed() {
if (webView.canGoBack()) webView.goBack()
if (binding.webView.canGoBack()) binding.webView.goBack()
else super.onBackPressed()
}

Expand Down Expand Up @@ -66,6 +69,5 @@ class AnimationLoadingSampleActivity : SampleBaseActivity(), StateLayout.OnState
onStateLayoutListener.onStateLayoutInfoButtonClick()
}
}

}
}
}
Loading