parent
2f15a3456c
commit
dc4e577934
@ -0,0 +1,41 @@
|
|||||||
|
package com.rehome.dywoa.adapter
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.rehome.dywoa.base.BaseViewBindingAdapter
|
||||||
|
import com.rehome.dywoa.bean.CurrentDayDjBean
|
||||||
|
import com.rehome.dywoa.bean.YjyaListBean
|
||||||
|
import com.rehome.dywoa.databinding.AdapterCurrentDayDjBinding
|
||||||
|
import com.rehome.dywoa.databinding.AdapterYjyaListBinding
|
||||||
|
|
||||||
|
class YjyaListAdapter(var context: Context,
|
||||||
|
var data: MutableList<YjyaListBean.Row>) : BaseViewBindingAdapter<AdapterYjyaListBinding>(context) {
|
||||||
|
|
||||||
|
override fun getCount(): Int {
|
||||||
|
return data.count()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItem(position: Int): Any {
|
||||||
|
return data[position]
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemId(position: Int): Long {
|
||||||
|
return position.toLong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getBinding(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
parent: ViewGroup?
|
||||||
|
) = AdapterYjyaListBinding.inflate(inflater, parent, false)
|
||||||
|
override fun handleData(position: Int, binding: AdapterYjyaListBinding) {
|
||||||
|
val item: YjyaListBean.Row = data[position]
|
||||||
|
binding.tvYamc.text = item.title
|
||||||
|
binding.tvType.text = item.type
|
||||||
|
binding.tvLevel.text = item.yadj
|
||||||
|
binding.tvZt.text = item.zt
|
||||||
|
binding.tvQdr.text = item.qdr
|
||||||
|
binding.tvEndDate.text = item.startDate
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
package com.rehome.dywoa.bean;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class YjyaListBean extends BaseListBean{
|
||||||
|
|
||||||
|
private List<Row> Rows;
|
||||||
|
|
||||||
|
public List<Row> getRows() {
|
||||||
|
return Rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRows(List<Row> rows) {
|
||||||
|
Rows = rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Row {
|
||||||
|
private String ID;
|
||||||
|
private String TITLE;
|
||||||
|
private String ZT;
|
||||||
|
private String QDR;
|
||||||
|
private String TYPE;
|
||||||
|
private String YADJ;
|
||||||
|
private String startDate;
|
||||||
|
|
||||||
|
public String getID() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setID(String ID) {
|
||||||
|
this.ID = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTITLE() {
|
||||||
|
return TITLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTITLE(String TITLE) {
|
||||||
|
this.TITLE = TITLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getZT() {
|
||||||
|
return ZT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZT(String ZT) {
|
||||||
|
this.ZT = ZT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQDR() {
|
||||||
|
return QDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQDR(String QDR) {
|
||||||
|
this.QDR = QDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTYPE() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTYPE(String TYPE) {
|
||||||
|
this.TYPE = TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYADJ() {
|
||||||
|
return YADJ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYADJ(String YADJ) {
|
||||||
|
this.YADJ = YADJ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(String startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,133 @@
|
|||||||
|
package com.rehome.dywoa.ui.activity
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import com.rehome.dywoa.App
|
||||||
|
import com.rehome.dywoa.Contans
|
||||||
|
import com.rehome.dywoa.R
|
||||||
|
import com.rehome.dywoa.adapter.CurrentDayDjAdapter
|
||||||
|
import com.rehome.dywoa.adapter.YjyaListAdapter
|
||||||
|
import com.rehome.dywoa.base.BaseActivityOaToolbarViewBinding
|
||||||
|
import com.rehome.dywoa.bean.CurrentDayDjBean
|
||||||
|
import com.rehome.dywoa.bean.YjyaListBean
|
||||||
|
import com.rehome.dywoa.databinding.ActivityYjyaBinding
|
||||||
|
import com.rehome.dywoa.utils.GsonUtils
|
||||||
|
import com.rehome.dywoa.utils.HttpListener
|
||||||
|
import com.rehome.dywoa.utils.NoProgresshttpUtils
|
||||||
|
import com.rehome.dywoa.utils.NohttpUtils
|
||||||
|
import com.rehome.dywoa.weiget.OAToolbar
|
||||||
|
import com.yolanda.nohttp.NoHttp
|
||||||
|
import com.yolanda.nohttp.RequestMethod
|
||||||
|
import com.yolanda.nohttp.rest.Response
|
||||||
|
|
||||||
|
class YjyaActivity : BaseActivityOaToolbarViewBinding<ActivityYjyaBinding>() {
|
||||||
|
|
||||||
|
private lateinit var adapter: YjyaListAdapter
|
||||||
|
private var datas: MutableList<YjyaListBean.Row> = mutableListOf()
|
||||||
|
private lateinit var username: String
|
||||||
|
|
||||||
|
override fun getViewBinding() = ActivityYjyaBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
|
override fun getToolbar() = binding.toolbarView.toolbar
|
||||||
|
|
||||||
|
override fun initView() {
|
||||||
|
|
||||||
|
initToolbar("应急预案", "") {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
username = App.getInstance().userInfo.manid
|
||||||
|
adapter = YjyaListAdapter(context, datas)
|
||||||
|
binding.lv.adapter = adapter
|
||||||
|
|
||||||
|
binding.tvNodata.visibility= View.VISIBLE
|
||||||
|
binding.lv.visibility= View.GONE
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun initData() {
|
||||||
|
//检查服务器连接状态
|
||||||
|
checkServerConnectStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
//检查服务器连接状态
|
||||||
|
private fun checkServerConnectStatus() {
|
||||||
|
var param = HashMap<String,String>()
|
||||||
|
param["login"] = "dywoa";
|
||||||
|
val json = GsonUtils.GsonString(param)
|
||||||
|
val url = Contans.IP + Contans.check_server_connect
|
||||||
|
Log.i("app",url)
|
||||||
|
Log.i("app",json)
|
||||||
|
val request = NoHttp.createStringRequest(
|
||||||
|
url,
|
||||||
|
RequestMethod.POST
|
||||||
|
)
|
||||||
|
request.setDefineRequestBodyForJson(json)
|
||||||
|
NoProgresshttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
||||||
|
override fun onSucceed(what: Int, response: Response<String?>?) {
|
||||||
|
val result = response?.get()
|
||||||
|
if (result != null) {
|
||||||
|
showLog("-----onSucceed----")
|
||||||
|
showLog(result)
|
||||||
|
if(result == "1"){
|
||||||
|
showLog("connect server success")
|
||||||
|
//获取数据
|
||||||
|
getListData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailed(what: Int, response: Response<String?>?) {
|
||||||
|
showLog("connect server onFailed")
|
||||||
|
showToast("无法连接到服务器,请检查网络环境")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getListData() {
|
||||||
|
|
||||||
|
var param = HashMap<String,String>()
|
||||||
|
//param["GH"] = username
|
||||||
|
param["GH"] = "sysadmin"
|
||||||
|
val json = GsonUtils.GsonString(param)
|
||||||
|
|
||||||
|
val url: String = Contans.IP + Contans.YJYA_GET_LIST_TJ
|
||||||
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
||||||
|
request.setDefineRequestBodyForJson(json)
|
||||||
|
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String> {
|
||||||
|
override fun onSucceed(what: Int, response: Response<String>?) {
|
||||||
|
if (response != null) {
|
||||||
|
val result = response.get()
|
||||||
|
showLog(result)
|
||||||
|
val bean = GsonUtils.GsonToBean(result, YjyaListBean::class.java)
|
||||||
|
if (bean != null && bean.total != 0) {
|
||||||
|
if (bean.rows != null && bean.rows.size>0) {
|
||||||
|
datas.clear()
|
||||||
|
datas.addAll(bean.rows)
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
binding.tvNodata.visibility= View.GONE
|
||||||
|
binding.lv.visibility=View.VISIBLE
|
||||||
|
}else {
|
||||||
|
datas.clear()
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
binding.tvNodata.visibility= View.VISIBLE
|
||||||
|
binding.lv.visibility=View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailed(what: Int, response: Response<String>?) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, true, true, "正在加载数据...")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".ui.activity.YjyaActivity">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/toolbarView"
|
||||||
|
android:visibility="visible"
|
||||||
|
layout="@layout/layout_base" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/lv"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:divider="@color/gray"
|
||||||
|
android:dividerHeight="1dp" />
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_nodata"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="暂无数据" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
</LinearLayout>
|
||||||
@ -0,0 +1,162 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/ll"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10px"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="60px">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="50px"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="预案名称:"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_yamc"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center|left"
|
||||||
|
android:minHeight="50px"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="60px">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="50px"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="预案类型:"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_type"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center|left"
|
||||||
|
android:minHeight="50px"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="60px">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="50px"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="预案等级:"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_level"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center|left"
|
||||||
|
android:minHeight="50px"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="60px">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="50px"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="状态:"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_zt"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center|left"
|
||||||
|
android:minHeight="50px"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="60px"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="50px"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="启动人:"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_qdr"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center|left"
|
||||||
|
android:minHeight="50px"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="60px">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="50px"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="启动时间:"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_end_date"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5px"
|
||||||
|
android:gravity="center|left"
|
||||||
|
android:minHeight="50px"
|
||||||
|
android:textSize="30px"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
Loading…
Reference in New Issue