修复bug。

This commit is contained in:
Cold-Mint 2023-02-21 19:33:06 +08:00
parent 530c50da2b
commit 7ecddf8976
45 changed files with 132 additions and 63 deletions

View File

@ -31,6 +31,7 @@ import com.coldmint.rust.pro.databean.FunctionInfo
import com.coldmint.rust.pro.databinding.ActivityActivateBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
@ -49,11 +50,11 @@ class ActivateActivity : BaseActivity<ActivityActivateBinding>() {
if (t.code == ServerConfiguration.Success_Code) {
val data = t.data
if (data != null && data.isNotEmpty()) {
val layoutManager = LinearLayoutManager(this@ActivateActivity)
val layoutManager = StableLinearLayoutManager(this@ActivateActivity)
layoutManager.orientation = RecyclerView.HORIZONTAL
viewBinding.recyclerview.layoutManager = layoutManager
viewBinding.couponRecyclerview.layoutManager =
LinearLayoutManager(this@ActivateActivity)
StableLinearLayoutManager(this@ActivateActivity)
val adapter = PlanAdapter(this@ActivateActivity, data)
planAdapter = adapter
adapter.setItemEvent { i, itemPlanBinding, viewHolder, data ->

View File

@ -14,6 +14,7 @@ import androidx.core.view.isVisible
import com.coldmint.rust.pro.adapters.ApplicationListAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivityApplicationListBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import java.util.ArrayList
class ApplicationListActivity : BaseActivity<ActivityApplicationListBinding>() {
@ -130,7 +131,7 @@ class ApplicationListActivity : BaseActivity<ActivityApplicationListBinding>() {
// LinearLayoutManager.VERTICAL
// )
// )
viewBinding.appListView.layoutManager = LinearLayoutManager(this@ApplicationListActivity)
viewBinding.appListView.layoutManager = StableLinearLayoutManager(this@ApplicationListActivity)
}

View File

@ -21,6 +21,7 @@ import com.coldmint.rust.pro.databean.Bookmark
import com.coldmint.rust.pro.databinding.ActivityBookmarkManagerBinding
import com.coldmint.rust.pro.databinding.EditBookmarkBinding
import com.coldmint.rust.pro.dialog.BookmarkDialog
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.io.File
@ -240,7 +241,7 @@ class BookmarkManagerActivity : BaseActivity<ActivityBookmarkManagerBinding>() {
bookmarkManager = BookmarkManager(this@BookmarkManagerActivity)
bookmarkManager.load()
viewBinding.bookmarkList.layoutManager =
LinearLayoutManager(this@BookmarkManagerActivity)
StableLinearLayoutManager(this@BookmarkManagerActivity)
val bookmarks = bookmarkManager.list()
updateView(bookmarks)
viewBinding.fab.setOnClickListener {

View File

@ -15,6 +15,7 @@ import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databean.GuideData
import com.coldmint.rust.pro.databinding.ActivityCreationWizardBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
class CreationWizardActivity : BaseActivity<ActivityCreationWizardBinding>() {
@ -40,7 +41,7 @@ class CreationWizardActivity : BaseActivity<ActivityCreationWizardBinding>() {
return
}
type = temType
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
when (temType) {
"mod" -> {
loadMod()

View File

@ -44,6 +44,7 @@ import com.coldmint.rust.pro.interfaces.BookmarkListener
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.tool.CompletionItemConverter
import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.coldmint.rust.pro.viewmodel.EditStartViewModel
import com.coldmint.rust.pro.viewmodel.EditViewModel
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -457,7 +458,7 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
// * 初始化右侧视图
// */
// fun initEndView() {
// editEndBinding.logView.layoutManager = LinearLayoutManager(this)
// editEndBinding.logView.layoutManager = StableLinearLayoutManager(this)
// }
//当用户切换到其他应用界面时
@ -529,7 +530,7 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
private fun initStartView() {
editStartBinding.fileList.layoutManager = LinearLayoutManager(this)
editStartBinding.fileList.layoutManager = StableLinearLayoutManager(this)
editStartBinding.fab.setOnClickListener {
val popupMenu = GlobalMethod.createPopMenu(editStartBinding.fab)
if (fileAdapter != null) {
@ -1094,7 +1095,7 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
}
}
}
val linearLayoutManager = LinearLayoutManager(this)
val linearLayoutManager = StableLinearLayoutManager(this)
linearLayoutManager.orientation = RecyclerView.HORIZONTAL
viewBinding.recyclerview.isVisible = true
viewBinding.recyclerview.layoutManager = linearLayoutManager

View File

@ -27,6 +27,7 @@ import com.coldmint.rust.core.tool.FileOperator
import com.coldmint.rust.pro.adapters.MapAndMusicAdapter
import com.coldmint.rust.pro.databinding.ActivityEditModInfoBinding
import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import java.io.File
import java.lang.StringBuilder
import java.util.ArrayList
@ -475,7 +476,7 @@ class EditModInfoActivity : BaseActivity<ActivityEditModInfoBinding>() {
}
}
val mapAndMusicAdapter = MapAndMusicAdapter(this, files, true)
val layoutManager = LinearLayoutManager(this@EditModInfoActivity)
val layoutManager = StableLinearLayoutManager(this@EditModInfoActivity)
mapAndMusicAdapter.setItemChangeEvent { changeType, i, file, i2 ->
viewBinding.musicPathView.text =
String.format(getString(R.string.filenum), i2)
@ -558,7 +559,7 @@ class EditModInfoActivity : BaseActivity<ActivityEditModInfoBinding>() {
}
}
val mapAndMapAdapter = MapAndMusicAdapter(this, files, false)
val layoutManager = LinearLayoutManager(this@EditModInfoActivity)
val layoutManager = StableLinearLayoutManager(this@EditModInfoActivity)
mapAndMapAdapter.setItemChangeEvent { changeType, i, file, i2 ->
viewBinding.mapPathView.text =
String.format(getString(R.string.filenum), i2)

View File

@ -14,6 +14,7 @@ import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databean.ErrorInfo
import com.coldmint.rust.pro.databinding.ActivityErrorInfoBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.gson.Gson
import java.io.File
import java.util.concurrent.Executors
@ -30,7 +31,7 @@ class ErrorInfoActivity : BaseActivity<ActivityErrorInfoBinding>() {
if (canUseView) {
setTitle(R.string.see_error_info)
setReturnButton()
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
val path = AppSettings.dataRootDirectory + "/carsh/"
loadList(path)
}

View File

@ -33,6 +33,7 @@ import com.coldmint.rust.pro.databean.FileTab
import com.coldmint.rust.pro.databinding.ActivityFileBinding
import com.coldmint.rust.pro.interfaces.BookmarkListener
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.coldmint.rust.pro.viewmodel.FileManagerViewModel
import com.google.android.material.chip.Chip
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -190,10 +191,8 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
} else super.onKeyDown(keyCode, event)
}
@RequiresApi(Build.VERSION_CODES.LOLLIPOP_MR1)
fun initAction() {
viewBinding.fab.setOnClickListener {
val intent = Intent()
val startType = viewModel.startTypeData
when (startType) {
// "exportFile" -> {
@ -507,8 +506,8 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
if (canUseView) {
setReturnButton()
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this@FileManagerActivity)
val linearLayoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this@FileManagerActivity)
val linearLayoutManager = StableLinearLayoutManager(this)
linearLayoutManager.orientation = LinearLayoutManager.HORIZONTAL
viewBinding.fileTabNav.layoutManager = linearLayoutManager
loadTitle()

View File

@ -19,6 +19,7 @@ import com.coldmint.rust.core.ModClass
import com.coldmint.rust.pro.adapters.AttachFileAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivityGlobalOperationsBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.coldmint.rust.pro.viewmodel.GlobalOperationsViewModel
import com.google.android.material.textfield.TextInputEditText
import com.google.android.material.textfield.TextInputLayout
@ -56,7 +57,7 @@ class GlobalOperationsActivity : BaseActivity<ActivityGlobalOperationsBinding>()
viewModel.setModPath(modPath)
loadTextWatcher()
loadOnClickListener()
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
viewModel.fileListLiveData.observe(this) {
viewBinding.operationCard.isVisible = true
viewBinding.resultCard.isVisible = true

View File

@ -8,6 +8,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.coldmint.rust.pro.adapters.LibAdapter
import com.coldmint.rust.pro.databean.LibInfo
import com.coldmint.rust.pro.databinding.ActivityLibraryBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
import java.util.ArrayList
@ -190,7 +191,7 @@ class LibraryActivity : BaseActivity<ActivityLibraryBinding>() {
viewBinding.libsView.addItemDecoration(
divider
)
viewBinding.libsView.layoutManager = LinearLayoutManager(this@LibraryActivity)
viewBinding.libsView.layoutManager = StableLinearLayoutManager(this@LibraryActivity)
val libAdapter = LibAdapter(this@LibraryActivity, getLibInfoList())
viewBinding.libsView.adapter = libAdapter
}

View File

@ -15,6 +15,7 @@ import com.coldmint.rust.pro.adapters.TemplateItemAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivityNetworkTemplatePackageDetailsBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
class NetworkTemplatePackageDetailsActivity :
@ -31,7 +32,7 @@ class NetworkTemplatePackageDetailsActivity :
// createDirectory = intent.getStringExtra("createDirectory")
title = getString(R.string.title)
setReturnButton()
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
val divider = MaterialDividerItemDecoration(
this,
MaterialDividerItemDecoration.VERTICAL

View File

@ -21,6 +21,7 @@ import com.coldmint.rust.pro.base.BaseAdapter
import com.coldmint.rust.pro.databinding.ActivityOrderListBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.snackbar.Snackbar
/**
@ -46,7 +47,7 @@ class OrderListActivity : BaseActivity<ActivityOrderListBinding>() {
}
val thisIntent = intent
loadAll = thisIntent.getBooleanExtra("loadAll", false)
viewBinding.recyclerview.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerview.layoutManager = StableLinearLayoutManager(this)
loadList(loadAll)
}
}

View File

@ -14,6 +14,7 @@ import com.coldmint.rust.core.tool.FileOperator
import com.coldmint.rust.pro.adapters.FileAdapter
import com.coldmint.rust.pro.databinding.ActivityRecyclingStationBinding
import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import java.io.File
import java.util.ArrayList
@ -27,7 +28,7 @@ class RecyclingStationActivity : BaseActivity<ActivityRecyclingStationBinding>()
setReturnButton()
title = getString(R.string.enable_the_recovery_station)
viewBinding.backupList.layoutManager =
LinearLayoutManager(this@RecyclingStationActivity)
StableLinearLayoutManager(this@RecyclingStationActivity)
val workFolderPath = AppSettings.getValue(
AppSettings.Setting.RecoveryStationFolder,
this@RecyclingStationActivity.filesDir.absolutePath + "/backup/"

View File

@ -38,6 +38,7 @@ import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.LoadFileLayoutBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.github.promeg.pinyinhelper.Pinyin
import com.google.android.material.chip.Chip
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -78,7 +79,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
if (canUseView) {
title = getText(R.string.release)
setReturnButton()
val layoutManager = LinearLayoutManager(this)
val layoutManager = StableLinearLayoutManager(this)
layoutManager.orientation = RecyclerView.HORIZONTAL
viewBinding.screenshotRecyclerView.layoutManager = layoutManager
screenshotAdapter = ScreenshotAdapter(this, list)

View File

@ -15,6 +15,7 @@ import com.coldmint.rust.pro.adapters.ReportAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivityReportListBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
/**
* @author Cold Mint
@ -30,7 +31,7 @@ class ReportListActivity : BaseActivity<ActivityReportListBinding>() {
showInfoToView(R.string.please_login_first)
return
}
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
loadList(account)
}
}

View File

@ -16,6 +16,7 @@ import com.coldmint.rust.pro.adapters.AuditModAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivityReviewModBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.snackbar.Snackbar
/**
@ -35,7 +36,7 @@ class ReviewModActivity : BaseActivity<ActivityReviewModBinding>() {
showInfoToView(resId = R.string.please_login_first)
return
}
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
loadList()
}
}

View File

@ -15,6 +15,7 @@ import com.coldmint.rust.pro.adapters.HotSearchAdapter
import com.coldmint.rust.pro.adapters.SearchSuggestionsAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivitySearchBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
/**
* 搜索界面
@ -23,8 +24,8 @@ class SearchActivity : BaseActivity<ActivitySearchBinding>() {
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
title = getString(R.string.search)
setReturnButton()
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.hotSearchView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
viewBinding.hotSearchView.layoutManager = StableLinearLayoutManager(this)
loadSearchView()
loadHotSearch()
}

View File

@ -13,6 +13,7 @@ import com.coldmint.rust.core.web.WebMod
import com.coldmint.rust.pro.adapters.WebModAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivityTagBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
/**
* @author Cold Mint
@ -128,7 +129,7 @@ class TagActivity : BaseActivity<ActivityTagBinding>() {
}
titleStr = bundle.getString("title")
val action = bundle.getString("action")
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
if (action == null) {
showError("错误action为空")

View File

@ -31,6 +31,7 @@ import com.coldmint.rust.pro.databinding.AttachFilesBinding
import com.coldmint.rust.pro.fragments.EditTurretInfoFragment
import com.coldmint.rust.pro.fragments.SaveTemplateFragment
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.coldmint.rust.pro.viewmodel.TemplateMakerViewModel
import com.google.gson.Gson
import org.json.JSONArray
@ -64,7 +65,7 @@ class TemplateMakerActivity : BaseActivity<ActivityTemplateMakerBinding>() {
}
viewModel.isLocal(local)
viewModel.setPath(path)
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
viewModel.getCodeData { jsonArray, list ->
templateMakerAdapter = TemplateMakerAdapter(this, list)
if (jsonArray != null) {

View File

@ -8,6 +8,7 @@ import com.coldmint.rust.pro.adapters.ThanksAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databean.ThanksDataBean
import com.coldmint.rust.pro.databinding.ActivityThanksBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
/**
@ -32,7 +33,7 @@ class ThanksActivity : BaseActivity<ActivityThanksBinding>() {
viewBinding.recyclerView.addItemDecoration(
divider
)
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
val list = ArrayList<ThanksDataBean>()
list.add(ThanksDataBean("空调大郎", "帮助翻译俄语版本。", 1491779490))
list.add(ThanksDataBean("JDSA Ling", "制作助手新手模板,已被整合至助手内置模版。跟随助手更新。", 2735951230))

View File

@ -20,6 +20,7 @@ import com.coldmint.rust.core.web.ServerConfiguration
import com.coldmint.rust.pro.adapters.UserAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivityUserListBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
import com.google.android.material.snackbar.Snackbar
@ -70,7 +71,7 @@ class UserListActivity : BaseActivity<ActivityUserListBinding>() {
}
}
viewBinding.recyclerView.layoutManager =
LinearLayoutManager(this@UserListActivity)
StableLinearLayoutManager(this@UserListActivity)
val divider = MaterialDividerItemDecoration(
this,
MaterialDividerItemDecoration.VERTICAL

View File

@ -20,6 +20,7 @@ import com.coldmint.rust.core.tool.FileOperator
import com.coldmint.rust.pro.adapters.ValueAdapter
import com.coldmint.rust.pro.databinding.ActivityValueTypeBinding
import com.coldmint.rust.pro.databinding.EditValueBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.json.JSONArray
import org.json.JSONObject
@ -291,7 +292,7 @@ class ValueTypeActivity : BaseActivity<ActivityValueTypeBinding>() {
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
if (canUseView) {
title = getText(R.string.value_type_manager)
viewBinding.valueList.layoutManager = LinearLayoutManager(this@ValueTypeActivity)
viewBinding.valueList.layoutManager = StableLinearLayoutManager(this@ValueTypeActivity)
setReturnButton()
loadList()
viewBinding.fab.setOnClickListener { showEditDialog(null) }

View File

@ -23,6 +23,7 @@ import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivityWorkmangementBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
import com.google.android.material.snackbar.Snackbar
@ -256,7 +257,7 @@ class WorkManagementActivity : BaseActivity<ActivityWorkmangementBinding>() {
if (canUseView) {
title = getString(R.string.work_management)
setReturnButton()
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this)
val divider = MaterialDividerItemDecoration(
this,
MaterialDividerItemDecoration.VERTICAL

View File

@ -89,8 +89,8 @@ class TemplateAdapter(
view: View?,
parent: ViewGroup
): View {
val templateGroupBinding = TemplateGroupBinding.inflate(layoutInflater, parent, false)
try {
val templateClass = mGroup[groupPosition]
templateGroupBinding.templateName.text = templateClass.getName()
templateGroupBinding.templateNum.text = String.format(
@ -98,6 +98,10 @@ class TemplateAdapter(
mItemList[groupPosition].size
)
return templateGroupBinding.root
} catch (e: Exception) {
e.printStackTrace()
return templateGroupBinding.root
}
}
//获取子项的view

View File

@ -23,6 +23,7 @@ import com.coldmint.rust.pro.FileManagerActivity
import com.coldmint.rust.pro.base.BaseAdapter
import com.coldmint.rust.pro.databinding.TemplateBottomDialogBinding
import com.coldmint.rust.pro.databinding.TemplateListItemBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.divider.MaterialDividerItemDecoration
import java.io.File
@ -272,7 +273,7 @@ class TemplateListAdapter(
TemplateBottomDialogBinding.inflate(LayoutInflater.from(context))
bottomSheetDialog.setContentView(templateBottomDialogBinding.root)
templateBottomDialogBinding.templateActionList.layoutManager =
LinearLayoutManager(context)
StableLinearLayoutManager(context)
templateBottomDialogBinding.titleView.text = data.getName()
val list = ArrayList<String>()
list.add(editInfo)

View File

@ -30,6 +30,7 @@ import com.coldmint.rust.pro.adapters.UnitAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentAllUnitsBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import java.io.File
@ -54,7 +55,7 @@ class AllUnitsFragment(
val dataList: ArrayList<SourceFile> = ArrayList()
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.unitList.layoutManager = LinearLayoutManager(requireContext())
viewBinding.unitList.layoutManager = StableLinearLayoutManager(requireContext())
val divider = MaterialDividerItemDecoration(
requireContext(),
MaterialDividerItemDecoration.VERTICAL

View File

@ -26,6 +26,7 @@ import com.coldmint.rust.pro.adapters.DataSetAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentDatabaseBinding
import com.coldmint.rust.pro.databinding.DialogDatasetBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.gson.Gson
import java.io.File
import java.util.concurrent.Executors
@ -34,7 +35,7 @@ import kotlin.collections.ArrayList
class DatabaseFragment : BaseFragment<FragmentDatabaseBinding>() {
fun loadList() {
viewBinding.databaseList.layoutManager = LinearLayoutManager(requireContext())
viewBinding.databaseList.layoutManager = StableLinearLayoutManager(requireContext())
val database_directory = AppSettings.getValue(
AppSettings.Setting.DatabaseDirectory,
requireContext().filesDir.absolutePath + "/databases/"

View File

@ -13,6 +13,7 @@ import com.coldmint.rust.pro.R
import com.coldmint.rust.pro.adapters.DynamicAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentDynamicBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
/**
* @author Cold Mint
@ -57,7 +58,7 @@ class DynamicFragment(val userId: String) : BaseFragment<FragmentDynamicBinding>
}
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext())
loadList()
}
}

View File

@ -21,6 +21,7 @@ import com.coldmint.rust.pro.adapters.UserHeadAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentFollowBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
/**
* 关注者
@ -223,10 +224,10 @@ class FollowFragment : BaseFragment<FragmentFollowBinding>() {
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.rootLayout.layoutTransition.setAnimateParentHierarchy(false)
viewBinding.linearLayout2.layoutTransition.setAnimateParentHierarchy(false)
val linearLayoutManager = LinearLayoutManager(requireContext())
val linearLayoutManager = StableLinearLayoutManager(requireContext())
linearLayoutManager.orientation = RecyclerView.HORIZONTAL
viewBinding.headRecyclerView.layoutManager = linearLayoutManager
val linearLayoutManager2 = LinearLayoutManager(requireContext())
val linearLayoutManager2 = StableLinearLayoutManager(requireContext())
viewBinding.recyclerView.layoutManager = linearLayoutManager2
loadViewIfNeed()
}

View File

@ -17,6 +17,7 @@ import com.coldmint.rust.pro.R
import com.coldmint.rust.pro.adapters.HistoryAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentHistoryBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
import java.io.File
import java.util.concurrent.ExecutorService
@ -37,7 +38,7 @@ class HistoryUnitFragment(
var whenNumberChanged: ((Int) -> Unit)? = null
val executorService: ExecutorService = Executors.newSingleThreadExecutor()
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.unitList.layoutManager = LinearLayoutManager(requireContext())
viewBinding.unitList.layoutManager = StableLinearLayoutManager(requireContext())
val divider = MaterialDividerItemDecoration(
requireContext(),
MaterialDividerItemDecoration.VERTICAL

View File

@ -21,6 +21,7 @@ import com.coldmint.rust.pro.adapters.InsertCoinsAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentInsertCoinsBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
/**
@ -32,7 +33,7 @@ class InsertCoinsFragment(val modId: String) : BaseFragment<FragmentInsertCoinsB
}
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext())
val divider = MaterialDividerItemDecoration(
requireContext(),
MaterialDividerItemDecoration.VERTICAL

View File

@ -12,6 +12,7 @@ import com.coldmint.rust.core.LocalTemplatePackage
import com.coldmint.rust.pro.adapters.TemplateListAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentLocalTemplateBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import java.io.File
import java.util.*
import kotlin.collections.ArrayList
@ -51,7 +52,7 @@ class LocalTemplateFragment : BaseFragment<FragmentLocalTemplateBinding>() {
}
if (mutableList.isNotEmpty()) {
val listAdapter = TemplateListAdapter(requireContext(), mutableList, language, path)
val layoutManager = LinearLayoutManager(activity)
val layoutManager = StableLinearLayoutManager(requireContext())
viewBinding.templateList.layoutManager = layoutManager
viewBinding.templateList.adapter = listAdapter
viewBinding.swipeRefreshLayout.isVisible = true

View File

@ -22,6 +22,7 @@ import com.coldmint.rust.pro.adapters.MapAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentMapBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
import java.io.File
import kotlin.concurrent.thread
@ -136,7 +137,7 @@ class MapFragment : BaseFragment<FragmentMapBinding>() {
}
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.mapList.layoutManager = LinearLayoutManager(requireContext())
viewBinding.mapList.layoutManager = StableLinearLayoutManager(requireContext())
val divider = MaterialDividerItemDecoration(
requireContext(),
MaterialDividerItemDecoration.VERTICAL

View File

@ -24,6 +24,7 @@ import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentModCommentsBinding
import com.coldmint.rust.pro.dialog.CommentDialog
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
import com.google.android.material.snackbar.Snackbar
@ -32,7 +33,7 @@ import com.google.android.material.snackbar.Snackbar
*/
class ModCommentsFragment(val modId: String) : BaseFragment<FragmentModCommentsBinding>() {
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext())
val divider = MaterialDividerItemDecoration(
requireContext(),
MaterialDividerItemDecoration.VERTICAL

View File

@ -21,6 +21,7 @@ import com.coldmint.rust.pro.databinding.FragmentModBinding
import com.coldmint.rust.pro.databinding.ModListItemBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.coldmint.rust.pro.viewmodel.ModViewModel
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.divider.MaterialDividerItemDecoration
@ -338,7 +339,7 @@ class ModFragment : BaseFragment<FragmentModBinding>() {
}
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.modList.layoutManager = LinearLayoutManager(context)
viewBinding.modList.layoutManager = StableLinearLayoutManager(requireContext())
val divider = MaterialDividerItemDecoration(
requireContext(),
MaterialDividerItemDecoration.VERTICAL

View File

@ -12,13 +12,14 @@ import com.coldmint.rust.pro.adapters.MyWebTemplateAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentNetworkTemplateBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
/**
* 网络模板管理器
*/
class NetworkTemplateFragment : BaseFragment<FragmentNetworkTemplateBinding>() {
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext())
loadList()
viewBinding.swipeRefreshLayout.setOnRefreshListener {
loadList()

View File

@ -16,6 +16,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.FragmentPersonalHomeBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
/**
* @author Cold Mint
@ -29,9 +30,9 @@ class PersonalHomeFragment(val userId: String) : BaseFragment<FragmentPersonalHo
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.latestWorkRecycleView.layoutManager =
LinearLayoutManager(requireContext())
StableLinearLayoutManager(requireContext())
viewBinding.highestScoreRecycleView.layoutManager =
LinearLayoutManager(requireContext())
StableLinearLayoutManager(requireContext())
viewBinding.highestScoreActionView.setOnClickListener {
val bundle = Bundle()
bundle.putString(

View File

@ -19,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.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.chip.Chip
import me.zhanghai.android.fastscroll.FastScrollerBuilder
@ -30,7 +31,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
var lastOffset = 0
var lastPosition = 0
val linearLayoutManager by lazy {
LinearLayoutManager(requireContext())
StableLinearLayoutManager(requireContext())
}
private var sortMode: WebMod.SortMode = WebMod.SortMode.Download_Number

View File

@ -24,6 +24,7 @@ import com.coldmint.rust.pro.databinding.FragmentRecommendedBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.tool.TextStyleMaker
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.color.DynamicColors
import com.youth.banner.adapter.BannerImageAdapter
import com.youth.banner.holder.BannerImageHolder
@ -232,10 +233,10 @@ class RecommendedFragment : BaseFragment<FragmentRecommendedBinding>() {
}
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.latestReleaseView.layoutManager = LinearLayoutManager(requireContext())
viewBinding.latestReleaseView.layoutManager = StableLinearLayoutManager(requireContext())
viewBinding.soleRecommendedRecyclerView.layoutManager =
LinearLayoutManager(requireContext())
viewBinding.randomRecommendedView.layoutManager = LinearLayoutManager(requireContext())
StableLinearLayoutManager(requireContext())
viewBinding.randomRecommendedView.layoutManager = StableLinearLayoutManager(requireContext())
loadRandomRecommended()
viewBinding.changeRandomRecommended.setOnClickListener {
loadRandomRecommended()

View File

@ -20,6 +20,7 @@ import com.coldmint.rust.pro.R
import com.coldmint.rust.pro.adapters.TemplateSelectAdapter
import com.coldmint.rust.pro.databinding.FragmentSaveTemplateBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import org.json.JSONObject
import java.io.File
@ -47,7 +48,7 @@ class SaveTemplateFragment(val name: String, val json: JSONObject) : BottomSheet
@SuppressLint("ResourceType")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
fragmentSaveTemplateBinding.recyclerView.layoutManager =
LinearLayoutManager(requireContext())
StableLinearLayoutManager(requireContext())
loadWebTemplate {
loadLocalTemplate(requireContext())
loadList()

View File

@ -7,6 +7,7 @@ import com.coldmint.rust.core.dataBean.user.SearchResultDataBean
import com.coldmint.rust.pro.adapters.SearchResultAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentSearchResultBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
/**
@ -30,7 +31,7 @@ class SearchResultFragment(
MaterialDividerItemDecoration.VERTICAL
)
viewBinding.recyclerView.addItemDecoration(divider)
viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext())
}
/**

View File

@ -19,6 +19,7 @@ import com.coldmint.rust.pro.adapters.WebTemplateAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentTemplateCommunityBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
import me.zhanghai.android.fastscroll.FastScrollerBuilder
@ -37,7 +38,7 @@ class TemplateCommunityFragment : BaseFragment<FragmentTemplateCommunityBinding>
divider
)
viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext())
loadData()
viewBinding.swipeRefreshLayout.setOnRefreshListener {
loadData()
@ -50,6 +51,9 @@ class TemplateCommunityFragment : BaseFragment<FragmentTemplateCommunityBinding>
TemplatePhp.instance.getPublicTemplatePackageList(token, object :
ApiCallBack<WebTemplatePackageListData> {
override fun onResponse(t: WebTemplatePackageListData) {
if (!isAdded){
return
}
viewBinding.swipeRefreshLayout.isVisible = true
viewBinding.loadView.isVisible = false
viewBinding.errorLayout.isVisible = false

View File

@ -10,6 +10,7 @@ import com.coldmint.rust.pro.R
import com.coldmint.rust.pro.adapters.UserGroupAdapter
import com.coldmint.rust.pro.databean.UserGroupData
import com.coldmint.rust.pro.databinding.FragmentUserGroupBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
/**
@ -30,7 +31,7 @@ class UserGroupFragment : BottomSheetDialogFragment() {
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext())
val dataList = ArrayList<UserGroupData>()
dataList.add(UserGroupData(R.drawable.ic_qq, R.string.qq_group))
dataList.add(UserGroupData(R.drawable.ic_discord, R.string.discord_group))

View File

@ -0,0 +1,22 @@
package com.coldmint.rust.pro.ui
import android.content.Context
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
/**
* 稳定的线性布局管理器
*/
class StableLinearLayoutManager(val context: Context) : LinearLayoutManager(context) {
/**
* 这里加了try catch防止奔溃
*/
override fun onLayoutChildren(recycler: RecyclerView.Recycler?, state: RecyclerView.State?) {
try {
super.onLayoutChildren(recycler, state)
} catch (e: Exception) {
e.printStackTrace()
}
}
}

View File

@ -273,7 +273,7 @@ class TurretSketchpadView(context: Context, attributeSet: AttributeSet? = null)
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
if (mainImagePath != null && canvas != null) {
val bitmap = BitmapFactory.decodeFile(mainImagePath)
val bitmap = BitmapFactory.decodeFile(mainImagePath) ?: return
//计算坐标
calculateCoordinate(bitmap)
//设置图像