Skip to content

Commit

Permalink
Merge pull request #29 from erkutaras/develop
Browse files Browse the repository at this point in the history
release v1.5.0
  • Loading branch information
erkutaras authored May 31, 2020
2 parents 6bb9780 + 727eafb commit d8cafe7
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 49 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ allprojects {
**Step 2.** Add the library dependency to your project build.gradle:
```
dependencies {
implementation 'com.github.erkutaras:StateLayout:1.4.2'
implementation 'com.github.erkutaras:StateLayout:1.5.0'
}
```

Expand Down Expand Up @@ -169,7 +169,7 @@ Patches and new features are encouraged, and may be submitted by [forking this p

# License

Copyright 2018-2019 erkutaras
Copyright 2018-2020 erkutaras

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// 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.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

Expand Down
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 @@
#Sun May 19 19:37:42 MSK 2019
#Sun May 31 21:43:37 MSK 2020
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-6.1.1-all.zip
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ apply plugin: 'com.github.dcendents.android-maven'
group='com.erkutaras.statelayout'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 29
versionCode 24
versionName "1.4.2"
versionName "1.5.0"

vectorDrawables.useSupportLibrary = true
}
Expand All @@ -28,7 +28,7 @@ android {
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.appcompat:appcompat:1.1.0'
}
repositories {
mavenCentral()
Expand Down
21 changes: 3 additions & 18 deletions library/src/main/java/com/erkutaras/statelayout/StateLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,6 @@ class StateLayout @JvmOverloads constructor(context: Context,
return info()
}

@Deprecated("infoButtonListener(block: () -> Unit) calling is more convenient")
fun infoButtonListener(onStateLayoutListener: OnStateLayoutListener?): StateLayout {
infoLayout.findView<Button>(R.id.button_state_layout_info) {
setOnClickListener { onStateLayoutListener?.onStateLayoutInfoButtonClick() }
}
return info()
}

fun infoButtonListener(block: () -> Unit) {
infoLayout.findView<Button>(R.id.button_state_layout_info) {
setOnClickListener { block.invoke() }
Expand All @@ -229,10 +221,10 @@ class StateLayout @JvmOverloads constructor(context: Context,
return info()
}

fun infoButton(buttonText: String, onStateLayoutListener: OnStateLayoutListener?): StateLayout {
fun infoButton(buttonText: String, block: (() -> Unit)?): StateLayout {
infoLayout.findView<Button>(R.id.button_state_layout_info) {
text = buttonText
setOnClickListener { onStateLayoutListener?.onStateLayoutInfoButtonClick() }
setOnClickListener { block?.invoke() }
visibility = View.VISIBLE
}
return info()
Expand Down Expand Up @@ -299,7 +291,6 @@ class StateLayout @JvmOverloads constructor(context: Context,
stateInfo.infoTitle?.let { infoTitle(it) }
stateInfo.infoMessage?.let { infoMessage(it) }
stateInfo.infoButtonText?.let { infoButtonText(it) }
stateInfo.onStateLayoutListener?.let { infoButtonListener(it) }
stateInfo.onInfoButtonClick?.let { infoButtonListener(it) }
}
null, NONE -> hideAll()
Expand Down Expand Up @@ -329,10 +320,6 @@ class StateLayout @JvmOverloads constructor(context: Context,
fun provideNoneStateInfo() = StateInfo(state = NONE)
}

interface OnStateLayoutListener {
fun onStateLayoutInfoButtonClick()
}

enum class State {
LOADING, CONTENT, INFO, LOADING_WITH_CONTENT, ERROR, EMPTY, NONE
}
Expand All @@ -342,9 +329,7 @@ class StateLayout @JvmOverloads constructor(context: Context,
val infoTitle: String? = null,
val infoMessage: String? = null,
val infoButtonText: String? = null,
val state: StateLayout.State = INFO,
@Deprecated("onInfoButtonClick is more convenient")
val onStateLayoutListener: StateLayout.OnStateLayoutListener? = null,
val state: State = INFO,
val onInfoButtonClick: (() -> Unit)? = null,
val loadingAnimation: Animation? = null,
val loadingWithContentAnimation: Animation? = null
Expand Down
10 changes: 5 additions & 5 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "com.erkutaras.statelayout.sample"
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -25,9 +25,9 @@ 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.appcompat:appcompat:1.1.0'
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 'com.google.android.material:material:1.1.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
3 changes: 2 additions & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
<activity android:name=".StateLayoutSampleActivity"
android:label="StateLayout - Simple Usage">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ import kotlinx.android.synthetic.main.activity_state_layout_sample.*
*/
private const val WEB_URL = "https://github.com/erkutaras"

class AnimationLoadingSampleActivity : SampleBaseActivity(), StateLayout.OnStateLayoutListener {
class AnimationLoadingSampleActivity : SampleBaseActivity() {

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

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

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

override fun onStateLayoutInfoButtonClick() {
private fun onStateLayoutInfoButtonClick() {
webView.loadUrl(WEB_URL)
Toast.makeText(this, "Refreshing Page...", Toast.LENGTH_SHORT).show()
}
Expand All @@ -38,7 +40,7 @@ class AnimationLoadingSampleActivity : SampleBaseActivity(), StateLayout.OnState
}

private class SampleWebViewClient(val stateLayout: StateLayout,
val onStateLayoutListener: StateLayout.OnStateLayoutListener)
val onClick: () -> Unit)
: WebViewClient() {

var hasError: Boolean = false
Expand All @@ -62,9 +64,7 @@ class AnimationLoadingSampleActivity : SampleBaseActivity(), StateLayout.OnState
.infoTitle("Ooops.... :(")
.infoMessage("Unexpected error occurred. Please refresh the page!")
.infoButtonText("Refresh")
.infoButtonListener {
onStateLayoutListener.onStateLayoutInfoButtonClick()
}
.infoButtonListener(onClick)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ import android.widget.Toast
import com.erkutaras.statelayout.StateLayout
import kotlinx.android.synthetic.main.activity_state_layout_sample.*

private const val WEB_URL = "http://www.erkutaras.com/"
private const val WEB_URL = "https://www.erkutaras.com/"

class StateLayoutSampleActivity : SampleBaseActivity(), StateLayout.OnStateLayoutListener {
class StateLayoutSampleActivity : SampleBaseActivity() {

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

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

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

override fun onStateLayoutInfoButtonClick() {
private fun onStateLayoutInfoButtonClick() {
webView.loadUrl(WEB_URL)
Toast.makeText(this, "Refreshing Page...", Toast.LENGTH_SHORT).show()
}
Expand All @@ -35,7 +35,7 @@ class StateLayoutSampleActivity : SampleBaseActivity(), StateLayout.OnStateLayou
}

private class SampleWebViewClient(val stateLayout: StateLayout,
val onStateLayoutListener: StateLayout.OnStateLayoutListener)
val onClick: () -> Unit)
: WebViewClient() {

var hasError: Boolean = false
Expand All @@ -59,9 +59,7 @@ class StateLayoutSampleActivity : SampleBaseActivity(), StateLayout.OnStateLayou
.infoTitle("Ooops.... :(")
.infoMessage("Unexpected error occurred. Please refresh the page!")
.infoButtonText("Refresh")
.infoButtonListener {
onStateLayoutListener.onStateLayoutInfoButtonClick()
}
.infoButtonListener(onClick)
}

}
Expand Down

0 comments on commit d8cafe7

Please sign in to comment.