From ab641f96a8b40dcc6120ebce733e8f251f7052ff Mon Sep 17 00:00:00 2001 From: YunLei Date: Wed, 30 Aug 2023 18:35:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=20fix=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 8 +- .../main/java/com/yzx/escreen/MainActivity.kt | 14 +- .../com/yzx/escreen/activity/LoginActivity.kt | 27 +- .../yzx/escreen/adapter/DeviceListAdapter.kt | 40 ++ .../com/yzx/escreen/config/YzxInterface.kt | 6 + .../yzx/escreen/fragment/SettingFragment.kt | 403 ++++++++++++++++++ .../main/java/com/yzx/escreen/model/Device.kt | 9 + .../com/yzx/escreen/model/EventBugBean.kt | 4 +- .../yzx/escreen/presenter/SettingPresenter.kt | 111 +++++ app/src/main/res/drawable/shape_open_btn.xml | 6 + app/src/main/res/layout/fragment_setting.xml | 260 +++++++++++ .../main/res/layout/layout_device_item.xml | 75 ++++ app/src/main/res/mipmap-mdpi/setting.png | Bin 0 -> 1387 bytes .../main/res/mipmap-mdpi/setting_select.png | Bin 0 -> 1025 bytes app/src/main/res/mipmap-xhdpi/icon_user.png | Bin 0 -> 883 bytes 15 files changed, 948 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/com/yzx/escreen/adapter/DeviceListAdapter.kt create mode 100644 app/src/main/java/com/yzx/escreen/fragment/SettingFragment.kt create mode 100644 app/src/main/java/com/yzx/escreen/model/Device.kt create mode 100644 app/src/main/java/com/yzx/escreen/presenter/SettingPresenter.kt create mode 100644 app/src/main/res/drawable/shape_open_btn.xml create mode 100644 app/src/main/res/layout/fragment_setting.xml create mode 100644 app/src/main/res/layout/layout_device_item.xml create mode 100644 app/src/main/res/mipmap-mdpi/setting.png create mode 100644 app/src/main/res/mipmap-mdpi/setting_select.png create mode 100644 app/src/main/res/mipmap-xhdpi/icon_user.png diff --git a/app/build.gradle b/app/build.gradle index 39674e5..f9cb37c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,8 +19,8 @@ android { // minSdkVersion 26 minSdkVersion 21 targetSdkVersion 25 - versionCode 30005 - versionName "3.0.5" + versionCode 30007 + versionName "3.0.7" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // ndk { @@ -87,11 +87,11 @@ android { shrinkResources false // buildConfigField "String", "BASE_URL", '"http://192.168.69.99:9009"' // buildConfigField "String", "M_URL", '"http://192.168.69.112:8098"' - buildConfigField "String", "BASE_URL", '"https://oa.qbjjyyun.net/api"' +// buildConfigField "String", "BASE_URL", '"https://oa.qbjjyyun.net/api"' buildConfigField "String", "OA_URL", '"https://oa.live.educlouddata.com"' // buildConfigField "String", "OA_URL", '"http://192.168.69.114:3000"' buildConfigField "String", "M_URL", '"https://m.live.educlouddata.com/"' -// buildConfigField "String", "BASE_URL", '"https://oa.live.educlouddata.com/api"' + buildConfigField "String", "BASE_URL", '"https://oa.live.educlouddata.com/api"' buildConfigField "String", "APP_NAME", '"一体化平台(开发)"' buildConfigField "String", "MP_APPID", '"wxbb397ddae71bb14c"' // buildConfigField "String", "WS_URL", '"ws://192.168.69.114:9801/"' diff --git a/app/src/main/java/com/yzx/escreen/MainActivity.kt b/app/src/main/java/com/yzx/escreen/MainActivity.kt index 5aaacd3..6b8bfbf 100644 --- a/app/src/main/java/com/yzx/escreen/MainActivity.kt +++ b/app/src/main/java/com/yzx/escreen/MainActivity.kt @@ -36,7 +36,7 @@ import com.yzx.escreen.config.Config import com.yzx.escreen.config.RefreshToken import com.yzx.escreen.fragment.ChangeFragment import com.yzx.escreen.fragment.HomeFragment -import com.yzx.escreen.fragment.MyFragment +import com.yzx.escreen.fragment.SettingFragment import com.yzx.escreen.fragment.VisitorFragment import com.yzx.escreen.model.* import com.yzx.escreen.presenter.MainPresenter @@ -146,7 +146,8 @@ class MainActivity : BaseActivity(), NetworkUtils.OnNetworkStatus tabData.add(TabEntity("学生请假", R.mipmap.leave_select, R.mipmap.leave_unselect)) tabData.add(TabEntity("学籍异动", R.mipmap.change_select, R.mipmap.change_unselect)) tabData.add(TabEntity("访客管理", R.mipmap.visitor_select, R.mipmap.visitor_unselect)) - tabData.add(TabEntity("我的", R.mipmap.my_select, R.mipmap.my_unselect)) +// tabData.add(TabEntity("我的", R.mipmap.my_select, R.mipmap.my_unselect)) + tabData.add(TabEntity("设置", R.mipmap.setting_select, R.mipmap.setting)) tabLayout.setTabData(tabData) viewPager2.adapter = HomePagerAdapter(this) @@ -398,6 +399,13 @@ class MainActivity : BaseActivity(), NetworkUtils.OnNetworkStatus mPresenter?.getLeaveShowIds("${detail.ids}") } + //请假消息 + @Subscribe(threadMode = ThreadMode.MAIN) + fun onMessageEvent(detail: UserVersionCheck) { + LogUtils.d("WebSocketClient--onMessageEvent",detail) + checkVersion(true) + } + private fun wsHeart() { @@ -651,7 +659,7 @@ class HomePagerAdapter(act: AppCompatActivity) : FragmentStateAdapter(act) { } 3 -> { - return MyFragment.getNewInstance() + return SettingFragment.getNewInstance() } } return HomeFragment() diff --git a/app/src/main/java/com/yzx/escreen/activity/LoginActivity.kt b/app/src/main/java/com/yzx/escreen/activity/LoginActivity.kt index 60fc23b..3bf975b 100644 --- a/app/src/main/java/com/yzx/escreen/activity/LoginActivity.kt +++ b/app/src/main/java/com/yzx/escreen/activity/LoginActivity.kt @@ -39,6 +39,7 @@ class LoginActivity : BaseActivity(), LoginView { } private var mTicket = "" + private var isPageShow = true override val inflateId: Int get() = R.layout.activity_login @@ -164,14 +165,30 @@ class LoginActivity : BaseActivity(), LoginView { override fun onDestroy() { qrCodeImg?.apply { - removeCallbacks(null) + removeCallbacks(mRun) } super.onDestroy() } + override fun onResume() { + super.onResume() + this.isPageShow = true + } + + override fun onStop() { + super.onStop() + this.isPageShow = false + } + private var mBindDialog: QMUIDialog? = null private var mOverTimeDialog: QMUIDialog? = null + private var mRun = Runnable { + if(isPageShow){ + mPresenter?.loginQuery(mTicket) + } + } + override fun onLoginQuerySuccess(user: BaseUser, code: Int) { when (code) { 0 -> { @@ -196,15 +213,11 @@ class LoginActivity : BaseActivity(), LoginView { } else if (!mBindDialog!!.isShowing) { mBindDialog?.show() } - qrCodeImg.postDelayed({ - mPresenter?.loginQuery(mTicket) - }, 1000) + qrCodeImg.postDelayed(mRun, 1000) } 452 -> { - qrCodeImg.postDelayed({ - mPresenter?.loginQuery(mTicket) - }, 1000) + qrCodeImg.postDelayed(mRun, 1000) } else -> { diff --git a/app/src/main/java/com/yzx/escreen/adapter/DeviceListAdapter.kt b/app/src/main/java/com/yzx/escreen/adapter/DeviceListAdapter.kt new file mode 100644 index 0000000..2da64d2 --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/adapter/DeviceListAdapter.kt @@ -0,0 +1,40 @@ +package com.yzx.escreen.adapter + +import android.annotation.SuppressLint +import android.view.View +import com.chad.library.adapter.base.BaseQuickAdapter +import com.chad.library.adapter.base.viewholder.BaseViewHolder +import com.yzx.escreen.R +import com.yzx.escreen.model.Device +import kotlinx.android.synthetic.main.layout_device_item.view.* + +class DeviceListAdapter(list: MutableList) : + BaseQuickAdapter(R.layout.layout_device_item, list) { + + init { + addChildClickViewIds(R.id.actionOpen, R.id.actionNormal) + } + + @SuppressLint("SetTextI18n") + override fun convert(holder: BaseViewHolder, item: Device) { + holder.itemView.deviceName.text = item.name + holder.itemView.deviceTypeName.text = "进出校考勤设备" + holder.itemView.deviceTagName.text = if (item.type == 1) { + "进闸设备" + } else { + "出闸设备" + } + holder.itemView.deviceName.isChecked = item.isChecked + holder.itemView.deviceName.setOnCheckedChangeListener { _, isChecked -> + item.isChecked = isChecked + } + + holder.itemView.bottomLine.visibility = if (holder.adapterPosition == data.size - 1) { + View.GONE + } else { + View.VISIBLE + } + + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt b/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt index 3c8bc71..49d0e96 100644 --- a/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt +++ b/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt @@ -39,4 +39,10 @@ object YzxInterface { */ const val INTERFACE_ACCESS_CONTROL_GET_FACE_LIST= "/parent/entranceGuard/getEntranceGuardFaceList" // 获取访客人脸信息列表 const val INTERFACE_ACCESS_CONTROL_GET_FACE_INFO_DETAIL= "/parent/entranceGuard/getEntranceGuardFaceById" // 访客信息 + + /** + * 设置门禁 + */ + const val INTERFACE_ACCESS_CONTROL_GET_FACE_DEVICE_LIST= "/parent/entranceGuard/getAccessSchoolFaceDeviceList" // 门禁管理-门禁设备列表 + const val INTERFACE_ACCESS_CONTROL_POST_DOOR_RELAY_MODE= "/parent/entranceGuard/setDoorRelayMode" // 门禁管理-设置门禁模式 } diff --git a/app/src/main/java/com/yzx/escreen/fragment/SettingFragment.kt b/app/src/main/java/com/yzx/escreen/fragment/SettingFragment.kt new file mode 100644 index 0000000..f84f26d --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/fragment/SettingFragment.kt @@ -0,0 +1,403 @@ +package com.yzx.escreen.fragment + +import android.graphics.Color +import android.text.InputType +import android.view.View +import androidx.recyclerview.widget.LinearLayoutManager +import com.blankj.utilcode.util.KeyboardUtils +import com.blankj.utilcode.util.LogUtils +import com.blankj.utilcode.util.NetworkUtils +import com.qmuiteam.qmui.widget.dialog.QMUIDialog +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog.Builder.ICON_TYPE_FAIL +import com.yzx.escreen.R +import com.yzx.escreen.activity.LoginActivity +import com.yzx.escreen.adapter.DeviceListAdapter +import com.yzx.escreen.fragment.base.BaseFragment +import com.yzx.escreen.model.Device +import com.yzx.escreen.model.Pager +import com.yzx.escreen.model.TeacherInfo +import com.yzx.escreen.model.TimeShow +import com.yzx.escreen.model.User +import com.yzx.escreen.model.UserVersionCheck +import com.yzx.escreen.presenter.SettingPresenter +import com.yzx.escreen.presenter.SettingView +import com.yzx.escreen.utils.hideNavigationBar +import kotlinx.android.synthetic.main.fragment_setting.btnNormal +import kotlinx.android.synthetic.main.fragment_setting.btnOpen +import kotlinx.android.synthetic.main.fragment_setting.btnRefresh +import kotlinx.android.synthetic.main.fragment_setting.checkAll +import kotlinx.android.synthetic.main.fragment_setting.checkVersion +import kotlinx.android.synthetic.main.fragment_setting.goPageOne +import kotlinx.android.synthetic.main.fragment_setting.loadingLayout +import kotlinx.android.synthetic.main.fragment_setting.nextTxtBtn +import kotlinx.android.synthetic.main.fragment_setting.pageTv +import kotlinx.android.synthetic.main.fragment_setting.preTxtBtn +import kotlinx.android.synthetic.main.fragment_setting.recyclerView +import kotlinx.android.synthetic.main.fragment_setting.sysExitBtn +import kotlinx.android.synthetic.main.fragment_setting.totalTv +import kotlinx.android.synthetic.main.fragment_setting.userNameBox +import kotlinx.android.synthetic.main.fragment_setting.userNameTv +import kotlinx.android.synthetic.main.layout_loading.view.QMUIEmptyView +import org.greenrobot.eventbus.EventBus +import org.greenrobot.eventbus.Subscribe +import org.greenrobot.eventbus.ThreadMode +import org.jetbrains.anko.support.v4.toast +import org.jetbrains.anko.textColor +import kotlin.system.exitProcess + +class SettingFragment : BaseFragment(), SettingView { + + companion object { + + @JvmStatic + fun getNewInstance() = + SettingFragment() + } + + private var count = 0 + private val run = Runnable { + count = 0 + } + private var isLoading = false + private var mPager = Pager() + var list = mutableListOf() + private var isRefresh = false + + private val mAdapter: DeviceListAdapter by lazy { + val list = mutableListOf() + DeviceListAdapter(list) + } + + override val inflateId: Int + get() = R.layout.fragment_setting + + override fun initView() { + sysExitBtn.setOnClickListener { + count++ + sysExitBtn.removeCallbacks(run) + sysExitBtn.postDelayed(run, 1000) + if (count >= 5) { + showExitDialog() + } + } + + recyclerView.layoutManager = + LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) + recyclerView.adapter = mAdapter + + mAdapter.setOnItemChildClickListener { adapter, view, position -> + val item = mAdapter.getItem(position) + val idList = mutableListOf() + idList.add(item.id) + LogUtils.d("deviceids",idList.joinToString(",") ) + when (view.id) { + R.id.actionNormal -> { + showActionDialog(idList, 0) + } + + R.id.actionOpen -> { + showActionDialog(idList, 1) + } + } + } + + + + preTxtBtn.setOnClickListener { pre() } + nextTxtBtn.setOnClickListener { next() } + btnRefresh.setOnClickListener { + isRefresh = true + showLayoutLoading() + initData() + } + + btnOpen.setOnClickListener { + val newList = mAdapter.data.filter { it.isChecked } + if(newList.isEmpty()){ + showDialogToast("请先选择设备", icon = ICON_TYPE_FAIL) + return@setOnClickListener + } + + val idList = newList.map { it.id } + showActionDialog(idList.toMutableList(),1) + } + btnNormal.setOnClickListener { + val newList = mAdapter.data.filter { it.isChecked } + if(newList.isEmpty()){ + showDialogToast("请先选择设备", icon = ICON_TYPE_FAIL) + return@setOnClickListener + } + + val idList = newList.map { it.id } + showActionDialog(idList.toMutableList(),0) + } + checkAll.setOnCheckedChangeListener { _, isChecked -> + if(isChecked){ + mAdapter.data.forEach { it.isChecked = true } + mAdapter.notifyDataSetChanged() + }else{ + mAdapter.data.forEach { it.isChecked = false } + mAdapter.notifyDataSetChanged() + } + } + + userNameBox.setOnClickListener { + logoutDialog() + } + + checkVersion.setOnClickListener { + EventBus.getDefault().post(UserVersionCheck()) + } + + } + + private fun logoutDialog(){ + val tipDialog = QMUIDialog.MessageDialogBuilder(activity) + .setTitle("温馨提示") + .setMessage("是否确定退出登录?") + .addAction("取消") { dialog, index -> + dialog.dismiss() + } + .addAction("确定") { dialog, index -> + dialog.dismiss() + activity?.apply { + User.clearUserInfo() + LoginActivity.active(this) + finish() + } + } + .create() + tipDialog.show() + } + + private fun showActionDialog(idList: MutableList, mode: Int) { + val tipDialog = QMUIDialog.MessageDialogBuilder(activity) + .setTitle("温馨提示") + .setMessage( + if (mode == 1) { + "是否确定将设备设置为常开?" + } else { + "是否确定将设备设置为标准状态?" + } + ) + .addAction("取消") { dialog, index -> + dialog.dismiss() + } + .addAction("确定") { dialog, index -> + dialog.dismiss() + showLoading("操作中...") + mPresenter?.setDoorRelayMode(idList,mode) + } + .create() + tipDialog.show() + } + + private fun showLayoutLoading() { + loadingLayout.visibility = View.VISIBLE + } + + private fun hideLayoutLoading() { + loadingLayout.visibility = View.GONE + } + + private fun refreshData() { + if (isLoading) { + return + } + isLoading = true + mPresenter?.getDeviceList(mPager.page_no) + } + + private fun pre() { + if (isLoading) { + return + } + if (mPager.page_no <= 1) { + } else { + isLoading = true + showLayoutLoading() + mPresenter?.getDeviceList(mPager.page_no - 1) + } + } + + private fun next() { + if (isLoading) { + return + } + if (mPager.page_no >= mPager.total_pages) { + } else { + isLoading = true + showLayoutLoading() + mPresenter?.getDeviceList(mPager.page_no + 1) + } + } + + private fun showExitDialog() { + val builder = QMUIDialog.EditTextDialogBuilder(activity) + + builder.setPlaceholder("输入密码") + .setTitle("请输入密码") + .setInputType(InputType.TYPE_NUMBER_VARIATION_PASSWORD or InputType.TYPE_CLASS_NUMBER) + .addAction( + "取消" + ) { dialog, index -> + KeyboardUtils.hideSoftInput(builder.editText) + dialog?.dismiss() + } + .addAction( + "确定" + ) { dialog, index -> + val text = builder.editText.text + LogUtils.d(text) + LogUtils.d("112233".equals(text)) + if ("112233" == text.toString()) { + activity?.finish() + exitProcess(0) + } else { +// ToastUtils.showShort("密码不正确") + showPwdErrorTip() + } + } + .setCancelable(false) + .setCanceledOnTouchOutside(false) + val dialog = builder.show() + + dialog.hideNavigationBar() + } + + private fun showPwdErrorTip() { + val tipDialog = QMUITipDialog.Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_FAIL) + .setTipWord("密码错误") + .create() + tipDialog.show() + tipDialog.hideNavigationBar() + sysExitBtn.postDelayed({ + tipDialog.dismiss() + }, 1500) + } + + override fun initData() { + mPresenter?.getDeviceList(1) + + mPager.page_no = 1 + if (NetworkUtils.isConnected()) { + showEmpty(1) + isLoading = true + mPresenter?.getDeviceList(mPager.page_no) + } else { + showEmpty(2) + } + + + } + + override fun onResume() { + super.onResume() + mPresenter?.getTeacherInfo(User.getUser().user_id) + } + + override fun initPresenter(): SettingPresenter = SettingPresenter(this) + override fun onSetSuccess() { + hideLoading() + showDialogToast("设置成功!") + } + + override fun onSetError(error: String) { + hideLoading() + showDialogToast(error,icon = QMUITipDialog.Builder.ICON_TYPE_FAIL) + } + + + override fun onStop() { + super.onStop() + EventBus.getDefault().unregister(this) + } + + + override fun onStart() { + super.onStart() + EventBus.getDefault().register(this) + } + + //接收消息 + @Subscribe(threadMode = ThreadMode.MAIN) + fun onMessageEvent(event: TimeShow) { +// timeView.setTime(event) + } + + override fun onDeviceListSuccess(list: MutableList, pager: Pager) { + pageTv?.apply { + if (isRefresh) { + toast("刷新成功!") + isRefresh = false + } + mAdapter.setList(list) + mPager = pager + pageTv.text = "${pager.page_no} / ${pager.total_pages}" + totalTv.text = "共${pager.total_count}条" + + val disabledColor = Color.parseColor("#666666") + val color = Color.parseColor("#3ca0e9") + if (pager.page_no <= 1) { + preTxtBtn.textColor = disabledColor + goPageOne.visibility = View.GONE + } else { + preTxtBtn.textColor = resources.getColor(R.color.s_app_color_blue) + goPageOne.visibility = View.VISIBLE + } + + if (pager.page_no >= pager.total_pages) { + nextTxtBtn.textColor = disabledColor + } else { + nextTxtBtn.textColor = resources.getColor(R.color.s_app_color_blue) + } + + isLoading = false + showEmpty(3) + hideLayoutLoading() + } + } + + override fun onDeviceListError(error: String) { + + } + + /** + * type 1 loading 2 neterror 3 empty + */ + private fun showEmpty(type: Int) { + when (type) { + 1 -> { + mAdapter.setEmptyView(R.layout.layout_loading) + mAdapter.emptyLayout?.apply { + this.QMUIEmptyView.setLoadingShowing(true) + this.QMUIEmptyView.setTitleText("数据加载中") + } + } + + 2 -> { + mAdapter.setEmptyView(R.layout.layout_loading) + mAdapter.emptyLayout?.apply { + this.QMUIEmptyView.show(false, null, "网络连接异常,请检查", "去设置") { + NetworkUtils.openWirelessSettings() + } + } + } + + 3 -> { + mAdapter.setEmptyView(R.layout.layout_empty) + } + } + + } + + override fun onUserInfoError(error: String) { + + } + + override fun onUserInfoSuccess(info: TeacherInfo) { + userNameTv.text = info.teacher_name + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/model/Device.kt b/app/src/main/java/com/yzx/escreen/model/Device.kt new file mode 100644 index 0000000..223aaa2 --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/model/Device.kt @@ -0,0 +1,9 @@ +package com.yzx.escreen.model + +data class Device ( + val id: Int = 0, + val name:String = "", + val type:Int = 0, + val device_category:Int = 0, + var isChecked:Boolean = false +) \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/model/EventBugBean.kt b/app/src/main/java/com/yzx/escreen/model/EventBugBean.kt index 4e678b6..5c206d2 100644 --- a/app/src/main/java/com/yzx/escreen/model/EventBugBean.kt +++ b/app/src/main/java/com/yzx/escreen/model/EventBugBean.kt @@ -3,4 +3,6 @@ package com.yzx.escreen.model class EventBugBean { } -data class EventLeaveIds(var ids:String="") \ No newline at end of file +data class EventLeaveIds(var ids:String="") + +data class UserVersionCheck(var userCheck:Boolean = true) \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/presenter/SettingPresenter.kt b/app/src/main/java/com/yzx/escreen/presenter/SettingPresenter.kt new file mode 100644 index 0000000..6347334 --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/presenter/SettingPresenter.kt @@ -0,0 +1,111 @@ +package com.yzx.escreen.presenter + +import com.blankj.utilcode.util.LogUtils +import com.lzy.okgo.OkGo +import com.lzy.okgo.model.Response +import com.yzx.escreen.config.Config +import com.yzx.escreen.config.YzxInterface +import com.yzx.escreen.model.Device +import com.yzx.escreen.model.Pager +import com.yzx.escreen.model.TeacherInfo +import com.yzx.escreen.model.User +import com.yzx.escreen.presenter.base.BasePresenter +import com.yzx.escreen.presenter.base.IView +import com.yzx.escreen.presenter.base.JsonCallBack +import com.yzx.escreen.presenter.base.YzxResponse + +class SettingPresenter(view: SettingView) : BasePresenter(view) { + + + fun getTeacherInfo(user_id: Int) { + if(User.getUser().token.isEmpty()){ + return + } + val url = "${Config.BASE_URL}${YzxInterface.INTERFACE_GET_TEACHER_INFO}" + OkGo.post>(url) + .tag(this) + .params("user_id", user_id) + .execute(object : JsonCallBack>() { + + override fun onSuccess(response: Response>?) { + LogUtils.d(response) + if (response?.isSuccessful == true) { + mView?.onUserInfoSuccess(response.body().data) + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + mView?.onUserInfoError(response?.body()?.msg ?: "") + } + }) + } + fun getDeviceList(pageNo: Int) { + if(User.getUser().token.isEmpty()){ + return + } + val url = "${Config.BASE_URL}${YzxInterface.INTERFACE_ACCESS_CONTROL_GET_FACE_DEVICE_LIST}" + OkGo.post>(url) + .tag(this) + .params("page_size", 10) + .params("page_no", pageNo) + .execute(object : JsonCallBack>() { + + + override fun onSuccess(response: Response>?) { + LogUtils.d(response) + if (response?.isSuccessful == true) { + mView?.onDeviceListSuccess(response.body().list, response.body().pager) + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + mView?.onDeviceListError(response?.body()?.msg ?: "") + } + }) + } + + + fun setDoorRelayMode(deviceIdList: MutableList,mode:Int = 0) { + if(User.getUser().token.isEmpty()){ + return + } + val url = "${Config.BASE_URL}${YzxInterface.INTERFACE_ACCESS_CONTROL_POST_DOOR_RELAY_MODE}" + OkGo.post>(url) + .tag(this) + .params("device_ids", deviceIdList.joinToString(",")) + .params("mode", mode) + .execute(object : JsonCallBack>() { + + override fun onSuccess(response: Response>?) { + LogUtils.d(response) + if (response?.isSuccessful == true) { + mView?.onSetSuccess() + } + } + + override fun onError(response: Response>?) { + super.onError(response) + LogUtils.d(response) + mView?.onSetError(response?.body()?.msg ?: "") + } + }) + } + + + + +} + +interface SettingView : IView { + fun onSetSuccess() + fun onSetError(error:String) + + fun onDeviceListSuccess(list:MutableList, pager: Pager) + fun onDeviceListError(error:String) + fun onUserInfoSuccess(info: TeacherInfo) + fun onUserInfoError(error:String) +} \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_open_btn.xml b/app/src/main/res/drawable/shape_open_btn.xml new file mode 100644 index 0000000..0edc80f --- /dev/null +++ b/app/src/main/res/drawable/shape_open_btn.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_setting.xml b/app/src/main/res/layout/fragment_setting.xml new file mode 100644 index 0000000..f197987 --- /dev/null +++ b/app/src/main/res/layout/fragment_setting.xml @@ -0,0 +1,260 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_device_item.xml b/app/src/main/res/layout/layout_device_item.xml new file mode 100644 index 0000000..5017498 --- /dev/null +++ b/app/src/main/res/layout/layout_device_item.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-mdpi/setting.png b/app/src/main/res/mipmap-mdpi/setting.png new file mode 100644 index 0000000000000000000000000000000000000000..b9319323229612de37d5392fc3e2ea4ff310846b GIT binary patch literal 1387 zcmV-x1(f=UP)Px)B}qgRO{yQFzH_o|-5W)?9##(#b?RKvXpEtJU<$d1=;r^@l{%OD8Us}k~ zOu5tP^ch0fNJ57YKAxYSpQLkZK5wR+!fQ!h2+!L!!b{(2qTKO#+&Jex)8p3K%PlzuoWmS4r5~&#ROJfatnzv)yh#N)Me*r^gV&dpd(dukZVVG3F(G?!CV+ z<(>B31!!rlfdsk&+6}`1V6d?G+uPf_we~Ud+*584>{(EhLe3FwAp#QG!do9&lvR1I z01o71_&g4~QRqK;*lxGm``pmjyT}QoF{(YMM7{V}s%v@3!GpWqZehf}??JhlN4)oE zINx>My8>xN1&f|z6a#N9in1|={X2z*m3MR5Q&f;u4ub;R4yXs=Gv*8c2BjnxgcN|f zpV1%|dN3a4(GnQ3%Av5C6iWhdA(#m$CO;@>i~)K^7W-t({7tN2i3HRrH$%MiAWnRE z%sKZZm5baLAVRQ4(AqOp-IJJ&Si~u7wQN%;r3pp@$3!EG$}w>s zOG2&n*PbWnoa%j1IS>e6-m(Xy41lA@TFZin3M~=On|0LM%dwyk1#4Oxs)f=-PSJBr z{UNy`7jggu*4j;0sAESFLbzzzJ<%P+oC7XeGS;MAKFo2>-4uwcn8@(**n<@b@YuwX zZ4)+Dp-YH$7mS6;LsX7IBhne#u36blz#FRC$<$p+Mu?18U`SE93PDs}!vKW%=7MZ% z0ZQocaz&%TqH@eIXUYw0?cZS-E?O`k?wgFl5pJm)sGlqa34IqM1#O;J%v}uBf5{ytugF z5DosWWjXmBRIX__u2#9(EQMnontHV6%-UvItK4kNr$x6licsIFoqDA^MCH~@oxV${ zoGjy7tTC|EiDUi;@2T3J?^ck>yJGH3bIVyc{&cQk12JPpataRLt=jUG+7f7;H1w?G z(bTJPy(2~KRxLs(md&ho^U#g;t5kcqGJzH$Y#k&pfUUb#ix9jgD7F0%!p4|$Y1=dA z5iI|?J>QJMa6>0*b6XvjX_!;P9l21hnTL$gaAwxYEWj1%7jqf69wyU?10lTJRG=&M z?)oi{X7)G=6~}4g|M8}j6o42arF=b)KhTj@(jvzdi@2m9g;p4{aZXTk()^5OC9T;L zipqgEn6Wzhi#v&EYbRt(Zi^mM(=Vb4eUPA@0E=1D*AU^fN_NiO!Thvl*RJxMBH3q0 zm>;%HKRd+B{k2;oNv>APaYH9kp0xwnUr`Pot=KN!fSOwBx3D@cp;{{URRoV3g`o9O@m002ovPDHLkV1m0$mnZ-L literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-mdpi/setting_select.png b/app/src/main/res/mipmap-mdpi/setting_select.png new file mode 100644 index 0000000000000000000000000000000000000000..ba9d149cf052d4794ee044dcfc979740e158c698 GIT binary patch literal 1025 zcmV+c1pfPpP)Px&yGcYrRA@u(T3v49Fc6*z-76IJjoxCVvMQW}a1!7o2`3@dQmMBnZwRiikXbn) zG$f8^oY)k!+gDuAeDnW}gW&n^CEi5{IH-z2g5@7LCLhzMjV~3@*Tp}h?cf1}PwxH$ zrO&-Tr=CLYR0*K$k{**I9o8P^FlX|UC*q8Ubfcq8gLqdwA)<(kV@9ASK zJuf|H4Q?21M+bn7DNlyW-3$okQY8RkzMk|Krt=cHwW1|epsKLSl_RAK9mrw4Ujfia zdbcU>YIh;b4{5rT6d{r4nv^Ag4N^K?PoI)9kYT(dDX{z;ChPEVd~rv#9T5hRwkQb! zvfxBsI0;kA^)Q$rKxhXJK;>Q0_e5bW0B8g!0(L@?c~MaMInY-3FaR6DiLA$IdWGLj zm9`n2Wl^{Sjs_9+d@T;%JvbG{?_vL0hy3ot($pi31w}d^eqTrem_|2qwT!kSz+m;A z${S@flMUbJY)7f9S)#d+umz>8 zDbj13S+M}AtQ-)&6?0=|EPw%FFzIryY5^QOID=C{)zAw78CB^zCpIw#@#Jq60+;ERib-8+FggsH?8VEJca}xlqhL^PD~ZV&Dmw^@Rr=w;L5TM@q-&+H2A> zT{VyEcB9yW4{)tkb@}qvp5!*gkQZ>0WsgoF*Ae6eT-!CB>p{T_IO+6I_1;~8(`~XO zt;2Q2&OE0CyRKBWdFMLcii(~0x#ey~1fi=&s_wLD;*!@OiTBS`=d_-`7{4BZU;>0A z0vdD$S~ODQ+C3w~y_wB+x(TF`2LK6Dx-6E&EEDfK;Hm5H39b&2_r-k<3LL>Pu(sRrWloG|9XdaQ|OP(T+^i5~Xri#zz zT$}ckDP!{@E0`18=-~xi9>x}*NKrbr@rV?tH*nITA}tP5K;?7Z!0C&DMnz8{X;m%T vST4`K-b}x6YOc0zWa<9Lo9A39*yWzTDn57^$WavH00000NkvXXu0mjfhZ^6D literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xhdpi/icon_user.png b/app/src/main/res/mipmap-xhdpi/icon_user.png new file mode 100644 index 0000000000000000000000000000000000000000..1f9e74b7b2c9bf3b7c723a5b18109601d9625f46 GIT binary patch literal 883 zcmV-(1C0EMP)Px&ElET{RA@u(nhkE(Fbu`LlQ2#KoMdnk;3SNbY&*%=Nrs+OOKqCQ&(B#A)hhi} zO-mjB;;+Q*ja~S|tH8cNxSY+UDTz|~$Ww}3!^25hwTMo+Knc3&%7b>uV zy*INbGn)oG3+}s_{a{Igaj+^te^%vH;Q;k@alfiA?ek?w6%OwAE9rVFJRrX;@tKmL zz#*O#6=|=7EZMopr8n{Uwa`D zL9W-n%%V|%44fKc0Qwea>~%3)MzCm*J*(B(1LXjx48I4LTpLWZ(j7 z;yRr32u`(H1+KE7-Pr5FRVGOl*~XHHZ_KS;yCl|wt4@L}$(DgNNX1*ai`s*$PNG<^ z>MfXa=bAmZSJf|8&xHkcHCC;0JvEUveIL6k1v6IACuMf=l?>T~+r(XKxtVZ2Irfd~ z-iSAiK22;*_*|PZ)WWHSbb=>O5wSTfv~bl-IYq;QkW0gD_O(}Y%YOpr>Dlj|R0S7 z#}igdD{CqpNs|c@eYcU!TQM4et468H%IqHS<9(_j1@9tD2utk zELvh&Og1F1zCow#N5$} z`zhjbU+wjPJ>}z$?=2nP%ff&6y=4?fr~ZFN%$=%mX0l7e{RJp>#W+?fAh`el002ov JPDHLkV1ix!pS%D7 literal 0 HcmV?d00001