diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3a9f9ea..2ff9e1b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/white" android:orientation="vertical" tools:context=".view.MainActivity"> - + + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3a9f9ea..2ff9e1b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/white" android:orientation="vertical" tools:context=".view.MainActivity"> - + - + + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3a9f9ea..2ff9e1b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/white" android:orientation="vertical" tools:context=".view.MainActivity"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3a9f9ea..2ff9e1b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/white" android:orientation="vertical" tools:context=".view.MainActivity"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 61a4490..d3ceafb 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,6 +1,67 @@ - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3a9f9ea..2ff9e1b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/white" android:orientation="vertical" tools:context=".view.MainActivity"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 61a4490..d3ceafb 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,6 +1,67 @@ - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/include_base_title.xml b/app/src/main/res/layout/include_base_title.xml new file mode 100644 index 0000000..13de699 --- /dev/null +++ b/app/src/main/res/layout/include_base_title.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3a9f9ea..2ff9e1b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/white" android:orientation="vertical" tools:context=".view.MainActivity"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 61a4490..d3ceafb 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,6 +1,67 @@ - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/include_base_title.xml b/app/src/main/res/layout/include_base_title.xml new file mode 100644 index 0000000..13de699 --- /dev/null +++ b/app/src/main/res/layout/include_base_title.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_home_recycleview.xml b/app/src/main/res/layout/item_home_recycleview.xml new file mode 100644 index 0000000..af30be8 --- /dev/null +++ b/app/src/main/res/layout/item_home_recycleview.xml @@ -0,0 +1,32 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3a9f9ea..2ff9e1b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/white" android:orientation="vertical" tools:context=".view.MainActivity"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 61a4490..d3ceafb 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,6 +1,67 @@ - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/include_base_title.xml b/app/src/main/res/layout/include_base_title.xml new file mode 100644 index 0000000..13de699 --- /dev/null +++ b/app/src/main/res/layout/include_base_title.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_home_recycleview.xml b/app/src/main/res/layout/item_home_recycleview.xml new file mode 100644 index 0000000..af30be8 --- /dev/null +++ b/app/src/main/res/layout/item_home_recycleview.xml @@ -0,0 +1,32 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_popup.xml b/app/src/main/res/layout/item_popup.xml new file mode 100644 index 0000000..05033c4 --- /dev/null +++ b/app/src/main/res/layout/item_popup.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3a9f9ea..2ff9e1b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/white" android:orientation="vertical" tools:context=".view.MainActivity"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 61a4490..d3ceafb 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,6 +1,67 @@ - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/include_base_title.xml b/app/src/main/res/layout/include_base_title.xml new file mode 100644 index 0000000..13de699 --- /dev/null +++ b/app/src/main/res/layout/include_base_title.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_home_recycleview.xml b/app/src/main/res/layout/item_home_recycleview.xml new file mode 100644 index 0000000..af30be8 --- /dev/null +++ b/app/src/main/res/layout/item_home_recycleview.xml @@ -0,0 +1,32 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_popup.xml b/app/src/main/res/layout/item_popup.xml new file mode 100644 index 0000000..05033c4 --- /dev/null +++ b/app/src/main/res/layout/item_popup.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/popup_well_type.xml b/app/src/main/res/layout/popup_well_type.xml new file mode 100644 index 0000000..4e59df3 --- /dev/null +++ b/app/src/main/res/layout/popup_well_type.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3a9f9ea..2ff9e1b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/white" android:orientation="vertical" tools:context=".view.MainActivity"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 61a4490..d3ceafb 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,6 +1,67 @@ - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/include_base_title.xml b/app/src/main/res/layout/include_base_title.xml new file mode 100644 index 0000000..13de699 --- /dev/null +++ b/app/src/main/res/layout/include_base_title.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_home_recycleview.xml b/app/src/main/res/layout/item_home_recycleview.xml new file mode 100644 index 0000000..af30be8 --- /dev/null +++ b/app/src/main/res/layout/item_home_recycleview.xml @@ -0,0 +1,32 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_popup.xml b/app/src/main/res/layout/item_popup.xml new file mode 100644 index 0000000..05033c4 --- /dev/null +++ b/app/src/main/res/layout/item_popup.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/popup_well_type.xml b/app/src/main/res/layout/popup_well_type.xml new file mode 100644 index 0000000..4e59df3 --- /dev/null +++ b/app/src/main/res/layout/popup_well_type.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f9ec6c1..6c93418 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -8,4 +8,5 @@ #54FFFFFF #54000000 #C0000000 + #030B14 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d0562c3..d46f832 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,7 @@ + diff --git a/app/src/main/assets/svg/up.svg b/app/src/main/assets/svg/up.svg new file mode 100644 index 0000000..b34abec --- /dev/null +++ b/app/src/main/assets/svg/up.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt new file mode 100644 index 0000000..cf15d6b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/adapter/HomeRecycleAdapter.kt @@ -0,0 +1,48 @@ +package com.casic.app.smartwell.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.casic.app.smartwell.R +import com.casic.app.smartwell.utils.Constant + +class HomeRecycleAdapter(private val context: Context) : + RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { + val view: View = + LayoutInflater.from(context).inflate(R.layout.item_home_recycleview, parent, false) + return ItemViewHolder(view) + } + + override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { + holder.imageView.setBackgroundResource(Constant.HOME_ICONS[position]) + holder.textView.text = Constant.HOME_ITEMS[position] + if (clickListener != null) { + holder.itemView.setOnClickListener { + clickListener!!.onClick(position) + } + } + } + + override fun getItemCount(): Int = Constant.HOME_ITEMS.size + + private var clickListener: OnGridItemClickListener? = null + + interface OnGridItemClickListener { + fun onClick(position: Int) + } + + fun setOnGridItemClickListener(onGridItemClickListener: OnGridItemClickListener?) { + clickListener = onGridItemClickListener + } + + class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val imageView: ImageView = itemView.findViewById(R.id.imageView) + val textView: TextView = itemView.findViewById(R.id.textView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt new file mode 100644 index 0000000..cac523d --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/WellTypeModel.kt @@ -0,0 +1,25 @@ +package com.casic.app.smartwell.model + +class WellTypeModel { + /** + * code : 200 + * data : [{"name":"雨水井","id":"61","value":"1"},{"name":"污水井","id":"62","value":"2"},{"name":"燃气井","id":"63","value":"3"},{"name":"热力井","id":"64","value":"4"},{"name":"电力井","id":"65","value":"5"},{"name":"交通井","id":"88","value":"6"},{"name":"路灯井","id":"89","value":"7"},{"name":"通信井","id":"90","value":"8"},{"name":"监控井","id":"91","value":"9"},{"name":"其他","id":"92","value":"10"}] + * message : 请求成功 + * success : true + */ + var code = 0 + var message: String? = null + var isSuccess = false + var data: List? = null + + class DataBean { + /** + * name : 雨水井 + * id : 61 + * value : 1 + */ + var name: String? = null + var id: String? = null + var value: String? = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt index 5410892..f8f0c73 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/Constant.kt @@ -1,6 +1,7 @@ package com.casic.app.smartwell.utils import android.Manifest +import com.casic.app.smartwell.R object Constant { @@ -15,4 +16,9 @@ const val PASSWORD = "password" const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" const val USER_DETAIL_MODEL = "userDetailModel" + + val HOME_ICONS = arrayOf( + R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher + ) + val HOME_ITEMS = arrayOf("闸井管理", "告警工单", "布防撤防") } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 3f7e8cb..02ab7b6 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,12 @@ ): String /** + * 获取闸井类别 + */ + @GET("/dict/code/sluicewellType") + suspend fun obtainWellType(@Header("token") token: String): WellTypeModel + + /** * 获取用户信息 */ @GET("/user/info") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index 6945bd8..194ea92 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -24,6 +24,13 @@ } /** + * 获取闸井类别 + */ + suspend fun obtainWellType(): WellTypeModel { + return api.obtainWellType(AuthenticationHelper.token!!) + } + + /** * 获取用户信息 */ suspend fun obtainUserDetail(): UserDetailModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt index 937400e..97193c5 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/AboutUsActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class AboutUsActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_about_us diff --git a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt index 2cd6c61..4274444 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/ChangePasswordActivity.kt @@ -10,7 +10,7 @@ import com.casic.app.smartwell.utils.* import com.casic.app.smartwell.vm.ChangePasswordViewModel import kotlinx.android.synthetic.main.activity_change_pwd.* -import kotlinx.android.synthetic.main.activity_user_detail.topLayout +import kotlinx.android.synthetic.main.include_base_title.* import java.nio.charset.StandardCharsets class ChangePasswordActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt index e12f513..fc70a26 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/CustomerServiceActivity.kt @@ -3,7 +3,7 @@ import com.casic.app.smartwell.R import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor -import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class CustomerServiceActivity : BaseActivity() { override fun initLayoutView(): Int = R.layout.activity_customer_service diff --git a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt index 18cf6b5..4213916 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/HelpCenterActivity.kt @@ -5,7 +5,7 @@ import com.casic.app.smartwell.base.BaseActivity import com.casic.app.smartwell.extensions.covertColor import kotlinx.android.synthetic.main.activity_help_center.* -import kotlinx.android.synthetic.main.activity_main.topLayout +import kotlinx.android.synthetic.main.include_base_title.* class HelpCenterActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt index 490a9a1..e5698a1 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/LoginActivity.kt @@ -32,7 +32,7 @@ } override fun afterTextChanged(s: Editable) { - if (s.toString().trim { it <= ' ' }.length > 10) { + if (s.toString().trim { it <= ' ' }.length > 16) { inputLayout.error = "密码长度超出限制" } else { inputLayout.error = null diff --git a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt index 9421eea..8bf81da 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/MainActivity.kt @@ -18,6 +18,7 @@ import com.casic.app.smartwell.vm.UserDetailViewModel import com.google.gson.Gson import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.include_base_title.* class MainActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt index 50149a6..325b0f8 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/UserDetailActivity.kt @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken import kotlinx.android.synthetic.main.activity_user_detail.* import kotlinx.android.synthetic.main.fragment_mine.userNameView +import kotlinx.android.synthetic.main.include_base_title.* class UserDetailActivity : BaseActivity() { diff --git a/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt new file mode 100644 index 0000000..aa8943a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/view/WellManagementActivity.kt @@ -0,0 +1,75 @@ +package com.casic.app.smartwell.view + +import android.view.animation.LinearInterpolator +import androidx.lifecycle.ViewModelProvider +import com.casic.app.smartwell.R +import com.casic.app.smartwell.base.BaseActivity +import com.casic.app.smartwell.extensions.covertColor +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.vm.WellTypeViewModel +import com.casic.app.smartwell.widgets.EasyPopupWindow +import kotlinx.android.synthetic.main.activity_well_management.* +import kotlinx.android.synthetic.main.include_base_title.* + + +class WellManagementActivity : BaseActivity() { + + private lateinit var wellTypeViewModel: WellTypeViewModel + private lateinit var easyPopupWindow: EasyPopupWindow + private var items: MutableList = ArrayList() + + override fun initLayoutView(): Int = R.layout.activity_well_management + + override fun setupTopBarLayout() { + topLayout.setTitle("窨井管理").setTextColor(R.color.white.covertColor(this)) + topLayout.setBackgroundColor(R.color.mainThemeColor.covertColor(this)) + } + + override fun initData() { + easyPopupWindow = EasyPopupWindow(this) + easyPopupWindow.setBackgroundDrawable(null) + wellTypeViewModel = ViewModelProvider(this).get(WellTypeViewModel::class.java) + wellTypeViewModel.obtainWellType() + wellTypeViewModel.wellTypeModel.observe(this, { + if (it.code == 200) { + it.data!!.forEachIndexed { index, dataBean -> + val bean: WellTypeModel.DataBean + if (index == 0) { + bean = WellTypeModel.DataBean() + bean.id = "0" + bean.name = "全\u3000部" + bean.value = "0" + } else { + bean = dataBean + } + items.add(bean) + } + easyPopupWindow.setupPopupData(items) + } + }) + } + + private var clickTag = 0 + + override fun initEvent() { + wellTypeLayout.setOnClickListener { + //旋转arrowImageView + val rotateAnimation = arrowImageView.animate() + rotateAnimation.duration = 200 + rotateAnimation.interpolator = LinearInterpolator() + if (clickTag % 2 == 0) { + rotateAnimation.rotation(180f) + } else { + rotateAnimation.rotation(0f) + } + clickTag++ + easyPopupWindow.showAsDropDown(wellTypeLayout) + easyPopupWindow.setOnPopupWindowClickListener(object : + EasyPopupWindow.OnPopupWindowClickListener { + override fun onPopupClick(position: Int) { + wellTypeView.text = items[position].name + } + }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index eb909c1..b3bb6a9 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,13 +1,31 @@ package com.casic.app.smartwell.view.fragment +import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R +import com.casic.app.smartwell.adapter.HomeRecycleAdapter +import com.casic.app.smartwell.extensions.navigatePageTo +import com.casic.app.smartwell.view.WellManagementActivity import com.pengxh.app.multilib.base.BaseFragment +import kotlinx.android.synthetic.main.fragment_home.* -class HomePageFragment : BaseFragment(){ +class HomePageFragment : BaseFragment() { override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { - + //首页功能块 + val homeRecycleAdapter = HomeRecycleAdapter(requireContext()) + homeRecyclerView.layoutManager = GridLayoutManager(requireContext(), 3) + homeRecyclerView.adapter = homeRecycleAdapter + homeRecycleAdapter.setOnGridItemClickListener(object : + HomeRecycleAdapter.OnGridItemClickListener { + override fun onClick(position: Int) { + when (position) { + 0 -> requireContext().navigatePageTo(WellManagementActivity::class.java) +// 1 -> startActivity(Intent(context, SearchRecordActivity::class.java)) +// 2 -> startActivity(Intent(context, StatisticsActivity::class.java)) + } + } + }) } override fun initEvent() { diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt new file mode 100644 index 0000000..015d92e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellTypeViewModel.kt @@ -0,0 +1,20 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.model.WellTypeModel +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager + +class WellTypeViewModel : BaseViewModel() { + private val kTag = "WellTypeViewModel" + + val wellTypeModel = MutableLiveData() + + fun obtainWellType() = launch({ + wellTypeModel.value = RetrofitServiceManager.obtainWellType() + }, { + Log.d(kTag, "obtainWellType: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt new file mode 100644 index 0000000..061b0a7 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/widgets/EasyPopupWindow.kt @@ -0,0 +1,88 @@ +package com.casic.app.smartwell.widgets + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.* +import com.casic.app.smartwell.R +import com.casic.app.smartwell.model.WellTypeModel +import com.pengxh.app.multilib.utils.SizeUtil + +/** + * @description: 顶部下拉菜单 + * @author: Pengxh + * @email: 290677893@qq.com + * @date: 2019/12/28 20:35 + */ +class EasyPopupWindow(private val ctx: Context) : PopupWindow(ctx) { + + private var mClickListener: OnPopupWindowClickListener? = null + private var items: List = ArrayList() + + init { + width = (SizeUtil.getScreenWidth(ctx) * 0.25).toInt() + height = ViewGroup.LayoutParams.WRAP_CONTENT + isOutsideTouchable = true + isFocusable = true + animationStyle = R.style.PopupAnimation + contentView = LayoutInflater.from(ctx).inflate(R.layout.popup_well_type, null, false) + } + + fun setupPopupData(itemList: List) { + this.items = itemList + val popupListView = contentView.findViewById(R.id.popupListView) + setupListView(popupListView) + } + + //给PopupWindow列表绑定数据 + private fun setupListView(popupListView: ListView) { + val adapter = PopupAdapter() + popupListView.adapter = adapter + popupListView.onItemClickListener = + AdapterView.OnItemClickListener { _, _, i, _ -> + if (mClickListener != null) { + mClickListener!!.onPopupClick(i) + } + dismiss() + } + } + + interface OnPopupWindowClickListener { + fun onPopupClick(position: Int) + } + + fun setOnPopupWindowClickListener(windowClickListener: OnPopupWindowClickListener?) { + mClickListener = windowClickListener + } + + inner class PopupAdapter : BaseAdapter() { + + private val inflater: LayoutInflater = LayoutInflater.from(ctx) + + override fun getCount(): Int = items.size + + override fun getItem(position: Int): Any = items[position] + + override fun getItemId(position: Int): Long = position.toLong() + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val view: View + val holder: ItemViewHolder + if (convertView == null) { + view = inflater.inflate(R.layout.item_popup, null) + holder = ItemViewHolder(view) + view.tag = holder + } else { + view = convertView + holder = view.tag as ItemViewHolder + } + holder.popupTitle.text = items[position].name + return view + } + } + + class ItemViewHolder(itemView: View) { + var popupTitle: TextView = itemView.findViewById(R.id.popupTitle) + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/activity_in.xml b/app/src/main/res/anim/activity_in.xml new file mode 100644 index 0000000..f2696ba --- /dev/null +++ b/app/src/main/res/anim/activity_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/activity_out.xml b/app/src/main/res/anim/activity_out.xml new file mode 100644 index 0000000..1e424a5 --- /dev/null +++ b/app/src/main/res/anim/activity_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_hide.xml b/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 0000000..55c7aca --- /dev/null +++ b/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/popup_show.xml b/app/src/main/res/anim/popup_show.xml new file mode 100644 index 0000000..c43c396 --- /dev/null +++ b/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_radius_5.xml b/app/src/main/res/drawable/bg_layout_radius_5.xml new file mode 100644 index 0000000..5a90f4e --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_radius_5.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..6ad993b --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_up.xml b/app/src/main/res/drawable/ic_up.xml new file mode 100644 index 0000000..151a0cb --- /dev/null +++ b/app/src/main/res/drawable/ic_up.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/popup_list_divider.xml b/app/src/main/res/drawable/popup_list_divider.xml new file mode 100644 index 0000000..c5b4a60 --- /dev/null +++ b/app/src/main/res/drawable/popup_list_divider.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml index aa12e44..a1b002a 100644 --- a/app/src/main/res/layout/activity_about_us.xml +++ b/app/src/main/res/layout/activity_about_us.xml @@ -7,11 +7,7 @@ android:orientation="vertical" tools:context=".view.AboutUsActivity"> - + - + - + - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3a9f9ea..2ff9e1b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/white" android:orientation="vertical" tools:context=".view.MainActivity"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 61a4490..d3ceafb 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,6 +1,67 @@ - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/include_base_title.xml b/app/src/main/res/layout/include_base_title.xml new file mode 100644 index 0000000..13de699 --- /dev/null +++ b/app/src/main/res/layout/include_base_title.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_home_recycleview.xml b/app/src/main/res/layout/item_home_recycleview.xml new file mode 100644 index 0000000..af30be8 --- /dev/null +++ b/app/src/main/res/layout/item_home_recycleview.xml @@ -0,0 +1,32 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_popup.xml b/app/src/main/res/layout/item_popup.xml new file mode 100644 index 0000000..05033c4 --- /dev/null +++ b/app/src/main/res/layout/item_popup.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/popup_well_type.xml b/app/src/main/res/layout/popup_well_type.xml new file mode 100644 index 0000000..4e59df3 --- /dev/null +++ b/app/src/main/res/layout/popup_well_type.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f9ec6c1..6c93418 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -8,4 +8,5 @@ #54FFFFFF #54000000 #C0000000 + #030B14 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index a4feac2..1713068 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -74,4 +74,11 @@ @color/hintColor @color/mainThemeColor + +