From aa3ba1d41f91ce5046290547d9cc6c6a204b3266 Mon Sep 17 00:00:00 2001 From: LeGend-wLw <874644990@qq.com> Date: Sun, 4 Feb 2024 23:48:58 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=E7=A7=BB=E9=99=A4ChannelUtils=E6=9C=89?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/lizongying/mytv/Utils.kt | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/app/src/main/java/com/lizongying/mytv/Utils.kt b/app/src/main/java/com/lizongying/mytv/Utils.kt index 8f56a45..d1c53a0 100644 --- a/app/src/main/java/com/lizongying/mytv/Utils.kt +++ b/app/src/main/java/com/lizongying/mytv/Utils.kt @@ -1,12 +1,9 @@ package com.lizongying.mytv -import android.content.Context import android.content.res.Resources import android.util.TypedValue -import java.io.File import java.text.SimpleDateFormat import java.util.* -import java.io.IOException object Utils { fun getDateFormat(format: String): String { @@ -28,49 +25,4 @@ object Utils { TypedValue.COMPLEX_UNIT_DIP, dp.toFloat(), Resources.getSystem().displayMetrics ).toInt() } - - /** - * 获取可读写的目录 - * - * @param context 应用环境信息 - * - * @return 可读写的目录 - * - */ - fun getAppDirectory(context: Context): File { - return context.filesDir - } - - /** - * 更新channels.json - * - * @param context 应用环境信息 - * - * @return 无 - * - * @throws IOException 网络请求失败 - */ - fun updateChannel(context: Context) { - val client = okhttp3.OkHttpClient() - val request = okhttp3.Request.Builder().url(getServerUrl(context)).build() - client.newCall(request).execute().use { response -> - if (!response.isSuccessful) throw IOException("Unexpected code $response") - val body = response.body() - //覆盖channels.json - val file = File(getAppDirectory(context), "channels.json") - if (!file.exists()) { - file.createNewFile() - } - file.writeText(body!!.string()) - } - } - - /** - * 从res/values/server.xml获取服务器地址 - * @param context 应用环境信息 - * @return 服务器地址 - */ - fun getServerUrl(context: Context): String { - return context.resources.getString(R.string.server_url) - } } \ No newline at end of file