init: init proj
This commit is contained in:
@@ -0,0 +1,790 @@
|
||||
package com.lukouguoji.aerologic.ui.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
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 androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.lukouguoji.aerologic.R
|
||||
import com.lukouguoji.aerologic.page.accident.visa.list.AccidentVisaListActivity
|
||||
import com.lukouguoji.aerologic.page.car.list.CarListActivity
|
||||
import com.lukouguoji.aerologic.page.flight.query.list.FlightQueryListActivity
|
||||
import com.lukouguoji.aerologic.page.gnj.jiaojie.GnjHandoverListActivity
|
||||
import com.lukouguoji.aerologic.page.gnj.out.stash.list.GnjOutStashListActivity
|
||||
import com.lukouguoji.aerologic.page.gnj.manifest.list.GnjManifestListActivity
|
||||
import com.lukouguoji.aerologic.page.gnj.stash.list.GnjStashListActivity
|
||||
import com.lukouguoji.aerologic.page.gnj.move.stash.list.GnjMoveStashListActivity
|
||||
import com.lukouguoji.aerologic.page.gnj.query.details.GnjQueryDetailsActivity
|
||||
import com.lukouguoji.aerologic.page.gnj.query.list.GnjQueryListActivity
|
||||
import com.lukouguoji.aerologic.page.gnj.unload.list.GnjUnloadListActivity
|
||||
import com.lukouguoji.aerologic.page.log.list.LogListActivity
|
||||
import com.lukouguoji.aerologic.page.message.list.MessageListActivity
|
||||
import com.lukouguoji.aerologic.page.telegram.list.TelegramListActivity
|
||||
import com.lukouguoji.aerologic.page.test.PrintActivity
|
||||
import com.lukouguoji.aerologic.page.transport.GoodsTransportActivity
|
||||
import com.lukouguoji.aerologic.page.transportLog.list.TransportLogActivity
|
||||
import com.lukouguoji.gnc.page.deposit.list.GncDepositListActivity
|
||||
import com.lukouguoji.gnc.page.distribution.home.GncDistributionHomeActivity
|
||||
import com.lukouguoji.gnc.page.fubang.list.GncFuBangListActivity
|
||||
import com.lukouguoji.gnc.page.shouyun.unlist.GncShouYunUnListActivity
|
||||
import com.lukouguoji.module_base.MyApplication
|
||||
import com.lukouguoji.module_base.adapter.loadImage
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
|
||||
class HomeFragment : Fragment() {
|
||||
|
||||
private val TAG: String = HomeFragment::class.java.simpleName
|
||||
|
||||
private var rvLeft: RecyclerView by Delegates.notNull()
|
||||
private var rvRight: RecyclerView by Delegates.notNull()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val inflate = inflater.inflate(R.layout.fragment_home, container, false)
|
||||
rvLeft = inflate.findViewById(R.id.left_menu_list)
|
||||
rvRight = inflate.findViewById(R.id.right_menu_list)
|
||||
return inflate
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val leftMenuList = initLeftMenuData()
|
||||
rvLeft.adapter = HomeLeftAdapt(leftMenuList)
|
||||
rvRight.adapter = HomeRightAdapt(getRightMenu4Id(leftMenuList.first().id))
|
||||
}
|
||||
|
||||
/////////// 左边的list循环
|
||||
inner class HomeLeftAdapt(private val leftMenuList: List<LeftMenu>) :
|
||||
RecyclerView.Adapter<HomeLeftAdapt.ViewHolder>() {
|
||||
|
||||
private var mPosition = 0
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val itemLayout: LinearLayout = view.findViewById(R.id.left_item_layout)
|
||||
val itemImg: ImageView = view.findViewById(R.id.left_item_img)
|
||||
val itemText: TextView = view.findViewById(R.id.left_item_text)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view =
|
||||
LayoutInflater.from(parent.context).inflate(R.layout.home_left_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
val leftMenu = leftMenuList[mPosition]
|
||||
viewHolder.itemView.setOnClickListener {
|
||||
val oldPosition = mPosition
|
||||
mPosition = viewHolder.adapterPosition
|
||||
val leftMenuTemp = leftMenuList[mPosition]
|
||||
|
||||
//航班查询
|
||||
if (Constant.AuthName.Flight == leftMenuTemp.id) {
|
||||
// ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_HANG_BAN_QUERY)
|
||||
// .navigation(activity, Constant.RequestCode.home_left_hang_ban_query)
|
||||
FlightQueryListActivity.start(requireContext())
|
||||
mPosition = oldPosition
|
||||
}
|
||||
//货物查询
|
||||
if (Constant.AuthName.CargoStatus == leftMenuTemp.id) {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_CARGO_TRACKING)
|
||||
.navigation(activity, Constant.RequestCode.home_left_hang_ban_query)
|
||||
mPosition = oldPosition
|
||||
}
|
||||
//其他查询
|
||||
else {
|
||||
}
|
||||
refreshRight(leftMenuList[mPosition].id)
|
||||
|
||||
//更新菜单状态
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
var item = leftMenuList[position]
|
||||
holder.itemText.text = item.text
|
||||
holder.itemImg.setImageResource(item.img)
|
||||
if (mPosition == position) {
|
||||
holder.itemLayout.setBackgroundResource(R.color.white)
|
||||
holder.itemImg.drawable.setTint(
|
||||
MyApplication.context.resources.getColor(
|
||||
R.color.colorPrimary,
|
||||
activity?.theme
|
||||
)
|
||||
)
|
||||
holder.itemText.setTextColor(
|
||||
MyApplication.context.resources.getColor(
|
||||
R.color.colorPrimary,
|
||||
activity?.theme
|
||||
)
|
||||
)
|
||||
} else {
|
||||
holder.itemLayout.setBackgroundResource(R.color.list_bg)
|
||||
holder.itemImg.drawable.setTint(
|
||||
MyApplication.context.resources.getColor(
|
||||
R.color.weak_grey,
|
||||
activity?.theme
|
||||
)
|
||||
)
|
||||
holder.itemText.setTextColor(
|
||||
MyApplication.context.resources.getColor(
|
||||
R.color.weak_grey,
|
||||
activity?.theme
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun getItemCount() = leftMenuList.size
|
||||
}
|
||||
|
||||
inner class LeftMenu(val id: String, val img: Int, val text: String)
|
||||
|
||||
fun initLeftMenuData(): List<LeftMenu> {
|
||||
var list = arrayListOf<LeftMenu>()
|
||||
list.add(LeftMenu(Constant.AuthName.DomExp, R.mipmap.gncn_icon, "国内出港"))
|
||||
list.add(LeftMenu(Constant.AuthName.DomImp, R.mipmap.gnjg, "国内进港"))
|
||||
list.add(LeftMenu(Constant.AuthName.IntExp, R.mipmap.gjcn_icon, "国际出港"))
|
||||
list.add(LeftMenu(Constant.AuthName.IntImp, R.mipmap.gjjn_icon, "国际进港"))
|
||||
list.add(LeftMenu(Constant.AuthName.Flight, R.mipmap.hangban_icon, "航班查询"))
|
||||
list.add(LeftMenu(Constant.AuthName.CargoStatus, R.mipmap.huowu_icon, "货物追踪"))
|
||||
list.add(LeftMenu(Constant.AuthName.Supervision, R.mipmap.monitor_up_down_icon, "监装监卸"))
|
||||
|
||||
list.add(LeftMenu(Constant.AuthName.Comprehensive, R.mipmap.zhgl_icon, "综合管理"))
|
||||
|
||||
/**
|
||||
* 左侧菜单 权限过滤
|
||||
* todo
|
||||
*/
|
||||
getAuthsObj()?.let {
|
||||
val authsFilter = list.filter { m ->
|
||||
it.getJSONArray(m.id) != null && it.getJSONArray(m.id).size > 0
|
||||
}
|
||||
list = authsFilter as ArrayList<LeftMenu>
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
private fun getAuthsObj(): JSONObject? {
|
||||
val authsString = SharedPreferenceUtil.getString(Constant.Share.authList)
|
||||
if (authsString != "") {
|
||||
val authsObj = JSON.parseObject(authsString)
|
||||
return authsObj
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
/////////// 右边的list循环
|
||||
inner class HomeRightAdapt(rightMenuList: List<RightMenu>) :
|
||||
RecyclerView.Adapter<HomeRightAdapt.ViewHolder>() {
|
||||
|
||||
private var rightMenuList = arrayListOf<RightMenu>().apply {
|
||||
addAll(rightMenuList)
|
||||
}
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val itemImg: ImageView = view.findViewById(R.id.right_item_img)
|
||||
val itemText: TextView = view.findViewById(R.id.right_item_text)
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新
|
||||
*/
|
||||
fun refresh(list: List<RightMenu>) {
|
||||
rightMenuList.clear()
|
||||
rightMenuList.addAll(list)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view =
|
||||
LayoutInflater.from(parent.context).inflate(R.layout.home_right_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
|
||||
viewHolder.itemView.setOnClickListener {
|
||||
|
||||
val position = viewHolder.adapterPosition
|
||||
var rightMenu = rightMenuList[position]
|
||||
when (rightMenu.id) {
|
||||
//// 国内出港
|
||||
Constant.AuthName.AppDomExpCheckin -> {
|
||||
GncShouYunUnListActivity.start(requireContext())
|
||||
}
|
||||
|
||||
Constant.AuthName.AppDomExpWeighting -> {
|
||||
GncFuBangListActivity.start(requireContext())
|
||||
}
|
||||
|
||||
Constant.AuthName.AppDomExpTransport -> {
|
||||
ARouter.getInstance()
|
||||
.build(ARouterConstants.ACTIVITY_URL_GOUT_TRANSFER_ACTIVITY)
|
||||
.navigation()
|
||||
}
|
||||
|
||||
Constant.AuthName.AppDomExpWareHouse -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GNC_WAREHOUSE)
|
||||
.navigation()
|
||||
}
|
||||
|
||||
Constant.AuthName.AppDomExpSearch -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GNC_QUERY_LIST)
|
||||
.navigation()
|
||||
}
|
||||
|
||||
Constant.AuthName.AppTest -> {
|
||||
PrintActivity.start(requireContext())
|
||||
}
|
||||
|
||||
Constant.AuthName.AppDomExpAssemble -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GNC_ASSEMBLE_LIST)
|
||||
.navigation()
|
||||
}
|
||||
|
||||
Constant.AuthName.AppDomExpDistribution -> {
|
||||
GncDistributionHomeActivity.start(requireContext())
|
||||
}
|
||||
|
||||
Constant.AuthName.AppDomExpDeposit -> {
|
||||
GncDepositListActivity.start(requireContext())
|
||||
}
|
||||
/**
|
||||
* 国内进港
|
||||
*/
|
||||
//舱单
|
||||
Constant.AuthName.GnjAppDomExpCheckin -> {
|
||||
GnjManifestListActivity.start(requireContext())
|
||||
}
|
||||
//出库
|
||||
Constant.AuthName.GnjChuKuList -> {
|
||||
GnjOutStashListActivity.start(requireContext())
|
||||
}
|
||||
//仓库管理
|
||||
Constant.AuthName.GnjWareHouse -> {
|
||||
GnjStashListActivity.start(requireContext())
|
||||
}
|
||||
//查询 列表
|
||||
Constant.AuthName.GnjQueryList -> {
|
||||
GnjQueryListActivity.start(requireContext())
|
||||
}
|
||||
//入库
|
||||
Constant.AuthName.GnjRuKu -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GNJ_RU_KU)
|
||||
.navigation()
|
||||
}
|
||||
//移库
|
||||
Constant.AuthName.GnjYiKu -> {
|
||||
GnjMoveStashListActivity.start(requireContext())
|
||||
}
|
||||
|
||||
Constant.AuthName.GnjHandover -> {
|
||||
GnjHandoverListActivity.start(requireContext())
|
||||
}
|
||||
/**
|
||||
* 国际出港
|
||||
*/
|
||||
//收运
|
||||
Constant.AuthName.GjcAppDomExpCheckin -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJC_RECEIVE_LIST)
|
||||
.navigation()
|
||||
}
|
||||
//复磅
|
||||
Constant.AuthName.GjcFuBangActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJC_FU_BANG)
|
||||
.navigation()
|
||||
}
|
||||
//仓库
|
||||
Constant.AuthName.GjcWareHouseActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJC_WARE_HOUSE)
|
||||
.navigation()
|
||||
}
|
||||
//查询
|
||||
Constant.AuthName.GjcQueryListActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJC_QUERY_LIST)
|
||||
.navigation()
|
||||
}
|
||||
//移库
|
||||
Constant.AuthName.GjcYiKuListActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJC_YI_KU)
|
||||
.navigation()
|
||||
}
|
||||
// 板箱
|
||||
Constant.AuthName.GjcBanXListActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJC_BOX_ASSEMBLE)
|
||||
.navigation()
|
||||
}
|
||||
// 货物交接
|
||||
Constant.AuthName.GjcGoodsListActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJC_GOODS_LIST)
|
||||
.navigation()
|
||||
}
|
||||
/**
|
||||
* 国际进港
|
||||
*/
|
||||
//舱单
|
||||
Constant.AuthName.GjjCangDanListActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJJ_CANG_DAN_LIST)
|
||||
.navigation()
|
||||
}
|
||||
//仓库
|
||||
Constant.AuthName.GjjWareHouseActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJJ_WARE_HOUSE)
|
||||
.navigation()
|
||||
}
|
||||
//出库
|
||||
Constant.AuthName.GjjChuKuListActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJJ_CHU_KU_LIST)
|
||||
.navigation()
|
||||
}
|
||||
//查询
|
||||
Constant.AuthName.GjjQueryListActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJJ_QUERY_LIST)
|
||||
.navigation()
|
||||
}
|
||||
// 报文解析
|
||||
Constant.AuthName.GjjPacketParseActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJJ_PACKET_PARSE)
|
||||
.navigation()
|
||||
}
|
||||
// 舱单
|
||||
Constant.AuthName.GjjManifestListActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJJ_MANIFEST)
|
||||
.navigation()
|
||||
}
|
||||
// 理货
|
||||
Constant.AuthName.GjjTallyListActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJJ_Tally)
|
||||
.navigation()
|
||||
}
|
||||
// 货物交接
|
||||
Constant.AuthName.GjjGoodsListActivity -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJJ_GOODS)
|
||||
.navigation()
|
||||
}
|
||||
/**
|
||||
* 航班查询
|
||||
*/
|
||||
//航班查询
|
||||
Constant.AuthName.HangBanQuery -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_HANG_BAN_QUERY)
|
||||
.navigation()
|
||||
}
|
||||
/**
|
||||
* 货物追踪
|
||||
*/
|
||||
//货物追踪
|
||||
Constant.AuthName.CargoTracking -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_CARGO_TRACKING)
|
||||
.navigation()
|
||||
}
|
||||
/**
|
||||
* 监装监卸
|
||||
*/
|
||||
//进港卸机
|
||||
Constant.AuthName.MonitorInPack -> {
|
||||
// ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_MONITOR_IN_PACK)
|
||||
// .navigation()
|
||||
GnjUnloadListActivity.start(requireContext())
|
||||
}
|
||||
//事故签证
|
||||
Constant.AuthName.AccidentVisa -> {
|
||||
ARouter.getInstance()
|
||||
.build(ARouterConstants.ACTIVITY_URL_MONITOR_ACCIDENT_VISA).navigation()
|
||||
}
|
||||
//出港装板
|
||||
Constant.AuthName.OutLoadingActivity -> {
|
||||
ARouter.getInstance()
|
||||
.build(ARouterConstants.ACTIVITY_URL_MONITOR_OUT_LOADING).navigation()
|
||||
}
|
||||
/**
|
||||
* 综合管理
|
||||
*/
|
||||
// 消息管理
|
||||
Constant.AuthName.ComprehensiveMessage -> {
|
||||
MessageListActivity.start(requireContext())
|
||||
}
|
||||
// 电报管理
|
||||
Constant.AuthName.ComprehensiveTelegram -> {
|
||||
TelegramListActivity.start(requireContext())
|
||||
}
|
||||
// 货物转运
|
||||
Constant.AuthName.ComprehensiveTransfer -> {
|
||||
GoodsTransportActivity.start(requireContext())
|
||||
}
|
||||
// 事故签证
|
||||
Constant.AuthName.ComprehensiveAccidentVisa -> {
|
||||
AccidentVisaListActivity.start(requireContext())
|
||||
}
|
||||
// 平板车管理
|
||||
Constant.AuthName.ComprehensiveCar -> {
|
||||
CarListActivity.start(requireContext())
|
||||
}
|
||||
// 转运记录
|
||||
Constant.AuthName.TransportLog -> {
|
||||
TransportLogActivity.start(requireContext())
|
||||
}
|
||||
// 日志查询
|
||||
Constant.AuthName.ComprehensiveLog -> {
|
||||
LogListActivity.start(requireContext())
|
||||
}
|
||||
|
||||
else -> {
|
||||
Toast.makeText(
|
||||
parent.context,
|
||||
"暂无入口,等待后期开放...",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
var item = rightMenuList[position]
|
||||
holder.itemText.text = item.text
|
||||
// holder.itemImg.setImageResource(item.img)
|
||||
loadPreviewImage(holder.itemView.context, item.img, holder.itemImg)
|
||||
}
|
||||
|
||||
private fun loadPreviewImage(context: Context, url: Any, target: ImageView) {
|
||||
val requestOptions = RequestOptions()
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.override(
|
||||
com.bumptech.glide.request.target.Target.SIZE_ORIGINAL,
|
||||
com.bumptech.glide.request.target.Target.SIZE_ORIGINAL
|
||||
)
|
||||
Glide.with(context)
|
||||
.setDefaultRequestOptions(requestOptions)
|
||||
.load(url)
|
||||
.into(target)
|
||||
}
|
||||
|
||||
override fun getItemCount() = rightMenuList.size
|
||||
}
|
||||
|
||||
inner class RightMenu(val id: String, val img: Int, val text: String)
|
||||
|
||||
private fun getRightMenu4Id(id: String): List<RightMenu> {
|
||||
var list = arrayListOf<RightMenu>()
|
||||
when (id) {
|
||||
Constant.AuthName.DomExp -> {
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.AppDomExpCheckin,
|
||||
com.lukouguoji.module_base.R.drawable.img_gnc_shouyun,
|
||||
"出港收运"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.AppDomExpWeighting,
|
||||
R.mipmap.gnc_fubang,
|
||||
"出港复磅"
|
||||
)
|
||||
)
|
||||
// list.add(RightMenu(Constant.AuthName.AppDomExpTransport, R.mipmap.gnc_zhuanyun, "转运确认"))
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.AppDomExpAssemble,
|
||||
com.lukouguoji.module_base.R.drawable.img_gnc_zuzhuang,
|
||||
"出港组装"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.AppDomExpDistribution,
|
||||
com.lukouguoji.module_base.R.drawable.img_gnc_fenpei,
|
||||
"出港分配"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.AppDomExpDeposit,
|
||||
com.lukouguoji.module_base.R.drawable.img_gnc_cunfang,
|
||||
"出港存放"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.AppDomExpWareHouse,
|
||||
R.mipmap.gnc_cangku,
|
||||
"仓库管理"
|
||||
)
|
||||
)
|
||||
list.add(RightMenu(Constant.AuthName.AppDomExpSearch, R.mipmap.gnc_cha, "出港查询"))
|
||||
list.add(RightMenu(Constant.AuthName.AppTest, R.mipmap.gnc_cha, "测试页"))
|
||||
}
|
||||
|
||||
Constant.AuthName.DomImp -> {
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GnjAppDomExpCheckin,
|
||||
R.mipmap.gnj_cang_dan_icon,
|
||||
"进港舱单"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GnjChuKuList,
|
||||
R.mipmap.gnj_chu_ku_icon,
|
||||
"进港出库"
|
||||
)
|
||||
)
|
||||
list.add(RightMenu(Constant.AuthName.GnjYiKu, R.mipmap.gnj_yi_ku_icon, "进港移库"))
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GnjWareHouse,
|
||||
R.mipmap.gnj_cang_ku_icon,
|
||||
"仓库管理"
|
||||
)
|
||||
)
|
||||
// list.add(RightMenu(Constant.AuthName.GnjRuKu, R.mipmap.gnc_zhuanyun, "转运确认"))
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GnjQueryList,
|
||||
R.mipmap.gnj_query_icon,
|
||||
"进港查询"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GnjHandover,
|
||||
R.mipmap.gnj_handover,
|
||||
"进港交接"
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
Constant.AuthName.IntExp -> {
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjcAppDomExpCheckin,
|
||||
R.mipmap.gjc_shou_yun_icon,
|
||||
"出港收运"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjcFuBangActivity,
|
||||
R.mipmap.gjc_fu_bang_icon,
|
||||
"板箱过磅"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjcWareHouseActivity,
|
||||
R.mipmap.gjc_cang_ku_icon,
|
||||
"仓库管理"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjcYiKuListActivity,
|
||||
R.mipmap.gjc_yi_ku_icon,
|
||||
"出港移库"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjcQueryListActivity,
|
||||
R.mipmap.gjc_query_icon,
|
||||
"出港查询"
|
||||
)
|
||||
)
|
||||
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjcBanXListActivity,
|
||||
com.lukouguoji.module_base.R.drawable.img_gjc_banxiangzuzhuang,
|
||||
"板箱组装"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjcGoodsListActivity,
|
||||
R.mipmap.img_hwjj,
|
||||
"货物交接"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Constant.AuthName.IntImp -> {
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjjChuKuListActivity,
|
||||
R.mipmap.gjj_chu_ku_icon,
|
||||
"提取出库"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjjWareHouseActivity,
|
||||
R.mipmap.gjj_cang_ku_icon,
|
||||
"仓库管理"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjjQueryListActivity,
|
||||
R.mipmap.gjj_query_icon,
|
||||
"进港查询"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjjPacketParseActivity,
|
||||
R.mipmap.img_bwjx,
|
||||
"报文解析"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjjManifestListActivity,
|
||||
R.mipmap.gjc_query_icon,
|
||||
"进港舱单"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjjTallyListActivity,
|
||||
R.mipmap.img_jglh,
|
||||
"进港理货"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.GjjGoodsListActivity,
|
||||
R.mipmap.img_hwjj,
|
||||
"货物交接"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Constant.AuthName.Flight -> {
|
||||
// list.add(RightMenu(Constant.AuthName.HangBanQuery, R.mipmap.guoji_in, "航班查询"))
|
||||
}
|
||||
|
||||
Constant.AuthName.CargoStatus -> {
|
||||
// list.add(RightMenu(Constant.AuthName.CargoTracking, R.mipmap.guoji_in, "货物状态查询"))
|
||||
}
|
||||
|
||||
Constant.AuthName.Supervision -> {
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.MonitorInPack,
|
||||
R.mipmap.mit_in_pack,
|
||||
"进港卸机"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.AccidentVisa,
|
||||
R.drawable.img_gj_shiguqianzheng,
|
||||
"事故签证"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.ComprehensiveAccidentVisa,
|
||||
R.mipmap.mit_accident_visa,
|
||||
"事故签证"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.OutLoadingActivity,
|
||||
R.mipmap.mit_out_pack,
|
||||
"出港装板"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Constant.AuthName.Comprehensive -> {
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.ComprehensiveMessage,
|
||||
com.lukouguoji.module_base.R.drawable.img_xiaoxiguanli,
|
||||
"消息管理"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.ComprehensiveTelegram,
|
||||
com.lukouguoji.module_base.R.drawable.img_gnc_dianbaoguanli,
|
||||
"电报管理"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.ComprehensiveTransfer,
|
||||
com.lukouguoji.module_base.R.drawable.img_gnc_huowuzhuanyun,
|
||||
"货物转运"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.ComprehensiveCar,
|
||||
com.lukouguoji.module_base.R.drawable.img_pingbancheguanli,
|
||||
"平板车管理"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.ComprehensiveLog,
|
||||
R.mipmap.gnc_shou,
|
||||
"日志查询"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RightMenu(
|
||||
Constant.AuthName.TransportLog,
|
||||
R.mipmap.transport_log,
|
||||
"转运记录"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
Log.e(TAG, "没有找到对应 $id 的右侧功能列表 ")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 右侧菜单 权限过滤
|
||||
*/
|
||||
val authsFilter = list.filter { m ->
|
||||
SharedPreferenceUtil.getString(Constant.Share.authList).contains(m.id)
|
||||
}
|
||||
// TODO: 暂时关闭权限筛选
|
||||
list = authsFilter as ArrayList<RightMenu>
|
||||
return list
|
||||
}
|
||||
|
||||
private fun refreshRight(id: String) {
|
||||
(rvRight.adapter as? HomeRightAdapt)?.refresh(getRightMenu4Id(id))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.lukouguoji.aerologic.ui.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.lukouguoji.aerologic.MineActivity
|
||||
import com.lukouguoji.aerologic.R
|
||||
import com.lukouguoji.aerologic.ui.viewModel.MineViewModel
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.service.repository.LoginRepository
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
|
||||
class MineFragment : Fragment(), View.OnClickListener {
|
||||
private lateinit var mineActivity: MineActivity
|
||||
private lateinit var viewModel: MineViewModel
|
||||
|
||||
private lateinit var toolBack: LinearLayout
|
||||
|
||||
private lateinit var oldPwd: EditText
|
||||
private lateinit var newPwd: EditText
|
||||
private lateinit var confirmPwd: EditText
|
||||
private lateinit var updatePwd: TextView
|
||||
|
||||
|
||||
private fun initView() {
|
||||
mineActivity = requireActivity() as MineActivity
|
||||
viewModel = ViewModelProvider(this).get(MineViewModel::class.java)
|
||||
|
||||
toolBack = mineActivity.findViewById(R.id.tool_back)
|
||||
oldPwd = mineActivity.findViewById(R.id.oldPwd)
|
||||
newPwd = mineActivity.findViewById(R.id.newPwd)
|
||||
confirmPwd = mineActivity.findViewById(R.id.confirmPwd)
|
||||
updatePwd = mineActivity.findViewById(R.id.updatePwd)
|
||||
|
||||
toolBack.setOnClickListener(this)
|
||||
updatePwd.setOnClickListener(this)
|
||||
|
||||
confirmPwd.setOnFocusChangeListener { v, hasFocus ->
|
||||
if (hasFocus) {
|
||||
// 此处为得到焦点时的处理内容
|
||||
} else {
|
||||
if (confirmPwd.text.toString() != newPwd.text.toString()) {
|
||||
Common.showToast(mineActivity, "两次输入的新密码不一致,请重新输入!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_mine, container, false)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
initView()
|
||||
|
||||
//确认移库 返回结果
|
||||
viewModel.updatePwdLive.observe(mineActivity) {
|
||||
mineActivity.loadingCancel()
|
||||
val status = it.getString("status")
|
||||
var dataStatus = it.getString("data")
|
||||
val msg = it.getString("msg")
|
||||
if (Constant.Result.succ == status && Constant.Result.succ == dataStatus) {
|
||||
Common.showToast(mineActivity, "密码修改成功!")
|
||||
LoginRepository.logout()
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_LOGIN).navigation()
|
||||
FlowBus.with<Any>(ConstantEvent.LOGOUT)
|
||||
.tryEmit(true)
|
||||
} else {
|
||||
if (msg != null && msg != "") {
|
||||
Common.showToast(mineActivity, msg)
|
||||
} else {
|
||||
Common.showToast(mineActivity, "密码修改失败!")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.tool_back -> {
|
||||
mineActivity.finish()
|
||||
}
|
||||
R.id.updatePwd -> {
|
||||
if (oldPwd.text.toString() == "") {
|
||||
Common.showToast(mineActivity, "请输入旧密码!")
|
||||
return
|
||||
}
|
||||
if (newPwd.text.toString() == "") {
|
||||
Common.showToast(mineActivity, "请输入新密码!")
|
||||
return
|
||||
}
|
||||
if (confirmPwd.text.toString() == "") {
|
||||
Common.showToast(mineActivity, "请再次输入新密码!")
|
||||
return
|
||||
}
|
||||
if (confirmPwd.text.toString() != newPwd.text.toString()) {
|
||||
Common.showToast(mineActivity, "两次输入的新密码不一致,请重新输入!")
|
||||
return
|
||||
}
|
||||
//修改密码接口
|
||||
viewModel.updatePwd(oldPwd.text.toString(), newPwd.text.toString())
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(mineActivity, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.lukouguoji.aerologic.ui.viewModel
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.Transformations
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.liveData
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.module_base.http.user.UserNetwork
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
class MineViewModel : ViewModel() {
|
||||
|
||||
private val updatePwdParam = MutableLiveData<JSONObject>()
|
||||
|
||||
val updatePwdLive = Transformations.switchMap(updatePwdParam) { param ->
|
||||
liveData(Dispatchers.IO) {
|
||||
try {
|
||||
val response = UserNetwork.updatePwd(param)
|
||||
emit(response)
|
||||
} catch (e: Exception) {
|
||||
Log.e("GoutCollectionViewModel", e.stackTraceToString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updatePwd(
|
||||
oldPwd: String,
|
||||
newPwd: String
|
||||
) {
|
||||
val param = JSONObject()
|
||||
param["oldPwd"] = oldPwd
|
||||
param["newPwd"] = newPwd
|
||||
updatePwdParam.value = param
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user