Commit ae8e4fcb authored by sheteng's avatar sheteng

2.0 开发 5

parent 00243d6d
......@@ -50,10 +50,10 @@ object GameDownLoadManger {
filename
)
// if (file.exists()) {
// activity.context?.let { DownloadUtils.install(file.absolutePath, it) }
// return
// }
if (file.exists()) {
activity.context?.let { DownloadUtils.install(file.absolutePath, it) }
return
}
downloadManager =
activity.context?.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
val request =
......@@ -89,7 +89,7 @@ object GameDownLoadManger {
var progress = 0F
while (progress < 100F) {
progress = getDownloadProgress(downloadId)
delay(2000)
delay(1000)
}
withContext(Dispatchers.Main) {
gameDownloadListener?.onFinish(downloadMap.get(downloadId))
......
......@@ -10,7 +10,7 @@ data class GameInfo(
val announcementList: List<Announcement>,
val anotherName: String,
val boosterPackageName: String?,
val boosterServer: String,
val boosterServer: String?,
val createdDate: String,
val dnsServer: String,
val downloadType : Int,
......@@ -21,7 +21,7 @@ data class GameInfo(
val imgs: String,
val introduction: String,
val packageName: String,
val proxyRules: String,
val proxyRules: String?,
val score: String,
val size: String,
val type: Int,
......
......@@ -42,7 +42,7 @@ class GameDownloadDialog(
val appSize = findViewById<TextView>(R.id.app_size)
appSize.setText("文件大小:${gameInfo.size}")
val appVersion = findViewById<TextView>(R.id.app_version)
appVersion.setText("版本号:${gameInfo.id}")
appVersion.setText("版本号:${gameInfo.version}")
val btnLeft = findViewById<TextView>(R.id.btn_left)
btnLeft.setOnClickListener {
dismiss<GameDownloadDialog>()
......
......@@ -101,7 +101,7 @@ class GameListFragment : XPageFragment() {
val game_notice_1_1 = itemView.findViewById<TextView>(R.id.game_notice_1_1)
val game_notice_1_2 = itemView.findViewById<TextView>(R.id.game_notice_1_2)
val game_notice_1_3 = itemView.findViewById<TextView>(R.id.game_notice_1_3)
val announcement1 = itemData.announcementList.stream().filter { it.type == 1 }
val announcement1 = itemData.announcementList.stream().filter { it.addrType == 3 }
.collect(Collectors.toList())
if (announcement1 == null || announcement1.size == 0) {
......@@ -132,7 +132,7 @@ class GameListFragment : XPageFragment() {
}
}
val announcement2 = itemData.announcementList.stream().filter { it.type == 2 }
val announcement2 = itemData.announcementList.stream().filter { it.addrType == 4 }
.collect(Collectors.toList())
if (announcement2 == null || announcement2.size == 0) {
......@@ -149,7 +149,7 @@ class GameListFragment : XPageFragment() {
.load(itemData.icon)
.into(game_img)
game_name.setText(itemData.gameName)
println(itemData)
if (itemData.type == 1) {
is_free.visibility = View.VISIBLE
} else {
......@@ -283,10 +283,15 @@ class GameListFragment : XPageFragment() {
gameInfo: GameInfo?,
downloadInfo: GameDownLoadManger.DownloadInfo
) {
if (gameInfo != null) {
if (gameInfo != null && dataList.contains(gameInfo)) {
val lastInfo = downloadInfoMap.get(gameInfo.id)
downloadInfo.speed =
downloadInfo.download_so_far - if (lastInfo == null) 0 else lastInfo.download_so_far
(downloadInfo.download_so_far - if (lastInfo == null) 0 else lastInfo.download_so_far)
if (lastInfo != null) {
if (downloadInfo.speed == 0L && lastInfo.speed != 0L){
downloadInfo.speed = lastInfo.speed
}
}
downloadInfoMap.put(gameInfo.id, downloadInfo)
_binding.gameList.adapter?.notifyItemChanged(
dataList.indexOf(
......@@ -311,7 +316,7 @@ class GameListFragment : XPageFragment() {
} else if (ann.type == 1) {
val params = Bundle()
params.putInt(Constants.GAME_ID, ann.gameId)
openPage(NewsFragment::class.java)
openPage(NewsFragment::class.java,params)
}
}
......
......@@ -10,6 +10,7 @@ import android.view.animation.Animation
import android.view.animation.LinearInterpolator
import android.view.animation.RotateAnimation
import androidx.lifecycle.ViewModelProvider
import com.bumptech.glide.Glide
import com.ccwangluo.accelerator.R
import com.ccwangluo.accelerator.databinding.FragmentQuickBinding
import com.ccwangluo.accelerator.model.NetState
......@@ -159,6 +160,12 @@ class AcceleratorFragment : XPageFragment() {
}
binding.radiusTv.visibility = if (SysUtils.getChannel() == 3) View.GONE else View.VISIBLE
binding.accGameName.setText(AcceleratorUtils.game!!.gameName)
AcceleratorUtils.game?.icon?.let {
Glide.with(this)
.load(it)
.into(binding.gameBg)
}
}
override fun initListeners() {
......
......@@ -41,6 +41,7 @@ class MineFragment : XPageFragment() {
createAgentWeb(this, binding.mineWebview, weburl)
agentWeb?.getJsInterfaceHolder()
?.addJavaObject("android", AndroidInterface(this, agentWeb!!))
refreshLogin()
}
override fun initListeners() {
......@@ -78,9 +79,7 @@ class MineFragment : XPageFragment() {
override fun onHiddenChanged(hidden: Boolean) {
super.onHiddenChanged(hidden)
if (!hidden) {
refreshLogin()
}
refreshLogin()
}
private fun refreshLogin() {
......
......@@ -157,7 +157,7 @@ class NewsFragment : XPageFragment() {
dataList.addAll(it)
binding.gameNewsList.adapter?.notifyDataSetChanged()
})
adapter = NewsCollectionAdapter(this, titles)
adapter = NewsCollectionAdapter(this, titles,gameId)
binding.viewPager.adapter = adapter
TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
tab.setCustomView(R.layout.item_tab)
......
......@@ -7,6 +7,7 @@ import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.fragment.app.Fragment
import com.ccwangluo.accelerator.databinding.FragmentMineBinding
import com.ccwangluo.accelerator.databinding.FragmentNoticeBinding
import com.ccwangluo.accelerator.ui.web.AndroidInterface
import com.ccwangluo.accelerator.manager.LoginUtils
import com.ccwangluo.accelerator.utils.SysUtils
......@@ -18,7 +19,7 @@ import com.xuexiang.xpage.utils.TitleBar
class NoticeFragment : XPageFragment() {
private var _binding: FragmentMineBinding? = null
private var _binding: FragmentNoticeBinding? = null
private val binding get() = _binding!!
private var agentWeb: AgentWeb? = null
......@@ -28,7 +29,7 @@ class NoticeFragment : XPageFragment() {
}
override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View {
_binding = FragmentMineBinding.inflate(inflater!!, container, false)
_binding = FragmentNoticeBinding.inflate(inflater!!, container, false)
return binding.root
}
......
......@@ -7,6 +7,8 @@ import androidx.lifecycle.lifecycleScope
import com.ccwangluo.accelerator.databinding.FragmentSplashBinding
import com.ccwangluo.accelerator.ui.BottomNavigationFragment
import com.ccwangluo.accelerator.utils.AcceleratorUtils
import com.ccwangluo.accelerator.utils.SysUtils
import com.ccwangluo.accelerator.utils.http.HttpGo
import com.tencent.map.geolocation.TencentLocationManager
import com.xuexiang.xpage.annotation.Page
import com.xuexiang.xpage.base.XPageFragment
......@@ -31,6 +33,9 @@ class SplashFragment : XPageFragment() {
override fun initViews() {
TencentLocationManager.getInstance(context)
lifecycleScope.launch(Dispatchers.IO) {
val map = mutableMapOf<String, Any>()
map.put("packageNameList", SysUtils.getAllAppInfo(context!!))
HttpGo.postSync<String>("/api/game/addHotGame",map)
delay(1000)
withContext(Dispatchers.Main) {
openPage(BottomNavigationFragment::class.java, false)
......
......@@ -4,7 +4,7 @@ import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
class NewsCollectionAdapter(fragment: Fragment, val titles: Array<String>) :
class NewsCollectionAdapter(fragment: Fragment, val titles: Array<String>,val gameId: Int) :
FragmentStateAdapter(fragment) {
var list = mutableListOf<NewsObjectFragment>()
......@@ -14,6 +14,7 @@ class NewsCollectionAdapter(fragment: Fragment, val titles: Array<String>) :
fragment.arguments = Bundle().apply {
// Our object is just an integer :-P
putInt(ARG_OBJECT, i)
putInt(GAME_ID,gameId)
}
list.add(fragment)
}
......@@ -32,5 +33,6 @@ class NewsCollectionAdapter(fragment: Fragment, val titles: Array<String>) :
companion object {
val ARG_OBJECT = "object"
val GAME_ID = "GAME_ID"
}
}
......@@ -54,6 +54,7 @@ class NewsObjectFragment : XPageFragment() {
private var gameId = 0
override fun initViews() {
gameId = arguments?.getInt(NewsCollectionAdapter.GAME_ID)!!
arguments?.takeIf { it.containsKey(ARG_OBJECT) }?.apply {
position = getInt(ARG_OBJECT).toString()
recycle_view = findViewById(R.id.recycle_view)
......@@ -283,11 +284,8 @@ class NewsObjectFragment : XPageFragment() {
}
fun refresh() {
AcceleratorUtils.game?.let {
gameId = it.id
page = 1
newsViewModel?.freshData(position, it.id, page)
}
newsViewModel?.freshData(position, gameId, page)
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.os.Looper
import android.os.RemoteException
import android.text.TextUtils.split
import androidx.activity.result.ActivityResultLauncher
import androidx.lifecycle.lifecycleScope
import com.ccnet.acc.NetworkAdapter
......@@ -196,12 +197,14 @@ object AcceleratorUtils : TencentLocationListener {
proxyGames.add(it)
}
}
DataStore.proxyRules = game.proxyRules
DataStore.proxyRules = if (game.proxyRules == null) "*" else game.proxyRules
DataStore.dnsServer = game.dnsServer
val serverPort = game.boosterServer.split(":")
DataStore.pingAccHost = serverPort[0]
DataStore.pingAccPort = serverPort[1].toInt()
game.boosterServer?.let {
val serverPort = it.split(":")
DataStore.pingAccHost = serverPort[0]
DataStore.pingAccPort = serverPort[1].toInt()
}
}
profile.individual = proxyGames.joinToString("\n")
profile.route = Acl.BYPASS_LAN
......
......@@ -198,21 +198,21 @@ object SysUtils {
if (TextUtils.isEmpty(localVersion) || TextUtils.isEmpty(remoteVersion)) {
return true
}
val local = localVersion!!.split("\\.")
val remote = remoteVersion!!.split("\\.")
if (local.size != remote.size || local.size == 0) {
val local = localVersion!!.split(".")
val remote = remoteVersion!!.split(".")
if (remote.size == 0 || local.size == 0) {
return true
}
for (i in 0..local.size) {
if (local[i].toInt() < remote[i].toInt()) {
if (remote.size > i && local[i].toInt() < remote[i].toInt()) {
return false
}
}
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
return true
}
......@@ -222,8 +222,8 @@ object SysUtils {
* @param ctx
* @return
*/
fun getAllAppInfo(ctx: Context): ArrayList<String?>? {
val appBeanList: ArrayList<String?> = ArrayList()
fun getAllAppInfo(ctx: Context): List<String> {
val appBeanList = mutableListOf<String>()
val packageManager = ctx.packageManager
val list = packageManager.getInstalledPackages(0)
for (p in list) {
......
......@@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:background="@color/divide_gray"
android:orientation="vertical">
<LinearLayout
......@@ -32,11 +32,13 @@
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh_game"
android:background="@color/divide_gray"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/game_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
......
......@@ -2,6 +2,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<FrameLayout
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#31354B"
android:orientation="horizontal">
<TextView
android:layout_width="36dp"
android:layout_height="25dp"
android:layout_marginLeft="15.5dp"
android:layout_marginTop="32.5dp"
android:layout_weight="1"
android:text="系统消息"
android:textColor="#FFFFFFFF"
android:textSize="18sp" />
</LinearLayout>
<FrameLayout
android:layout_marginTop="0dp"
android:id="@+id/mine_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
\ No newline at end of file
......@@ -110,6 +110,7 @@
android:background="@mipmap/circle_in1" />
<com.xuexiang.xui.widget.imageview.RadiusImageView
android:id="@+id/game_bg"
android:layout_width="190dp"
android:layout_height="190dp"
android:layout_centerInParent="true"
......
......@@ -289,17 +289,18 @@
android:layout_height="wrap_content"
android:text="【最新消息】常见问题解答,更新了~"
android:textColor="#FF36B8F4"
android:maxLength="20"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:textSize="11sp"
/>
<TextView
android:layout_width="22dp"
android:layout_height="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="查看 >"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_marginRight="15dp"
android:textColor="#FF36B8F4"
android:textSize="11sp"
/>
......
......@@ -24,8 +24,7 @@
<item name="colorAccent">@color/colorPrimaryDark</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<!-- <item name="android:background">@mipmap/splash</item>-->
<item name="android:windowBackground">@mipmap/win_bg</item>
<item name="android:windowBackground">@color/divide_gray</item>
<item name="android:windowDisablePreview">true</item>
<!-- <item name="xui_config_splash_app_logo">@mipmap/tt_logo</item>-->
<item name="xpage_actionbar_background">@null</item>
......
......@@ -14,6 +14,7 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
val kotlinVersion = rootProject.extra["kotlinVersion"].toString()
classpath(rootProject.extra["androidPlugin"].toString())
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
......
......@@ -9,8 +9,8 @@ object HttpConfig {
/**
* 主页h5
*/
// val UI_MAIN_URL = "http://10.3.64.200:8080/#"
val UI_MAIN_URL = "https://test-cc-tt-front.orangenet.org.cn/#" //测试
// val UI_MAIN_URL = "http://10.3.64.200:8081/#"
val UI_MAIN_URL = "http://test-cc-tt-front-new.orangenet.org.cn/#" //测试
// val UI_MAIN_URL = "https://cc-tt-front.srccwl.com/#" //生产
//隐私协议地址
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment