mirror of
https://github.com/easychen/pushdeer.git
synced 2025-01-10 15:05:27 +08:00
修复切换页面超量请求的bug
This commit is contained in:
parent
9c613eee4e
commit
67c421af70
@ -11,8 +11,8 @@ android {
|
||||
applicationId "com.pushdeer.os"
|
||||
minSdk 22
|
||||
targetSdk 31
|
||||
versionCode 1
|
||||
versionName "1.0-dev-2"
|
||||
versionCode 4
|
||||
versionName "1.0-dev-4"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
@ -84,6 +84,7 @@ dependencies {
|
||||
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"
|
||||
implementation "com.google.accompanist:accompanist-insets:$accompanist_version"
|
||||
// implementation "com.google.accompanist:accompanist-insets-ui:$accompanist_version"
|
||||
// implementation "com.google.accompanist:accompanist-swiperefresh:$accompanist_version"
|
||||
|
||||
// room
|
||||
def room_version = "2.4.0"
|
||||
@ -109,6 +110,6 @@ dependencies {
|
||||
implementation "io.coil-kt:coil:1.4.0"
|
||||
|
||||
implementation 'com.github.vishalkumarsinghvi:sign-in-with-apple-button-android:0.6'
|
||||
// implementation 'com.github.bumptech.glide:glide:4.12.0'
|
||||
// annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
|
||||
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.pushdeer.os",
|
||||
"variantName": "debug",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0-dev-2",
|
||||
"outputFile": "app-debug.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
@ -1,11 +1,8 @@
|
||||
package com.pushdeer.os
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.util.Linkify
|
||||
import androidx.activity.compose.setContent
|
||||
@ -37,6 +34,7 @@ import com.pushdeer.os.ui.compose.page.LoginPage
|
||||
import com.pushdeer.os.ui.compose.page.main.MainPage
|
||||
import com.pushdeer.os.ui.theme.PushDeerTheme
|
||||
import com.pushdeer.os.util.ActivityOpener
|
||||
import com.pushdeer.os.util.NotificationUtil
|
||||
import com.pushdeer.os.util.SystemUtil
|
||||
import com.pushdeer.os.viewmodel.LogDogViewModel
|
||||
import com.pushdeer.os.viewmodel.MessageViewModel
|
||||
@ -110,17 +108,7 @@ class MainActivity : AppCompatActivity(), RequestHolder {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.createNotificationChannel(
|
||||
NotificationChannel(
|
||||
"high_system",
|
||||
"服务提醒",
|
||||
NotificationManager.IMPORTANCE_HIGH
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
NotificationUtil.setupChannel(this)
|
||||
|
||||
myActivity = this
|
||||
qrScanActivityOpener = ActivityOpener.forResult(this)
|
||||
|
@ -15,7 +15,11 @@ class LogDog {
|
||||
var timestamp:Long = System.currentTimeMillis()
|
||||
|
||||
override fun toString(): String {
|
||||
return "id:$id level:$level entity:$entity\nlog:$log time:${timestamp.toTimestamp()}"
|
||||
return "id:$id\n" +
|
||||
"level:$level\n" +
|
||||
"entity:$entity\n" +
|
||||
"log:$log\n" +
|
||||
"time:${timestamp.toTimestamp()}"
|
||||
}
|
||||
|
||||
// @Composable
|
||||
|
@ -31,7 +31,7 @@ import kotlinx.coroutines.launch
|
||||
@Composable
|
||||
fun DeviceListPage(requestHolder: RequestHolder) {
|
||||
|
||||
SideEffect {
|
||||
LaunchedEffect(Unit) {
|
||||
requestHolder.coroutineScope.launch {
|
||||
requestHolder.pushDeerViewModel.deviceList()
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@ -26,7 +26,7 @@ import kotlinx.coroutines.launch
|
||||
@Composable
|
||||
fun KeyListPage(requestHolder: RequestHolder) {
|
||||
|
||||
SideEffect {
|
||||
LaunchedEffect(Unit) {
|
||||
requestHolder.coroutineScope.launch {
|
||||
requestHolder.pushDeerViewModel.keyList()
|
||||
}
|
||||
|
@ -26,19 +26,12 @@ import com.pushdeer.os.holder.RequestHolder
|
||||
import com.pushdeer.os.ui.navigation.Page
|
||||
import com.pushdeer.os.ui.navigation.pageList
|
||||
import com.pushdeer.os.ui.theme.mainBottomBtn
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
@ExperimentalMaterialApi
|
||||
@Composable
|
||||
fun MainPage(requestHolder: RequestHolder) {
|
||||
|
||||
SideEffect {
|
||||
requestHolder.coroutineScope.launch {
|
||||
requestHolder.pushDeerViewModel.userInfo()
|
||||
}
|
||||
}
|
||||
|
||||
var titleStringId by remember {
|
||||
mutableStateOf(Page.Messages.labelStringId)
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import kotlinx.coroutines.launch
|
||||
@Composable
|
||||
fun MessageListPage(requestHolder: RequestHolder) {
|
||||
|
||||
SideEffect {
|
||||
LaunchedEffect(Unit) {
|
||||
requestHolder.coroutineScope.launch {
|
||||
requestHolder.pushDeerViewModel.messageList()
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.pushdeer.os.util
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
|
||||
object NotificationUtil {
|
||||
|
||||
fun setupChannel(context: Context){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val notificationManager =
|
||||
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.createNotificationChannel(
|
||||
NotificationChannel(
|
||||
"high_system",
|
||||
"服务提醒",
|
||||
NotificationManager.IMPORTANCE_HIGH
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -44,12 +44,12 @@ class PushDeerViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
logDogRepository.logi("login", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "login: ${e.localizedMessage}")
|
||||
logDogRepository.loge("login", "", e.toString())
|
||||
return@withContext
|
||||
}
|
||||
logDogRepository.logi("login", "normally", "nothing happened")
|
||||
} else if (token == "" && idToken == "") {
|
||||
return@withContext
|
||||
} else if (token != "") {
|
||||
@ -71,6 +71,7 @@ class PushDeerViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
logDogRepository.logi("userInfo", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "userInfo: ${e.localizedMessage}")
|
||||
logDogRepository.loge("userInfo", "", e.toString())
|
||||
@ -96,6 +97,7 @@ class PushDeerViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
logDogRepository.logi("deviceReg", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "deviceReg: ${e.localizedMessage}")
|
||||
logDogRepository.loge("deviceReg", "", e.toString())
|
||||
@ -112,6 +114,7 @@ class PushDeerViewModel(
|
||||
deviceList.addAll(it.devices.reversed())
|
||||
}
|
||||
}
|
||||
logDogRepository.logi("deviceList", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "deviceList: ${e.localizedMessage}")
|
||||
logDogRepository.loge("deviceList", "", e.toString())
|
||||
@ -130,6 +133,7 @@ class PushDeerViewModel(
|
||||
deviceList()
|
||||
Log.d(TAG, "deviceRemove: $it")
|
||||
}
|
||||
logDogRepository.logi("deviceRemove", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "deviceRemove: ${e.localizedMessage}")
|
||||
logDogRepository.loge("deviceRemove", "", e.toString())
|
||||
@ -137,12 +141,13 @@ class PushDeerViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deviceRename(deviceInfo: DeviceInfo,onReturn: () -> Unit={}){
|
||||
withContext(Dispatchers.IO){
|
||||
suspend fun deviceRename(deviceInfo: DeviceInfo, onReturn: () -> Unit = {}) {
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
pushDeerService.deviceRename(token,deviceInfo.id,deviceInfo.name)
|
||||
pushDeerService.deviceRename(token, deviceInfo.id, deviceInfo.name)
|
||||
logDogRepository.logi("deviceRename", "normally", "nothing happened")
|
||||
onReturn()
|
||||
}catch (e:Exception){
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "deviceRename: ${e.localizedMessage}")
|
||||
logDogRepository.loge("deviceRename", "", e.toString())
|
||||
}
|
||||
@ -158,6 +163,7 @@ class PushDeerViewModel(
|
||||
keyList.addAll(it.keys)
|
||||
}
|
||||
}
|
||||
logDogRepository.logi("keyGen", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "keyGen: ${e.localizedMessage}")
|
||||
logDogRepository.loge("keyGen", "", e.toString())
|
||||
@ -176,6 +182,7 @@ class PushDeerViewModel(
|
||||
).let {
|
||||
keyList()
|
||||
}
|
||||
logDogRepository.logi("keyRegen", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "keyRegen: ${e.localizedMessage}")
|
||||
logDogRepository.loge("keyRegen", "", e.toString())
|
||||
@ -183,16 +190,17 @@ class PushDeerViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun keyRename(key: PushKey,onReturn: () -> Unit={}){
|
||||
withContext(Dispatchers.IO){
|
||||
suspend fun keyRename(key: PushKey, onReturn: () -> Unit = {}) {
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
pushDeerService.keyRename(
|
||||
token,
|
||||
key.id,
|
||||
key.name
|
||||
)
|
||||
logDogRepository.logi("keyRename", "normally", "nothing happened")
|
||||
onReturn()
|
||||
}catch (e: Exception) {
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "keyRename: ${e.localizedMessage}")
|
||||
logDogRepository.loge("keyRename", "", e.toString())
|
||||
}
|
||||
@ -208,6 +216,7 @@ class PushDeerViewModel(
|
||||
keyList.addAll(it.keys)
|
||||
}
|
||||
}
|
||||
logDogRepository.logi("keyList", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "keyList: ${e.localizedMessage}")
|
||||
logDogRepository.loge("keyList", "", e.toString())
|
||||
@ -221,6 +230,7 @@ class PushDeerViewModel(
|
||||
pushDeerService.keyRemove(mapOf("token" to token, "id" to keyId)).let {
|
||||
keyList()
|
||||
}
|
||||
logDogRepository.logi("keyRemove", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "keyRemove: ${e.localizedMessage}")
|
||||
logDogRepository.loge("keyRemove", "", e.toString())
|
||||
@ -247,6 +257,7 @@ class PushDeerViewModel(
|
||||
).let {
|
||||
messageList()
|
||||
}
|
||||
logDogRepository.logi("messagePush", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "messagePush: ${e.localizedMessage}")
|
||||
}
|
||||
@ -261,6 +272,7 @@ class PushDeerViewModel(
|
||||
messageRepository.insert(*(it.messages.toTypedArray()))
|
||||
}
|
||||
}
|
||||
logDogRepository.logi("messageList", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "messageList: ${e.localizedMessage}")
|
||||
}
|
||||
@ -273,6 +285,7 @@ class PushDeerViewModel(
|
||||
pushDeerService.messageRemove(token, messageId).let {
|
||||
messageList()
|
||||
}
|
||||
logDogRepository.logi("messageRemove", "normally", "nothing happened")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "keyRemove: ${e.localizedMessage}")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user