last commit

This commit is contained in:
shipovnikaaa 2025-02-20 15:59:22 +03:00
parent e2236c53dc
commit 5b1b590358
6 changed files with 164 additions and 55 deletions

View File

@ -0,0 +1,82 @@
kotlin version: 2.0.21
error message: Daemon compilation failed: null
java.lang.Exception
at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:69)
at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:65)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemon(GradleKotlinCompilerWork.kt:240)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemonOrFallbackImpl(GradleKotlinCompilerWork.kt:159)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:111)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction.execute(GradleCompilerRunnerWithWorkers.kt:76)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:209)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$0(DefaultWorkerExecutor.java:174)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:195)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:128)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:170)
at org.gradle.internal.Factories$1.create(Factories.java:31)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:267)
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:131)
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:136)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:165)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:134)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.nio.file.DirectoryNotEmptyException: C:\Users\User\AppData\Local\Temp\kotlin-backups17769967979094468495
at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
at java.base/sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source)
at java.base/java.nio.file.Files.delete(Unknown Source)
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction$cleanupStash$2$1$1.invoke(CompilationTransaction.kt:244)
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction$cleanupStash$2$1$1.invoke(CompilationTransaction.kt:244)
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.cleanupStash$lambda$11$lambda$10$lambda$9(CompilationTransaction.kt:244)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
at java.base/java.util.ArrayList.forEach(Unknown Source)
at java.base/java.util.stream.SortedOps$RefSortingSink.end(Unknown Source)
at java.base/java.util.stream.Sink$ChainedReference.end(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.cleanupStash(CompilationTransaction.kt:244)
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.close(CompilationTransaction.kt:254)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.tryCompileIncrementally(IncrementalCompilerRunner.kt:747)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:120)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:675)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:92)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1660)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
... 3 more

View File

@ -25,11 +25,13 @@ interface LoginApi {
@PUT("ban")
suspend fun ban(
@Header("Authorization") authHeader: String,
@Query("login") login: String
): Response<ResponseBody>
@PUT("unban")
suspend fun unban(
@Header("Authorization") authHeader: String,
@Query("login") login: String
): Response<ResponseBody>

View File

@ -68,12 +68,8 @@ class AdminFragment : Fragment(R.layout.fragment_admin) {
binding.ban.text = "заблокировать"
}
binding.ban.setOnClickListener {
viewModel.banPerson(username, state.isBanned, loginPerson){
if (state.isBanned){
binding.ban.text = "разблокировать"
}else{
binding.ban.text = "заблокировать"
}
viewModel.banPerson(username, password, state.isBanned, loginPerson){
login(username, password, loginPerson)
}
}
binding.fullnameAdmin.text = state.fullName
@ -85,6 +81,15 @@ class AdminFragment : Fragment(R.layout.fragment_admin) {
}
}
// private fun ban(username: String, ban:Boolean, login: String){
// viewModel.banPerson(username, ban, login)
// if (ban){
// binding.ban.text = "разблокировать"
// }else{
// binding.ban.text = "заблокировать"
// }
// }
private fun setError(error: String?) {

View File

@ -83,12 +83,24 @@ class AdminViewModel @Inject constructor(
}
}
fun banPerson(username: String, ban : Boolean, loginPerson: String, onSuccess: () -> Unit) {
fun banPerson(username: String, password: String, ban : Boolean, loginPerson: String, onSuccess: () -> Unit) {
viewModelScope.launch {
try {
// println(loginPerson)
val authHeader = createAuthHeader(username = username, password)
when(ban){
false -> loginApi.ban(loginPerson)
true -> loginApi.unban(loginPerson)
false -> loginApi.ban(authHeader, loginPerson)
true -> loginApi.unban(authHeader, loginPerson)
}
// val authHeader = createAuthHeader(username = username, password)
val info = loginApi.info(authHeader, loginPerson)
val personInfo = info.body()?.let { responseBody ->
GsonBuilder().create().fromJson(responseBody.string(), PersonInfoDto::class.java)
}
if (personInfo != null) {
_state.update {
AdminMainState(isBanned = personInfo.isBanned)
}
}
onSuccess()
} catch (httpException: HttpException) {

View File

@ -32,51 +32,6 @@ class MainFragment: Fragment(R.layout.fragment_main) {
super.onViewCreated(view, savedInstanceState)
_binding = FragmentMainBinding.bind(view)
val recyclerView = binding.recyclerView
val examList: MutableList<HistoryItem> = ArrayList()
examList.add(
HistoryItem(
"Math Exam",
"May 23, 2015",
"Best of Luck",
R.drawable.clock,
R.drawable.card
)
)
examList.add(
HistoryItem(
"Science Exam",
"June 10, 2015",
"Do Well",
R.drawable.clock,
R.drawable.card
)
)
examList.add(
HistoryItem(
"History Exam",
"July 15, 2015",
"All the Best",
R.drawable.clock,
R.drawable.card
)
)
examList.add(
HistoryItem(
"English Exam",
"August 1, 2015",
"Stay Confident",
R.drawable.clock,
R.drawable.card
)
)
recyclerView.layoutManager = LinearLayoutManager(requireActivity())
val adapter = adapterScrollView(examList)
recyclerView.adapter = adapter
val username = findNavController().currentBackStackEntry?.toRoute<MainDestination>()?.username
username?.let { user ->
val password = findNavController().currentBackStackEntry?.toRoute<MainDestination>()?.password
@ -105,10 +60,56 @@ class MainFragment: Fragment(R.layout.fragment_main) {
private fun subscribe() {
viewModel.state.collectWhenStarted(this) { state ->
val recyclerView = binding.recyclerView
val examList: MutableList<HistoryItem> = ArrayList()
examList.add(
HistoryItem(
"Math Exam",
"May 23, 2015",
"Best of Luck",
R.drawable.clock,
R.drawable.card
)
)
examList.add(
HistoryItem(
"Science Exam",
"June 10, 2015",
"Do Well",
R.drawable.clock,
R.drawable.card
)
)
examList.add(
HistoryItem(
"History Exam",
"July 15, 2015",
"All the Best",
R.drawable.clock,
R.drawable.card
)
)
examList.add(
HistoryItem(
"English Exam",
"August 1, 2015",
"Stay Confident",
R.drawable.clock,
R.drawable.card
)
)
if (state.photo.isNotEmpty()) {
picasso.load(state.photo).into(binding.photo)
}
println(state.isBanned)
if (state.isBanned){
binding.scan.visibility = View.GONE
}
else{
binding.scan.visibility = View.VISIBLE
}
if (state.role == "ADMIN"){
@ -118,12 +119,18 @@ class MainFragment: Fragment(R.layout.fragment_main) {
binding.position.text = state.position
binding.lastEntry.text = state.lastVisit
setError(state.error)
recyclerView.layoutManager = LinearLayoutManager(requireActivity())
val adapter = adapterScrollView(examList)
recyclerView.adapter = adapter
}
}
private fun setError(error: String?) {
val showError = error != null
val views = listOf(binding.fullname, binding.position, binding.lastEntry, binding.photo, binding.scan, binding.logout)
val views = listOf(binding.fullname, binding.position, binding.lastEntry, binding.photo, binding.logout)
views.forEach { it.visibility = if (showError) View.GONE else View.VISIBLE}
binding.error.visibility = if (showError) View.VISIBLE else View.GONE
binding.error.text = error ?: ""

View File

@ -45,6 +45,7 @@ class MainViewModel @Inject constructor(
val personInfo = info.body()?.let { responseBody ->
GsonBuilder().create().fromJson(responseBody.string(), PersonInfoDto::class.java)
}
println(personInfo)
if (personInfo != null) {
_state.update {
MainState(