1、增加室内整理工具布局2、封装定时业务类

This commit is contained in:
qiji4215 2023-06-26 14:12:38 +08:00
parent d3fc05adad
commit 97ad787f51
27 changed files with 256 additions and 0 deletions

View File

@ -40,6 +40,9 @@
<uses-permission android:name="android.permission.CAMERA" />
<!-- 音频权限 -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!--闹钟和提醒-->
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<!--android:largeHeap="true" 大内存 128M -->
<application
android:name=".OMQSApplication"

View File

@ -0,0 +1,131 @@
package com.navinfo.omqs.server
import android.annotation.SuppressLint
import android.app.AlarmManager
import android.app.PendingIntent
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import android.os.SystemClock
/**
* date:2023/6/18
* author:qj
* description:定时器
*/
class TimeTask<T : TimeTask.Task?>(context: Context, actionName: String, task: T) {
private var mContext: Context?
private val mActionName: String
private var mReceiver: TimeTaskReceiver? = null
private val mTask: T?
companion object {
private var mPendingIntent: PendingIntent? = null
}
init {
mContext = context
mActionName = actionName
mTask = task
initReceiver(context, actionName)
}
fun startLooperTask() {
if (null != mTask) {
mTask.exeTask()
configureAlarmManager(mTask.period())
}
}
fun stopLooperTask() {
cancelAlarmManager()
}
fun onClose() {
mContext!!.unregisterReceiver(mReceiver)
mContext = null
}
@SuppressLint("ObsoleteSdkInt")
private fun configureAlarmManager(time: Long) {
val manager = mContext!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
val pendIntent = pendingIntent
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> {
manager.setExactAndAllowWhileIdle(
AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + time,
pendIntent
)
}
Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT -> {
manager.setExact(
AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + time,
pendIntent
)
}
else -> {
manager[AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + time] = pendIntent
}
}
}
@get:SuppressLint("UnspecifiedImmutableFlag")
private val pendingIntent: PendingIntent?
get() {
if (mPendingIntent == null) {
val requestCode = 0
val intent = Intent()
intent.action = mActionName
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
mPendingIntent = PendingIntent.getBroadcast(
mContext, requestCode, intent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
)
}
else -> {
mPendingIntent = PendingIntent.getBroadcast(
mContext,
requestCode,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
)
}
}
}
return mPendingIntent
}
private fun cancelAlarmManager() {
val manager = mContext!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
manager.cancel(pendingIntent)
}
private fun initReceiver(context: Context, actionName: String) {
mReceiver = TimeTaskReceiver()
val intentFilter = IntentFilter()
intentFilter.addAction(actionName)
context.registerReceiver(mReceiver, intentFilter)
}
internal inner class TimeTaskReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
startLooperTask()
}
}
interface Task {
fun period(): Long {
// 默认时间5S
return 5000L
}
fun exeTask()
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/icon_finish_press"></item>
<item android:state_selected="true" android:drawable="@drawable/icon_finish_press"></item>
<item android:state_enabled="true" android:drawable="@drawable/icon_finish_nor"></item>
<item android:state_enabled="false" android:drawable="@drawable/icon_finish_disable"></item>
<item android:drawable="@drawable/icon_finish_nor"></item>
</selector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/icon_forward_press"></item>
<item android:state_selected="true" android:drawable="@drawable/icon_forward_press"></item>
<item android:state_enabled="true" android:drawable="@drawable/icon_forward_nor"></item>
<item android:state_enabled="false" android:drawable="@drawable/icon_forward_disable"></item>
<item android:drawable="@drawable/icon_forward_nor"></item>
</selector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_selected="false" android:state_enabled="true" android:drawable="@drawable/icon_no_mediaflag"></item>
<item android:state_enabled="false" android:drawable="@drawable/icon_mediaflag_disable"></item>
<item android:state_enabled="true" android:state_selected="true" android:drawable="@drawable/icon_mediaflag"></item>
<item android:drawable="@drawable/icon_no_mediaflag"></item>
</selector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/icon_next_press"></item>
<item android:state_selected="true" android:drawable="@drawable/icon_next_press"></item>
<item android:state_enabled="false" android:drawable="@drawable/icon_next_disable"></item>
<item android:state_enabled="true" android:drawable="@drawable/icon_next_nor"></item>
<item android:drawable="@drawable/icon_next_nor"></item>
</selector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_selected="false" android:state_enabled="true" android:drawable="@drawable/icon_play_nor"></item>
<item android:state_enabled="false" android:drawable="@drawable/icon_play_disable"></item>
<item android:state_enabled="true" android:state_selected="true" android:drawable="@drawable/icon_pause_nor"></item>
<item android:drawable="@drawable/icon_play_nor"></item>
</selector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/icon_select_point_press"></item>
<item android:state_selected="true" android:drawable="@drawable/icon_select_point_press"></item>
<item android:state_enabled="true" android:drawable="@drawable/icon_select_point_nor"></item>
<item android:state_enabled="false" android:drawable="@drawable/icon_select_point_disable"></item>
<item android:drawable="@drawable/icon_select_point_nor"></item>
</selector>

View File

@ -119,6 +119,73 @@
android:elevation="2dp"
android:onClick="@{()->mainActivity.onClickMenu()}" />
<androidx.constraintlayout.helper.widget.Flow
android:id="@+id/main_activity_flow_indoor"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/top_right_drawer_btns_mr"
app:constraint_referenced_ids="main_activity_snapshot_finish,main_activity_trace_snapshot_points,main_activity_snapshot_media_flag,main_activity_snapshot_rewind,main_activity_snapshot_pause,main_activity_snapshot_next,main_activity_menu_indoor_group"
app:flow_horizontalGap="6dp"
app:flow_wrapMode="aligned"
app:layout_constraintRight_toLeftOf="@id/main_activity_right_fragment"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Group
android:id="@+id/main_activity_menu_indoor_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="main_activity_snapshot_finish,main_activity_trace_snapshot_points,main_activity_snapshot_media_flag,main_activity_snapshot_rewind,main_activity_snapshot_pause,main_activity_snapshot_next" />
<ImageButton
android:id="@+id/main_activity_snapshot_finish"
style="@style/top_right_drawer_btns_style"
android:clickable="true"
android:enabled="false"
android:focusable="true"
android:src="@drawable/map_trace_finish"
tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/main_activity_trace_snapshot_points"
style="@style/top_right_drawer_btns_style"
android:focusable="true"
android:src="@drawable/map_trace_select_point"
tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/main_activity_snapshot_media_flag"
style="@style/top_right_drawer_btns_style"
android:enabled="false"
android:focusable="true"
android:src="@drawable/map_trace_mediaflag"
tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/main_activity_snapshot_rewind"
style="@style/top_right_drawer_btns_style"
android:enabled="false"
android:focusable="true"
android:src="@drawable/map_trace_forward"
tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/main_activity_snapshot_pause"
style="@style/top_right_drawer_btns_style"
android:enabled="false"
android:focusable="true"
android:src="@drawable/map_trace_pause"
tools:ignore="DuplicateIds,MissingConstraints" />
<ImageButton
android:id="@+id/main_activity_snapshot_next"
style="@style/top_right_drawer_btns_style"
android:enabled="false"
android:focusable="true"
android:src="@drawable/map_trace_next"
tools:ignore="DuplicateIds,MissingConstraints" />
<androidx.constraintlayout.widget.Barrier
android:layout_width="wrap_content"
android:layout_height="wrap_content"