package cn.flightfeather.thirdapp.view.recyclerview
|
|
import android.support.v4.widget.SwipeRefreshLayout
|
|
/**
|
* @author riku
|
* Date: 2019/5/17
|
*/
|
interface SwipeRefreshLayoutSetInterface {
|
|
fun initSwipeRefreshLayout(){
|
//下拉刷新
|
getSwipeRefreshLayout()?.let {
|
it.isEnabled = needSwipeRefresh()
|
if (getColorList().size == 3) {
|
it.setColorSchemeColors(getColorList()[0], getColorList()[1], getColorList()[2])
|
}
|
it.setOnRefreshListener {
|
onRefreshRequested()
|
it.postDelayed({
|
it.isRefreshing = false
|
}, 10000)
|
}
|
}
|
}
|
|
fun startRefresh(){
|
if (enableRefresh()) {
|
onRefreshRequested()
|
if (needSwipeRefresh()) {
|
getSwipeRefreshLayout()?.let {
|
it.isRefreshing = true
|
it.postDelayed({
|
it.isRefreshing = false
|
}, 10000)
|
}
|
}
|
}
|
}
|
|
fun stopRefresh(){
|
if (enableRefresh()) {
|
if (getSwipeRefreshLayout()?.isRefreshing == true) {
|
getSwipeRefreshLayout()?.isRefreshing = false
|
}
|
}
|
}
|
|
fun getSwipeRefreshLayout(): SwipeRefreshLayout?
|
|
//是否允许默认第一次自动刷新
|
fun enableRefresh(): Boolean
|
|
//启用layout动画效果的下拉刷新,能够手动刷新
|
fun needSwipeRefresh():Boolean
|
|
fun onRefreshRequested()
|
|
fun getColorList(): Array<Int>
|
|
}
|