diff --git a/imitate/build.gradle b/imitate/build.gradle index abccd5b6..e195b766 100644 --- a/imitate/build.gradle +++ b/imitate/build.gradle @@ -186,10 +186,10 @@ dependencies { // robolectric implementation group: 'commons-io', name: 'commons-io', version: '20030203.000550' - implementation project(path: ':subs:game') +// implementation project(path: ':subs:game') implementation project(path: ':subs:gif-revert') implementation project(path: ':subs:ai') - implementation project(path: ':subs:cpp_native') +// implementation project(path: ':subs:cpp_native') implementation project(path: ':subs:compose') implementation 'com.jaredrummler:simple-mvp:1.0.2' diff --git a/imitate/src/main/java/com/engineer/imitate/KotlinRootActivity.kt b/imitate/src/main/java/com/engineer/imitate/KotlinRootActivity.kt index fedac298..80a03de2 100644 --- a/imitate/src/main/java/com/engineer/imitate/KotlinRootActivity.kt +++ b/imitate/src/main/java/com/engineer/imitate/KotlinRootActivity.kt @@ -30,13 +30,11 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.launcher.ARouter -import com.engineer.compose.ui.MainComposeActivity import com.engineer.imitate.databinding.ActivityKotlinRootBinding import com.engineer.imitate.model.FragmentItem import com.engineer.imitate.room.SchoolDatabase import com.engineer.imitate.ui.activity.ReverseGifActivity import com.engineer.imitate.util.* -import com.example.cpp_native.app.NativeRoot import com.gyf.immersionbar.ImmersionBar import com.scwang.smart.refresh.footer.ClassicsFooter import com.scwang.smart.refresh.header.BezierRadarHeader @@ -82,8 +80,8 @@ class KotlinRootActivity : AppCompatActivity() { // autoStartPage() - NativeRoot.init() - NativeRoot.test() +// NativeRoot.init() +// NativeRoot.test() val patchViewModel = ViewModelProvider(this)[PatchViewModel::class.java] patchViewModel.copyFile() diff --git a/imitate/src/main/java/com/engineer/imitate/ui/fragments/EntranceFragment.kt b/imitate/src/main/java/com/engineer/imitate/ui/fragments/EntranceFragment.kt index c6efad5b..e6d9f571 100644 --- a/imitate/src/main/java/com/engineer/imitate/ui/fragments/EntranceFragment.kt +++ b/imitate/src/main/java/com/engineer/imitate/ui/fragments/EntranceFragment.kt @@ -21,7 +21,6 @@ import com.alibaba.android.arouter.facade.annotation.Route import com.andrefrsousa.superbottomsheet.SuperBottomSheetFragment import com.bumptech.glide.Glide import com.engineer.ai.DigitalClassificationActivity -import com.engineer.android.game.ui.GameRootActivity import com.engineer.imitate.R import com.engineer.imitate.databinding.FragmentEntranceBinding import com.engineer.imitate.ui.activity.CLActivity @@ -166,7 +165,7 @@ class EntranceFragment : Fragment() { } viewBinding.game.setOnClickListener { - startActivity(Intent(context, GameRootActivity::class.java)) +// startActivity(Intent(context, GameRootActivity::class.java)) } viewBinding.shell.setOnClickListener { startActivity(Intent(context, RunShellActivity::class.java)) } diff --git a/imitate/src/main/java/com/engineer/imitate/util/PatchPlayground.kt b/imitate/src/main/java/com/engineer/imitate/util/PatchPlayground.kt index 675d0c2d..8720c760 100644 --- a/imitate/src/main/java/com/engineer/imitate/util/PatchPlayground.kt +++ b/imitate/src/main/java/com/engineer/imitate/util/PatchPlayground.kt @@ -5,7 +5,6 @@ import android.content.Context import android.util.Log import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.viewModelScope -import com.example.cpp_native.internal.PatchUtil import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -78,7 +77,7 @@ suspend fun mergeFile(context: Context): Boolean { val oldFile = baseDir + "lastest.txt" val patchFile = baseDir + "diff.patch" withContext(Dispatchers.IO) { - PatchUtil.patchAPK(oldFile, result, patchFile) +// PatchUtil.patchAPK(oldFile, result, patchFile) } val mergeResult = FileUtils.fileRead(result) diff --git a/subs/compose/src/main/java/com/engineer/compose/ui/ChatActivity.kt b/subs/compose/src/main/java/com/engineer/compose/ui/ChatActivity.kt index dadadf66..611c7022 100644 --- a/subs/compose/src/main/java/com/engineer/compose/ui/ChatActivity.kt +++ b/subs/compose/src/main/java/com/engineer/compose/ui/ChatActivity.kt @@ -40,6 +40,7 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.viewmodel.compose.viewModel import com.engineer.compose.R import com.engineer.compose.ui.preview.ChatMessageItemPre @@ -79,6 +80,13 @@ fun ChatScreen( val msg by viewModel.messageList.observeAsState() val temp = provideTestChat() val kk by viewModel.kkk.observeAsState("11") + + viewModel.messageList.observe(LocalLifecycleOwner.current) { + if (it.size > 1) { + Log.e("ChatListPage", "list = ${it[1].text}") + } + } + Column(modifier = Modifier.fillMaxSize()) { Text(text = kk, modifier = Modifier.size(1.dp)) // 消息列表 @@ -150,6 +158,7 @@ fun MessageList(messages: ArrayList?, modifier: Modifier) { @Preview @Composable fun ChatMessageItem(@PreviewParameter(ChatMessageItemPre::class, 2) message: ChatMessage) { + Log.d("TAG_TAG", message.text) Row( modifier = Modifier .fillMaxWidth() diff --git a/subs/compose/src/main/java/com/engineer/compose/viewmodel/ChatViewModel.kt b/subs/compose/src/main/java/com/engineer/compose/viewmodel/ChatViewModel.kt index 51e2b948..d77cc1e8 100644 --- a/subs/compose/src/main/java/com/engineer/compose/viewmodel/ChatViewModel.kt +++ b/subs/compose/src/main/java/com/engineer/compose/viewmodel/ChatViewModel.kt @@ -47,34 +47,44 @@ class ChatViewModel : ViewModel() { private fun mockRequestResult() { val mockResponse = - "天空呈现蓝色的原因主要与光的散射有关。当太阳光进入大气层后,大气中的气体分子和悬浮微粒会对阳光进行散射。散射的强度与光的波长有关,波长较短的紫光散射强度最大,其次是蓝光,而波长较长的红光和黄光的散射强度较弱。\n" + - "\n" + - "由于蓝光在散射过程中受到的散射强度较大,因此更容易向四面八方散射,这使得我们看到的天空呈现出蓝色。同时,由于人眼对紫光并不敏感,因此即使紫光散射强度最大,我们看到的天空也不会是紫色,而是蓝色。\n" + - "\n" + - "此外,天空的颜色也会随着时间和地点的变化而有所不同。在日出和日落时,由于阳光需要穿过更厚的大气层,散射效果更加显著,天空可能会呈现出橙色或红色。而在晴朗的天气下,由于大气中尘埃和水滴较少,散射作用相对较弱,天空则会呈现出深蓝色。\n" + - "\n" + - "总之,天空之所以是蓝色的,主要是由于大气对阳光中蓝光的强烈散射作用所致。".toCharArray() - val sb = StringBuilder() - - Thread { - for (c in mockResponse) { - val history = _messageList.value ?: ArrayList() - val lastMsg = history.last() - sb.append(c) - kkk.postValue(sb.toString()) - if (lastMsg.sender == "Bot") { - val newMsg = ChatMessage("Bot", sb.toString(), false) - history[history.size - 1] = newMsg - } else { - val newMsg = ChatMessage("Bot", sb.toString(), false) - history.add(newMsg) - } - Log.d(TAG, "history $history") + "天空呈现蓝色的原因主要与光的散射有关。当太阳光进入大气层后,大气中的气体分子和悬浮微粒会对阳光进行散射".toCharArray() + val sb = StringBuffer() - _messageList.postValue(history) + val subThread = true + if (subThread) { + Thread { + sendData(sb, mockResponse, subThread) + }.start() + } else { + sendData(sb, mockResponse, subThread) + } + +// + + } + private fun sendData(sb: StringBuffer, mockResponse: CharArray, subThread: Boolean) { + + for (c in mockResponse) { + val history = _messageList.value ?: ArrayList() + val lastMsg = history.last() + sb.append(c) + kkk.postValue(sb.toString()) + if (lastMsg.sender == "Bot") { + val newMsg = ChatMessage("Bot", sb.toString(), false) + history[history.size - 1] = newMsg + } else { + val newMsg = ChatMessage("Bot", sb.toString(), false) + history.add(newMsg) + } + Log.d(TAG, "history $history") + + if (subThread) { + _messageList.postValue(history) Thread.sleep(10) + } else { + _messageList.value = history } - }.start() + } } } \ No newline at end of file