45 lines
1.2 KiB
Kotlin
45 lines
1.2 KiB
Kotlin
package xyz.mtfos.buywhat
|
|
|
|
import android.app.Activity
|
|
import android.os.Handler
|
|
import android.view.View
|
|
import android.view.ViewGroup
|
|
import android.widget.LinearLayout
|
|
import android.widget.RelativeLayout
|
|
import xyz.mtfos.tools.apiObject
|
|
import xyz.mtfos.tools.objectTool.bind
|
|
|
|
/**
|
|
* Created by jay on 2017/7/6.
|
|
*/
|
|
open class SampleActivity : Activity() {
|
|
protected val api: apiObject = apiObject(this@SampleActivity)
|
|
protected val layMain: RelativeLayout by bind(R.id.layMain)
|
|
protected val layLoading: LinearLayout by bind(R.id.layLoading)
|
|
|
|
fun setViewSource(v: View?) {
|
|
setContentView(v)
|
|
setDynView()
|
|
}
|
|
|
|
fun setViewSource(v: Int) {
|
|
setContentView(v)
|
|
setDynView()
|
|
}
|
|
|
|
fun setDynView() {
|
|
val loadingItem: LinearLayout = layoutInflater.inflate(R.layout.lay_loading, null) as LinearLayout
|
|
|
|
loadingItem.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
|
|
|
layLoading?.addView(loadingItem)
|
|
}
|
|
|
|
fun toggleLoading(flag: Boolean) {
|
|
layLoading?.visibility = if (flag == true) {
|
|
View.VISIBLE
|
|
} else {
|
|
View.GONE
|
|
}
|
|
}
|
|
} |