forked from RookieJay/JLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Title(feat):Add complete loadsir support of Activity and sample to gu…
…ide to use it. Cause:N/A Solution:N/A Effect: N/A Reviewer: N/A 附加说明:N/A
- Loading branch information
Showing
13 changed files
with
217 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
package pers.jay.demo.common | ||
|
||
import pers.jay.demo.loadsir.EmptyCallback | ||
import pers.jay.demo.loadsir.ErrorCallback | ||
import pers.jay.demo.loadsir.LoadingCallback | ||
import pers.jay.demo.loadsir.RetryCallback | ||
import pers.jay.library.loadsir.ViewStatusCallback | ||
import pers.jay.library.loadsir.StatusCallback | ||
|
||
/** | ||
* Copyright (c) 2011, 北京视达科技有限责任公司 All rights reserved. | ||
* author:juncai.zhou | ||
* date:2021/9/26 14:44 | ||
* description: | ||
*/ | ||
object Const { | ||
|
||
@JvmStatic | ||
val DEFAULT_LOADSIR_CALLBACK = ViewStatusCallback( | ||
val DEFAULT_VIEW_STATUS_CALLBACK = StatusCallback( | ||
LoadingCallback::class.java, | ||
EmptyCallback::class.java, | ||
ErrorCallback::class.java, | ||
RetryCallback::class.java | ||
) | ||
|
||
@JvmStatic | ||
val DEFAULT_ACTIVITY_STATUS_CALLBACK = StatusCallback( | ||
LoadingCallback::class.java, | ||
EmptyCallback::class.java, | ||
ErrorCallback::class.java, | ||
RetryCallback::class.java | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ class DemoViewModel : BaseViewModel<DemoRepo>() { | |
onCompletion { } | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,11 @@ interface IView { | |
*/ | ||
fun hideLoading() {} | ||
|
||
/** | ||
* 显示成功 | ||
*/ | ||
fun showSuccess() {} | ||
|
||
/** | ||
* 显示空视图 | ||
*/ | ||
|
36 changes: 36 additions & 0 deletions
36
jay_lib/src/main/java/pers/jay/library/base/StateListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package pers.jay.library.base | ||
|
||
/** | ||
* @Author RookieJay | ||
* @Time 2021/9/27 15:23 | ||
* @Description 状态监听器 | ||
*/ | ||
class StateListener<T> { | ||
|
||
var startAction: (() -> Unit)? = null | ||
var successAction: ((T) -> Unit)? = null | ||
var errorAction: ((String) -> Unit)? = null | ||
var emptyAction: (() -> Unit)? = null | ||
var completeAction: (() -> Unit)? = null | ||
|
||
fun onStart(action: (() -> Unit)?) { | ||
startAction = action | ||
} | ||
|
||
fun onSuccess(action: ((T) -> Unit)?) { | ||
successAction = action | ||
} | ||
|
||
fun onError(action: ((String) -> Unit)?) { | ||
errorAction = action | ||
} | ||
|
||
fun onEmpty(action: (() -> Unit)?) { | ||
emptyAction = action | ||
} | ||
|
||
fun onCompletion(action: (() -> Unit)?) { | ||
completeAction = action | ||
} | ||
|
||
} |
Oops, something went wrong.