package com.yidian.common

import android.app.Activity
import android.app.Application
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.header.ClassicsHeader
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.scwang.smart.refresh.layout.constant.SpinnerStyle

open class YdBaseApplication : Application() {
  companion object {
    lateinit var context: Application
    var activityList = ArrayList<Activity>()
  }

  override fun onCreate() {
    super.onCreate()
    initSmartRefreshLayout()
  }

  /**
   * 设置刷新 默认的header和footer
   */
  private fun initSmartRefreshLayout() {
    //设置全局的Header构建器
    SmartRefreshLayout.setDefaultRefreshHeaderCreator { context, layout ->
      layout.setPrimaryColorsId(android.R.color.transparent)//全局设置主题颜色
      ClassicsHeader(context) //指定为经典Header，默认是 贝塞尔雷达Header
    }
    //设置全局的Footer构建器
    SmartRefreshLayout.setDefaultRefreshFooterCreator { context, layout ->
      layout.setEnableLoadMoreWhenContentNotFull(true) //内容不满一页时候启用加载更多
      val footer = ClassicsFooter(context)
      footer.setBackgroundResource(android.R.color.transparent)
      footer.setDrawableSize(20f)
      footer.spinnerStyle = SpinnerStyle.FixedBehind //设置为固定在背后模式
      footer //指定为经典Footer，默认是 BallPulseFooter
    }
  }

}
