package com.fuban.user.ui.crosscity
|
|
import android.app.Activity
|
import android.content.BroadcastReceiver
|
import android.content.Context
|
import android.content.Intent
|
import android.content.IntentFilter
|
import androidx.recyclerview.widget.LinearLayoutManager
|
import cn.sinata.xldutils.view.SwipeRefreshRecyclerLayout
|
import com.fuban.user.R
|
import com.fuban.user.network.entity.Line
|
import com.fuban.user.ui.TransparentStatusBarActivity
|
import com.fuban.user.ui.crosscity.adapter.LineAdapter
|
import org.jetbrains.anko.find
|
import org.jetbrains.anko.startActivity
|
|
class ChooseLineActivity :TransparentStatusBarActivity(){
|
override fun setContentView() = R.layout.base_recyclerview_layout
|
|
private val lvLine by lazy {
|
find<SwipeRefreshRecyclerLayout>(R.id.swipeRefreshLayout)
|
}
|
private val datas by lazy {
|
intent.getParcelableArrayListExtra<Line>("data")
|
}
|
private val adapter by lazy {
|
LineAdapter(datas)
|
}
|
private val isScan by lazy { //是否扫码下单
|
intent.getBooleanExtra("isScan",false)
|
}
|
private var receiver: BroadcastReceiver? = null
|
|
override fun initClick() {
|
adapter.setOnItemClickListener { view, position ->
|
if (isScan){
|
setResult(Activity.RESULT_OK,intent.putExtra("line" , datas[position]))
|
finish()
|
} else
|
startActivity<ShiftActivity>("data" to datas[position],
|
"startCity" to intent.getStringExtra("startCity"),
|
"endCity" to intent.getStringExtra("endCity"),
|
"startId" to intent.getIntExtra("startId",0),
|
"endId" to intent.getIntExtra("endId",0))
|
}
|
}
|
|
override fun initView() {
|
title = "选择线路"
|
lvLine.setPadding(0,2,0,0)
|
lvLine.setLayoutManager(LinearLayoutManager(this))
|
lvLine.setMode(SwipeRefreshRecyclerLayout.Mode.None)
|
lvLine.setAdapter(adapter)
|
receiver = object :BroadcastReceiver() {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
finish()
|
}
|
}
|
registerReceiver(receiver, IntentFilter("crossOrderSuccess"))
|
}
|
|
override fun onDestroy() {
|
super.onDestroy()
|
if (receiver!=null)
|
unregisterReceiver(receiver)
|
}
|
}
|