package cn.flightfeather.thirdappmodule.module.home
|
|
import android.arch.lifecycle.ViewModelProviders
|
import android.content.Intent
|
import android.os.Bundle
|
import android.support.v4.app.Fragment
|
import android.view.LayoutInflater
|
import android.view.View
|
import android.view.ViewGroup
|
import android.widget.ImageView
|
import android.widget.LinearLayout
|
import android.widget.TextView
|
import android.widget.Toast
|
import butterknife.ButterKnife
|
import butterknife.Unbinder
|
import cn.flightfeather.thirdappmodule.CommonApplication
|
import cn.flightfeather.thirdappmodule.R
|
import cn.flightfeather.thirdappmodule.bean.entity.Scense
|
import cn.flightfeather.thirdappmodule.bean.entity.Subtask
|
import cn.flightfeather.thirdappmodule.bean.vo.InspectionInfoVo
|
import cn.flightfeather.thirdappmodule.bean.vo.RankVo
|
import cn.flightfeather.thirdappmodule.bean.vo.RankVo.SceneRank
|
import cn.flightfeather.thirdappmodule.bean.vo.TaskVo
|
import cn.flightfeather.thirdappmodule.common.net.ResultCallBack
|
import cn.flightfeather.thirdappmodule.module.dataanalysis.AnalysisOverViewFragment.Companion.rankS
|
import cn.flightfeather.thirdappmodule.httpservice.InspectionService
|
import cn.flightfeather.thirdappmodule.httpservice.TaskService
|
import cn.flightfeather.thirdappmodule.model.bean.NightWorkFileVo
|
import cn.flightfeather.thirdappmodule.module.nightwork.NightWorkRecordActivity
|
import cn.flightfeather.thirdappmodule.module.nightwork.NightWorkViewModel
|
import cn.flightfeather.thirdappmodule.util.Constant
|
import cn.flightfeather.thirdappmodule.util.DateFormatter
|
import com.amap.api.location.AMapLocationClient
|
import com.amap.api.location.AMapLocationClientOption
|
import com.amap.api.location.AMapLocationListener
|
import com.amap.api.services.weather.LocalWeatherForecastResult
|
import com.amap.api.services.weather.LocalWeatherLiveResult
|
import com.amap.api.services.weather.WeatherSearch
|
import com.amap.api.services.weather.WeatherSearch.OnWeatherSearchListener
|
import com.amap.api.services.weather.WeatherSearchQuery
|
import com.ping.greendao.gen.ScenseDao
|
import kotlinx.android.synthetic.main.function_card1_scene.*
|
import kotlinx.android.synthetic.main.function_card3_scene.*
|
import kotlinx.android.synthetic.main.function_card4_scene.*
|
import kotlinx.android.synthetic.main.function_card5_scene.*
|
import retrofit2.Call
|
import retrofit2.Callback
|
import retrofit2.Response
|
import java.text.ParseException
|
import java.util.*
|
|
/**
|
* A simple [Fragment] subclass.
|
*/
|
class HomeFragment_scene : Fragment(), OnWeatherSearchListener, View.OnClickListener {
|
private var tv_location: TextView? = null
|
private var iv_weather_icon: ImageView? = null
|
private var tv_temperature: TextView? = null
|
private var tv_weather: TextView? = null
|
private var ll_weatherBG: LinearLayout? = null
|
private var tv_timeCurrent: TextView? = null
|
private var sv_home_page: View? = null
|
private var hidden = false
|
private var application: CommonApplication? = null
|
|
//定位相关
|
private var mLocationClient: AMapLocationClient? = null
|
|
//查询天气相关
|
private var searchWeather = true
|
private var query: WeatherSearchQuery? = null
|
private var mweathersearch: WeatherSearch? = null
|
private var temperature: String? = null
|
private var weather: String? = null
|
|
//
|
private var viewHolder1: ViewHolder1? = null
|
private var viewHolder2: ViewHolder2? = null
|
private var viewHolder3: ViewHolder3? = null
|
private var viewHolder4: ViewHolder4? = null
|
private var viewHolder5: ViewHolder5? = null
|
|
//ViewHolder1(今日任务)
|
private val subtaskListOfUser = ArrayList<Subtask>()
|
|
//是否在切换回来时刷新
|
private var isUnHiddenRefresh = false
|
private var unbinder: Unbinder? = null
|
private var viewModel: NightWorkViewModel? = null
|
override fun onCreateView(
|
inflater: LayoutInflater, container: ViewGroup?,
|
savedInstanceState: Bundle?
|
): View? {
|
viewModel = ViewModelProviders.of(this).get(NightWorkViewModel::class.java)
|
// Inflate the layout for this fragment
|
val view = inflater.inflate(R.layout.fragment_home_pollution_scene, container, false)
|
unbinder = ButterKnife.bind(this, view)
|
return view
|
}
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
super.onViewCreated(view, savedInstanceState)
|
searchWeather = true
|
initData()
|
initUI(view)
|
initCurLocation()
|
initCurrentTime()
|
initScrollView(savedInstanceState)
|
initClickListener()
|
}
|
|
override fun onDestroy() {
|
if (unbinder != null) {
|
unbinder!!.unbind()
|
}
|
super.onDestroy()
|
mLocationClient!!.onDestroy()
|
}
|
|
override fun onPause() {
|
super.onPause()
|
mLocationClient!!.stopLocation()
|
searchWeather = true
|
}
|
|
override fun onResume() {
|
super.onResume()
|
if (!hidden) {
|
mLocationClient!!.startLocation()
|
initCurrentTime()
|
}
|
// refreshView();
|
}
|
|
override fun onStart() {
|
super.onStart()
|
}
|
|
private fun initData() {
|
application = activity!!.application as CommonApplication
|
}
|
|
private fun initUI(view: View) {
|
tv_location = view.findViewById<View>(R.id.tv_location) as TextView
|
tv_location!!.setOnClickListener(this)
|
iv_weather_icon = view.findViewById<View>(R.id.iv_weather_icon) as ImageView
|
//
|
iv_weather_icon!!.setOnClickListener(this)
|
//
|
tv_temperature = view.findViewById<View>(R.id.tv_temperature) as TextView
|
tv_weather = view.findViewById<View>(R.id.tv_weather) as TextView
|
ll_weatherBG = view.findViewById<View>(R.id.ll_weather_bg) as LinearLayout
|
tv_timeCurrent = view.findViewById<View>(R.id.tv_now_date_time) as TextView
|
sv_home_page = view.findViewById(R.id.sv_home_page)
|
}
|
|
//初始化时间textView
|
private fun initCurrentTime() {
|
val calendar = Calendar.getInstance()
|
tv_timeCurrent!!.text = DateFormatter.dateFormatWeek.format(calendar.time)
|
}
|
|
private fun initScrollView(savedInstanceState: Bundle?) {
|
// sv_home_page.setLayoutManager(new LinearLayoutManager(getContext()));
|
// parentAdapter = new RecyclerViewAdapter(getContext(),savedInstanceState);
|
// sv_home_page.setAdapter(parentAdapter);
|
viewHolder1 = ViewHolder1(savedInstanceState, sv_home_page)
|
viewHolder2 = ViewHolder2(savedInstanceState, sv_home_page)
|
viewHolder3 = ViewHolder3(savedInstanceState, sv_home_page)
|
viewHolder4 = ViewHolder4(savedInstanceState, sv_home_page)
|
viewHolder5 = ViewHolder5()
|
viewHolder1!!.initViewHolder1()
|
viewHolder1!!.refreshView()
|
viewHolder2!!.refreshView()
|
// viewHolder3.initViewHolder3();
|
viewHolder5!!.init()
|
}
|
|
private fun initCurLocation() {
|
val curLocation: String? = null
|
//声明定位回调监听器
|
val mLocationListener = AMapLocationListener { aMapLocation ->
|
if (aMapLocation != null) {
|
if (aMapLocation.errorCode == 0) {
|
//可在其中解析amapLocation获取相应内容
|
//城市地址
|
val address = aMapLocation.address
|
tv_location!!.text = address
|
searchWeather(aMapLocation.city)
|
} else {
|
// Toast.makeText(getActivity(), "定位失败,请检查网络", Toast.LENGTH_SHORT).show();
|
}
|
}
|
}
|
//初始化定位
|
mLocationClient = AMapLocationClient(activity!!.applicationContext)
|
//设置定位回调监听
|
mLocationClient!!.setLocationListener(mLocationListener)
|
//声明AMapLocationClientOption对象
|
var mLocationOption: AMapLocationClientOption? = null
|
//初始化AMapLocationClientOption对象
|
mLocationOption = AMapLocationClientOption()
|
//设置定位模式为AMapLocationMode.Hight_Accuracy,高精度模式。
|
mLocationOption.locationMode = AMapLocationClientOption.AMapLocationMode.Hight_Accuracy
|
//设置定位模式为AMapLocationMode.Battery_Saving,低功耗模式。
|
mLocationOption.locationMode = AMapLocationClientOption.AMapLocationMode.Battery_Saving
|
//设置定位间隔,单位毫秒,默认为2000ms,最低1000ms。
|
mLocationOption.interval = 10000
|
//设置是否返回地址信息(默认返回地址信息)
|
mLocationOption.isNeedAddress = true
|
//设置是否强制刷新WIFI,默认为true,强制刷新。
|
mLocationOption.isWifiActiveScan = true
|
//设置是否允许模拟位置,默认为true,允许模拟位置
|
mLocationOption.isMockEnable = true
|
//关闭缓存机制
|
mLocationOption.isLocationCacheEnable = false
|
//给定位客户端对象设置定位参数
|
mLocationClient!!.setLocationOption(mLocationOption)
|
//启动定位
|
mLocationClient!!.startLocation()
|
}
|
|
//根据城市搜索天气
|
private fun searchWeather(city: String) {
|
query = WeatherSearchQuery(city, WeatherSearchQuery.WEATHER_TYPE_LIVE)
|
mweathersearch = WeatherSearch(context)
|
mweathersearch!!.setOnWeatherSearchListener(this)
|
mweathersearch!!.query = query
|
mweathersearch!!.searchWeatherAsyn() //异步搜索
|
}
|
|
override fun onHiddenChanged(hidden: Boolean) {
|
super.onHiddenChanged(hidden)
|
this.hidden = hidden
|
if (hidden) {
|
mLocationClient!!.stopLocation()
|
searchWeather = true
|
} else {
|
mLocationClient!!.startLocation()
|
initCurrentTime()
|
// viewHolder2.clearView();
|
// refreshView();
|
if (isUnHiddenRefresh) {
|
refreshView()
|
isUnHiddenRefresh = !isUnHiddenRefresh
|
}
|
}
|
}
|
|
//设置是否在切换回来时刷新
|
fun setUnHiddenRefresh(unHiddenRefresh: Boolean) {
|
isUnHiddenRefresh = unHiddenRefresh
|
}
|
|
override fun onWeatherLiveSearched(localWeatherLiveResult: LocalWeatherLiveResult, i: Int) {
|
if (searchWeather) {
|
if (i == 1000) {
|
if (localWeatherLiveResult != null || localWeatherLiveResult.liveResult != null) {
|
val weatherlive = localWeatherLiveResult.liveResult
|
temperature = weatherlive.temperature + "°"
|
weather = weatherlive.weather.trim { it <= ' ' }
|
tv_weather!!.text = weather
|
tv_temperature!!.text = temperature
|
if (weather != null && weather!!.trim { it <= ' ' } != "") {
|
if (weather == "多云") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_1)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_cloudy)
|
} else if (weather == "晴") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_0)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_sunny)
|
} else if (weather == "阴") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_2)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_cloudy)
|
} else if (weather == "小雨") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_3)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain)
|
} else if (weather == "中雨") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_4)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain)
|
} else if (weather == "大雨") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_5)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain)
|
} else if (weather == "阵雨") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_8)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain)
|
} else if (weather == "雨夹雪") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_15)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain)
|
} else if (weather == "小雪") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_9)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain)
|
} else if (weather == "中雪") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_10)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain)
|
} else if (weather == "大雪") {
|
iv_weather_icon!!.setBackgroundResource(R.drawable.weather_icon_11)
|
ll_weatherBG!!.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain)
|
}
|
}
|
searchWeather = false
|
}
|
}
|
}
|
}
|
|
override fun onWeatherForecastSearched(localWeatherForecastResult: LocalWeatherForecastResult, i: Int) {}
|
override fun onClick(view: View) {
|
val id = view.id
|
if (id == R.id.iv_weather_icon) {
|
Toast.makeText(context, "打开天气详情", Toast.LENGTH_SHORT).show()
|
} else if (id == R.id.btn_search) {
|
refreshView()
|
}
|
}
|
|
enum class ITEM_TYPE {
|
ITEM1, ITEM2, ITEM3, ITEM4, ITEM5 {
|
|
}
|
}
|
|
fun refreshView() {
|
viewHolder1!!.initViewHolder1()
|
viewHolder1!!.refreshView()
|
viewHolder2!!.refreshView()
|
}
|
|
/**
|
* 返回当前用户执行的子任务列表
|
* @param msubtaskList
|
* @return
|
*/
|
fun getmSubtaskListOfUser(msubtaskList: List<Subtask>): ArrayList<Subtask> {
|
if (application!!.currentUser.usertypeid.toInt() == 2) { //主管部门的任务展示按照区县划分
|
subtaskListOfUser.clear()
|
for (subtask in msubtaskList) {
|
if (subtask.districtcode == application!!.currentUser.dguid){} //区县行政编码判定,只显示对应区县的任务
|
subtaskListOfUser.add(subtask)
|
}
|
}
|
return subtaskListOfUser
|
}
|
|
//<editor-fold desc="ViewHolder1">
|
private val taskVoList: MutableList<TaskVo> = ArrayList() //用户场景对应的区县所有的顶层任务
|
private var curScene = Scense() //当前用户对应的场景信息
|
private var lastMonthRank = 0//上月排名
|
private var monthBeforeLastMonthRank = 0//上上月排名
|
|
inner class ViewHolder1 internal constructor(savedInstanceState: Bundle?, itemView: View?) {
|
fun initViewHolder1() {
|
val s1 = if (lastMonthRank == 0 || lastMonthRank > 99) "您上月无排名" else "您上月排名第" + lastMonthRank + "名"
|
var s2 = "无排名对比"
|
text_rank_detail_3!!.setText(R.string.rank_tip_4)
|
|
//<editor-fold desc="填写排名">
|
if (lastMonthRank == 0 || lastMonthRank > 99) {
|
text_rank!!.text = "--"
|
} else if (lastMonthRank in 1..9) {
|
val tmp = "0$lastMonthRank"
|
text_rank!!.text = tmp
|
} else {
|
text_rank!!.text = lastMonthRank.toString()
|
}
|
//</editor-fold>
|
if (lastMonthRank == 0
|
|| monthBeforeLastMonthRank == 0
|
) {
|
image_rank!!.setImageResource(R.drawable.icon_rank_no_change_2)
|
} else {
|
if (lastMonthRank == monthBeforeLastMonthRank) {
|
image_rank!!.setImageResource(R.drawable.icon_rank_no_change_2)
|
s2 = "较上上月排名无变化"
|
text_rank_detail_3!!.setText(R.string.rank_tip_3)
|
} else if (lastMonthRank - monthBeforeLastMonthRank > 0) {
|
image_rank!!.setImageResource(R.drawable.icon_rank_down_2)
|
s2 = "较上上月排名下降" + (lastMonthRank - monthBeforeLastMonthRank) + "名"
|
text_rank_detail_3!!.setText(R.string.rank_tip_2)
|
} else {
|
image_rank!!.setImageResource(R.drawable.icon_rank_up_2)
|
s2 = "较上上月排名上升" + (monthBeforeLastMonthRank - lastMonthRank) + "名"
|
text_rank_detail_3!!.setText(R.string.rank_tip_1)
|
}
|
}
|
text_rank_detail_1!!.text = s1
|
text_rank_detail_2!!.text = s2
|
}
|
|
fun refreshView() {
|
taskList
|
}//主管部门的部门id就是区县id//返回结果默认按时间降序排序
|
|
//顶层任务
|
val taskList: Unit
|
get() {
|
val scenseDao = application!!.daoSession.scenseDao
|
val sceneId = application!!.currentUser.dguid
|
val scenses = scenseDao.queryBuilder()
|
.where(
|
ScenseDao.Properties.Guid.eq(
|
sceneId ?: ""
|
)
|
).list()
|
if (!scenses.isEmpty()) {
|
curScene = scenses[0]
|
}
|
//顶层任务
|
val getTopClassTaskList = application!!.retrofit.create(TaskService::class.java).getTopClassTaskList(0)
|
val finalScense = curScene
|
getTopClassTaskList.enqueue(object : Callback<ArrayList<TaskVo>?> {
|
override fun onResponse(call: Call<ArrayList<TaskVo>?>, response: Response<ArrayList<TaskVo>?>) {
|
if (response.body() != null) {
|
val allTaskVoList: List<TaskVo>? = response.body() //返回结果默认按时间降序排序
|
for (t in allTaskVoList!!) {
|
if (t.districtcode == finalScense.districtcode) { //主管部门的部门id就是区县id
|
taskVoList.add(t)
|
}
|
}
|
val now = Date()
|
if (taskVoList.size >= 2 && taskVoList[0].starttime.before(now)) {
|
getRank(taskVoList[1])
|
viewHolder3!!.refreshView()
|
}
|
}
|
}
|
|
override fun onFailure(call: Call<ArrayList<TaskVo>?>, t: Throwable) {}
|
})
|
}
|
private var isDone = false //需要分别查询上月与上上月客户场景的排名,以便做比较
|
fun getRank(taskVo: TaskVo) {
|
val getRank = application!!.retrofit.create(TaskService::class.java).getRank(taskVo.tguid, curScene.typeid.toString(), curScene.guid)
|
getRank.enqueue(object : Callback<RankVo?> {
|
override fun onResponse(call: Call<RankVo?>, response: Response<RankVo?>) {
|
if (response.body() != null) {
|
//上月排名
|
if (!isDone) {
|
val rankVo = response.body()
|
val sceneRanks: List<SceneRank?> = rankVo!!.sceneRanks
|
rankS(sceneRanks)
|
for (i in sceneRanks.indices) {
|
if (curScene.guid == sceneRanks[i]!!.sceneNameId && sceneRanks[i]!!.score > -1) {
|
lastMonthRank = sceneRanks[i]!!.rankNo //上月排名
|
initViewHolder1()
|
break
|
}
|
}
|
if (taskVoList.size >= 3) {
|
isDone = true
|
getRank(taskVoList[2])
|
}
|
} else {
|
val rankVo = response.body()
|
val sceneRanks: List<SceneRank?> = rankVo!!.sceneRanks
|
rankS(sceneRanks)
|
for (i in sceneRanks.indices) {
|
if (curScene.guid == sceneRanks[i]!!.sceneNameId && sceneRanks[i]!!.score > -1) {
|
monthBeforeLastMonthRank = sceneRanks[i]!!.rankNo //上上月排名
|
initViewHolder1()
|
break
|
}
|
}
|
isDone = false
|
}
|
}
|
}
|
|
override fun onFailure(call: Call<RankVo?>, t: Throwable) {}
|
})
|
}
|
}
|
|
//</editor-fold>
|
|
//<editor-fold desc="ViewHolder2">
|
inner class ViewHolder2 internal constructor(savedInstanceState: Bundle?, itemView: View?) {
|
fun refreshView() {
|
initViewholder2()
|
}
|
|
private fun initViewholder2() {}
|
}
|
|
//</editor-fold>
|
|
//<editor-fold desc="ViewHolder3">
|
inner class ViewHolder3 internal constructor(savedInstanceState: Bundle?, itemView: View?) {
|
fun refreshView() {
|
initViewHolder3()
|
}
|
|
/**
|
* 在[ViewHolder1.getRank]第一次被调用后(确保当前场景在当前时间有对应的顶层任务),才会调用此函数
|
*/
|
private fun initViewHolder3() {
|
val sceneId = application!!.currentUser.dguid
|
val topTaskId = taskVoList[0].tguid
|
val getInspectionInfoByScene = application!!.retrofit.create(InspectionService::class.java).getInspectionInfoByScene(sceneId, topTaskId)
|
getInspectionInfoByScene.enqueue(object : Callback<InspectionInfoVo?> {
|
override fun onResponse(call: Call<InspectionInfoVo?>, response: Response<InspectionInfoVo?>) {
|
if (response.body() != null) {
|
initView(response.body())
|
viewHolder4!!.refreshView(response.body())
|
}
|
}
|
|
override fun onFailure(call: Call<InspectionInfoVo?>, t: Throwable) {}
|
})
|
}
|
|
fun initView(infoVo: InspectionInfoVo?) {
|
//已巡查
|
if (infoVo!!.isInspected) {
|
text_no_supervise_tips!!.visibility = View.INVISIBLE
|
cl_1!!.visibility = View.VISIBLE
|
cl_2!!.visibility = View.VISIBLE
|
image_inspection_status!!.isSelected = true
|
text_inspection_time!!.text = infoVo.inspectionTime
|
text_inspection_times!!.text = (
|
infoVo.unChangedCount + infoVo.changedCount
|
).toString()
|
text_change_promise!!.isSelected = infoVo.isPromised
|
text_change_promise!!.setText(if (infoVo.isPromised) R.string.promised else R.string.refused)
|
text_change_status!!.isSelected = infoVo.isChanged
|
text_change_status!!.setText(if (infoVo.isChanged) R.string.changed else R.string.unchanged)
|
} else {
|
text_no_supervise_tips!!.visibility = View.VISIBLE
|
cl_1!!.visibility = View.GONE
|
cl_2!!.visibility = View.INVISIBLE
|
image_inspection_status!!.isSelected = false
|
}
|
}
|
}
|
|
//</editor-fold>
|
|
//<editor-fold desc="ViewHolder4">
|
inner class ViewHolder4 internal constructor(savedInstanceState: Bundle?, itemView: View?) {
|
fun refreshView(infoVo: InspectionInfoVo?) {
|
initViewHolder4(infoVo)
|
}
|
|
/**
|
* 在[ViewHolder3.initViewHolder3]函数第一次被调用后,才能调用此函数
|
*/
|
fun initViewHolder4(infoVo: InspectionInfoVo?) {
|
text_change_count!!.text = infoVo!!.unChangedCount.toString()
|
text_changed_count!!.text = infoVo.changedCount.toString()
|
val promisedTime = infoVo.promisedTime
|
try {
|
//未整改完成
|
if (infoVo.unChangedCount > 0) {
|
var promisedTime_d: Date? = null
|
promisedTime_d = if (promisedTime == null || promisedTime.equals("null", ignoreCase = true)) {
|
DateFormatter.dateFormat2.parse(infoVo.inspectionTime)
|
} else {
|
DateFormatter.dateFormat.parse(promisedTime)
|
}
|
val calendar = Calendar.getInstance()
|
calendar[Calendar.HOUR_OF_DAY] = 0
|
calendar[Calendar.MINUTE] = 0
|
calendar[Calendar.SECOND] = 0
|
val today = calendar.time
|
val leftDays = (promisedTime_d.time - today.time).toInt() / 1000 / 60 / 60 / 24
|
if (leftDays >= 0) {
|
text_change_left_day!!.text = leftDays.toString()
|
} else {
|
text_change_info!!.text = "您已逾期"
|
text_change_left_day.text = (-leftDays).toString()
|
}
|
group_deadline!!.visibility = View.VISIBLE
|
image_done!!.visibility = View.GONE
|
} else {
|
group_deadline!!.visibility = View.GONE
|
image_done!!.visibility = View.VISIBLE
|
}
|
} catch (e: ParseException) {
|
e.printStackTrace()
|
}
|
}
|
}
|
|
//</editor-fold>
|
|
inner class ViewHolder5 {
|
fun init() {
|
cl_night_work!!.setOnClickListener { v: View? -> startActivity(Intent(context, NightWorkRecordActivity::class.java)) }
|
viewModel!!.getNightWorkFile(false, 1, object : ResultCallBack<List<NightWorkFileVo>> {
|
override fun onCacheSuccess(result: List<NightWorkFileVo>?) {}
|
override fun onPage(current: Int, total: Int) {}
|
override fun onSuccess(result: List<NightWorkFileVo>?) {
|
if (result == null || result.isEmpty()) {
|
txt_news!!.text = "暂无新许可证"
|
} else {
|
txt_news!!.text = "有新许可证下发,请查看"
|
}
|
}
|
|
override fun onFailure() {
|
txt_news!!.text = "网络连接失败,请退出重试"
|
}
|
})
|
}
|
}
|
|
//<editor-fold desc="点击事件">
|
private fun initClickListener() {
|
card_change_problem.setOnClickListener { onChangeProblem() }
|
card_changed_problem.setOnClickListener { onChangeProblem() }
|
}
|
private fun onChangeProblem() {
|
val intent = Intent("cn.flightfeather.thirdapp.broadcasereceiver.MainReceiver")
|
intent.action = Constant.GOTO_INSPECTION_FRAGMENT
|
activity!!.sendBroadcast(intent)
|
}
|
//</editor-fold>
|
}
|