模组排行更新

This commit is contained in:
coldmint 2022-10-12 23:59:16 +08:00
parent 575b6c4a1f
commit 0b4d6c9738
15 changed files with 119 additions and 14 deletions

Binary file not shown.

View File

@ -147,10 +147,14 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
* @param data Data
*/
fun ifNeedShowUpdate(data: AppUpdateData.Data) {
val key = "应用更新"
if (ServerConfiguration.isTestServer()){
Log.w(key, "当前为本地测试服务器,已禁用更新检查。")
return
}
val executorService = Executors.newSingleThreadExecutor()
executorService.submit {
//检查更新
val key = "应用更新"
val packageInfo: PackageInfo = packageManager.getPackageInfo(packageName, 0)
val checkBetaUpdate =
AppSettings.getValue(AppSettings.Setting.CheckBetaUpdate, false)

View File

@ -1,8 +1,12 @@
package com.coldmint.rust.pro.fragments
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.widget.PopupMenu
import android.widget.Toast
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -15,6 +19,7 @@ import com.coldmint.rust.pro.WebModInfoActivity
import com.coldmint.rust.pro.adapters.WebModAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentRankingBinding
import com.google.android.material.chip.Chip
import me.zhanghai.android.fastscroll.FastScrollerBuilder
/**
@ -27,6 +32,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
val linearLayoutManager by lazy {
LinearLayoutManager(requireContext())
}
private var sortMode: WebMod.SortMode = WebMod.SortMode.Download_Number
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.recyclerView.layoutManager = linearLayoutManager
@ -48,13 +54,37 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
loadMods()
viewBinding.swipeRefreshLayout.isRefreshing = false
}
viewBinding.downloadChip.setOnCheckedChangeListener { buttonView, isChecked ->
if (isChecked) {
sortMode = WebMod.SortMode.Download_Number
loadMods()
}
}
viewBinding.unitChip.setOnCheckedChangeListener { buttonView, isChecked ->
if (isChecked) {
sortMode = WebMod.SortMode.Unit_Number
loadMods()
}
}
viewBinding.coinChip.setOnCheckedChangeListener { buttonView, isChecked ->
if (isChecked) {
sortMode = WebMod.SortMode.Coin_Number
loadMods()
}
}
viewBinding.updateChip.setOnCheckedChangeListener { buttonView, isChecked ->
if (isChecked) {
sortMode = WebMod.SortMode.Update_Number
loadMods()
}
}
viewBinding.downloadChip.isChecked = true
}
override fun onResume() {
loadMods()
super.onResume()
}
// override fun onResume() {
// loadMods()
// super.onResume()
// }
fun loadMods() {
WebMod.instance.list(object : ApiCallBack<WebModListData> {
@ -65,6 +95,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
viewBinding.progressBar.isVisible = false
viewBinding.textview.isVisible = false
viewBinding.swipeRefreshLayout.isVisible = true
// Toast.makeText(requireContext(),"加载"+list.size,Toast.LENGTH_SHORT).show()
val adapter = createAdapter(list)
viewBinding.recyclerView.adapter = adapter
linearLayoutManager.scrollToPositionWithOffset(
@ -85,7 +116,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
showInfoToView(R.string.network_error)
}
}, sortMode = WebMod.SortMode.Download_Number, limit = "100")
}, sortMode = sortMode, limit = "100")
}
@ -99,6 +130,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
webModAdapter = WebModAdapter(context = requireContext(), dataList = dataList)
webModAdapter!!
} else {
webModAdapter!!.setNewDataList(dataList)
webModAdapter!!
}
adapter.setItemEvent { i, webModItemBinding, viewHolder, data ->

View File

@ -36,7 +36,7 @@ class RecommendedFragment : BaseFragment<FragmentRecommendedBinding>() {
/**
* 加载最近更新
*/
fun loaList() {
fun loadList() {
//如果进度条可见那么为首次加载
val isFirst = viewBinding.progressBar.isVisible
viewBinding.latestReleaseProgressIndicator.isVisible = true
@ -218,7 +218,7 @@ class RecommendedFragment : BaseFragment<FragmentRecommendedBinding>() {
override fun onResume() {
super.onResume()
loaList()
loadList()
loadSoleRecommended()
loadBannerData()
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
@ -27,10 +28,63 @@
android:layout_marginTop="8dp"
android:visibility="gone">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:orientation="vertical">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:singleLine="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/downloadChip"
style="@style/Widget.Material3.Chip.Suggestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/download_num"
android:textEditSuggestionItemLayout="@array/report_entries" />
<com.google.android.material.chip.Chip
android:id="@+id/coinChip"
style="@style/Widget.Material3.Chip.Suggestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/coin_num"
android:textEditSuggestionItemLayout="@array/report_entries" />
<com.google.android.material.chip.Chip
android:id="@+id/unitChip"
style="@style/Widget.Material3.Chip.Suggestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/unit_number"
android:textEditSuggestionItemLayout="@array/report_entries" />
<com.google.android.material.chip.Chip
android:id="@+id/updateChip"
style="@style/Widget.Material3.Chip.Suggestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/update_number"
android:textEditSuggestionItemLayout="@array/report_entries" />
</com.google.android.material.chip.ChipGroup>
</HorizontalScrollView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View File

@ -936,5 +936,9 @@
<string name="setting_source_file_type" translatable="false">sourceFileType</string>
<string name="setting_source_file_type_title">源文件类型</string>
<string name="setting_source_file_type_describe">配置源文件类型,符合配置格式的文件将以文本编辑形式打开。以逗号分割不同格式。</string>
<string name="download_num">下载量</string>
<string name="coin_num">投币数</string>
<string name="unit_number">单位数</string>
<string name="update_number">更新次数</string>
</resources>

View File

@ -24,7 +24,7 @@ object ServerConfiguration {
//本地:http://10.0.2.2/
//电脑查 ip [ipconfig]
private const val testIp = "http://10.0.2.2/rust-assistant-backstage/"
private const val testIp = "http://10.0.2.2/"
const val defaultIp = "http://39.105.229.249/"
var website = defaultIp
const val Success_Code = 0
@ -32,6 +32,15 @@ object ServerConfiguration {
const val ForeverTime = "forever"
/**
* 是否为本地测试服
* @return Boolean
*/
fun isTestServer(): Boolean {
return website == testIp
}
/**
* 将整数转换为字符串加上""
* @param num Int

View File

@ -18,7 +18,9 @@ class WebMod private constructor() {
enum class SortMode(private val value: String) {
Latest_Time("latestTime"), Download_Number("downloadNumber");
Latest_Time("latestTime"), Download_Number("downloadNumber"), Coin_Number("coinNumber"), Unit_Number(
"unitNumber"
),Update_Number("updateNumber");
/**
* 获取枚举代表的值