帮我优化以下 const val LOAD_H5_SUCCESS="appLoadH5Success" //H5加载完成 const val APP_START_ACTIVITY="appStartActivity" const val GET_GAODE_LOCATION = "appGetGaoDeLocation" //获取定位 const val BARCODESCANNER_SCAN = "appBarcodescannerScan" //扫码 const val APP_GET_FILE_BASE64 = "appGetFileBase64" const val CAMERA_UPLOAD = "appCameraUpload" //调取拍照的功能 const val CREDENTIALS_CAMERA_UPLOAD = "appCredentialsCameraUpload" //调取证件拍照的功能 const val SCAN_BLUETOOTH = "appScanBluetooth" const val APP_DISCONNECT_BLE="appDisConnectBle" const val TH_PRINT = "appThPrint" const val GET_TH_WEIGHT = "appGetThWeight" const val GET_SJ_WEIGHT = "appGetSjWeight" const val PDA_PRINT = "appPdaPrint" const val GALLERY_UPLOAD = "appGalleryUpload" //上传文件 const val CREDENTIALS_GALLERY_UPLOAD = "appCredentialsGalleryUpload" //证件本地文件上传 const val FILE_UPLOAD = "appFileUpload" const val CLEAR_CACHE = "appClearCache" //清理缓存 const val GET_CACHE_SIZE = "appGetCacheSize" //获取缓存 const val DOWNLOAD_FILE = "appDownloadFile" const val PHONE_DEVICE = "appPhoneDevice" //H5获取手机设备信息 const val MEDIA_START_RECORD = "appMediaStartRecord" //开启录音 const val MEDIA_STOP_RECORD = "appMediaStopRecord" //结束录音 const val PDA_SCAN = "appPdaScan" const val APP_BLE_CONNECTED = "appBleConnected" const val APP_BLE_CONNECTED_BY_PARAMS = "appBleConnectedByParams" const val APP_USB_CONNECTED = "appUsbConnected" const val APP_CONNECT_USB = "appConnectUsb" const val APP_BACK_PAGE = "appBackPage" const val APP_LOGOUT="appLogout" //退出登录 const val APP_LOGOUT_MESSAGE="appLogoutMessage" //402 401 提示 const val APP_TOKEN_TIMEOUT="appTokenTimeOut" //token过期 const val APP_TO_BACKLOG="appToBacklog" //返回工作台 const val APP_REFRESH_BACKLOG="appRefreshBacklog" //刷新工作台 const val APP_REFRESH_BACKLOG_NUM="appRefreshBacklogNum" //刷新工作台数量 const val APP_CLOSE_MULTI_CHOOSE="appCloseMultiChoose" const val APP_SET_ORG_DATA="appSetOrgData"
时间: 2023-11-12 08:06:39 浏览: 124
可以将这些常量放在一个公共的类中,以便全局使用,如下所示:
```
object AppConstants {
const val LOAD_H5_SUCCESS="appLoadH5Success" //H5加载完成
const val APP_START_ACTIVITY="appStartActivity"
const val GET_GAODE_LOCATION = "appGetGaoDeLocation" //获取定位
const val BARCODESCANNER_SCAN = "appBarcodescannerScan" //扫码
const val APP_GET_FILE_BASE64 = "appGetFileBase64"
const val CAMERA_UPLOAD = "appCameraUpload" //调取拍照的功能
const val CREDENTIALS_CAMERA_UPLOAD = "appCredentialsCameraUpload" //调取证件拍照的功能
const val SCAN_BLUETOOTH = "appScanBluetooth"
const val APP_DISCONNECT_BLE="appDisConnectBle"
const val TH_PRINT = "appThPrint"
const val GET_TH_WEIGHT = "appGetThWeight"
const val GET_SJ_WEIGHT = "appGetSjWeight"
const val PDA_PRINT = "appPdaPrint"
const val GALLERY_UPLOAD = "appGalleryUpload" //上传文件
const val CREDENTIALS_GALLERY_UPLOAD = "appCredentialsGalleryUpload" //证件本地文件上传
const val FILE_UPLOAD = "appFileUpload"
const val CLEAR_CACHE = "appClearCache" //清理缓存
const val GET_CACHE_SIZE = "appGetCacheSize" //获取缓存
const val DOWNLOAD_FILE = "appDownloadFile"
const val PHONE_DEVICE = "appPhoneDevice" //H5获取手机设备信息
const val MEDIA_START_RECORD = "appMediaStartRecord" //开启录音
const val MEDIA_STOP_RECORD = "appMediaStopRecord" //结束录音
const val PDA_SCAN = "appPdaScan"
const val APP_BLE_CONNECTED = "appBleConnected"
const val APP_BLE_CONNECTED_BY_PARAMS = "appBleConnectedByParams"
const val APP_USB_CONNECTED = "appUsbConnected"
const val APP_CONNECT_USB = "appConnectUsb"
const val APP_BACK_PAGE = "appBackPage"
const val APP_LOGOUT="appLogout" //退出登录
const val APP_LOGOUT_MESSAGE="appLogoutMessage" //402 401 提示
const val APP_TOKEN_TIMEOUT="appTokenTimeOut" //token过期
const val APP_TO_BACKLOG="appToBacklog" //返回工作台
const val APP_REFRESH_BACKLOG="appRefreshBacklog" //刷新工作台
const val APP_REFRESH_BACKLOG_NUM="appRefreshBacklogNum" //刷新工作台数量
const val APP_CLOSE_MULTI_CHOOSE="appCloseMultiChoose"
const val APP_SET_ORG_DATA="appSetOrgData"
}
```
使用时只需通过类名调用即可,如 `AppConstants.LOAD_H5_SUCCESS`。这样做的好处是方便管理和维护,同时也可以避免命名冲突。
阅读全文