今天修改了个人项目

package com.example.activity.student

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.EditText
import androidx.annotation.RequiresApi
import com.example.R
import com.example.activity.StudentActivity
import com.example.network.ServiceCreator
import com.example.pojo.User
import com.example.pojo.Weekgoal
import com.example.service.WeekgoalService
import com.example.utils.DateTimeUtils
import com.example.utils.InputFilterUtils
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response


class isSuccessActivity : AppCompatActivity() {
    @SuppressLint("MissingInflatedId")
    @RequiresApi(Build.VERSION_CODES.O)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_is_success)
        //      获取上一个页面页面相关信息
        val receiveUser=intent.getParcelableExtra<User>("suser")
        val usname= receiveUser?.username

        val issuccessEt=findViewById<EditText>(R.id.issuccess_et)
        val nextweek=findViewById<EditText>(R.id.issuccess_nextweek)
        InputFilterUtils.setRangeInputFilter(issuccessEt, 0.0, 100.0)
        val sure=findViewById<Button>(R.id.issuccess_sure)

        sure.setOnClickListener {
            val weekgoal= usname?.let { it1 ->
                issuccessEt.text.toString().toIntOrNull()?.let { it2 ->
                    Weekgoal(
                        it1,"", it2,nextweek.text.toString(),
                        DateTimeUtils.getCurrentDateTime())
                }
            }

            val weekgoalService=ServiceCreator.create<WeekgoalService>()
            if (weekgoal != null) {
                weekgoalService.addweek(weekgoal).enqueue(object :Callback<Void>{
                    override fun onResponse(call: Call<Void>, response: Response<Void>) {
                        if (response.isSuccessful){
                            Log.e("MainActivity", "数据已成功添加到后端数据库")
                        }else{
                            Log.e("MainActivity", "添加数据时出错:${response.code()}")
                        }
                        val intent = Intent(this@isSuccessActivity, StudentActivity::class.java)
                        intent.putExtra("user",receiveUser)
                        startActivity(intent)
                    }

                    override fun onFailure(call: Call<Void>, t: Throwable) {
                        Log.e("Tag","失败")
                    }

                })
            }
        }
    }
}

 

posted on 2024-04-07 23:30  许七安gyg  阅读(2)  评论(0编辑  收藏  举报
$(document).ready(function() { // 禁止右键 $(document).bind("contextmenu", function(){return false;}); // 禁止选择 $(document).bind("selectstart", function(){return false;}); // 禁止Ctrl+C 和Ctrl+A $(document).keydown(function(event) { if ((event.ctrlKey&&event.which==67) || (event.ctrlKey&&event.which==86)) { //alert("对不起,版权所有,禁止复制"); return false; } }); });