Update UpdateManager.kt

This commit is contained in:
MNCHL 2023-12-25 19:42:44 +08:00 committed by GitHub
parent ed8e7efea9
commit 0bdb674d80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,6 @@ import android.util.Log
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import okhttp3.ResponseBody
import org.json.JSONObject import org.json.JSONObject
class UpdateManager(private val context: Context) { class UpdateManager(private val context: Context) {
@ -30,8 +29,9 @@ class UpdateManager(private val context: Context) {
.build() .build()
val response: Response = client.newCall(request).execute() val response: Response = client.newCall(request).execute()
val responseBody: ResponseBody? = response.body()
val responseCode: Int = response.code() val responseBody = response.body()
val responseCode = response.code()
if (responseBody != null) { if (responseBody != null) {
if (responseCode == 200) { if (responseCode == 200) {
@ -46,7 +46,7 @@ class UpdateManager(private val context: Context) {
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "Error checking for updates: ${e.message}") Log.e(TAG, "Error checking for updates: ${e.message}")
} }
return "" return "" // 处理失败的情况,返回空字符串
} }
override fun onPostExecute(result: String) { override fun onPostExecute(result: String) {