From 7ecddf89767e039947c52af4a8af8ae1db6c5a0e Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Tue, 21 Feb 2023 19:33:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/coldmint/rust/pro/ActivateActivity.kt | 5 +++-- .../rust/pro/ApplicationListActivity.kt | 3 ++- .../rust/pro/BookmarkManagerActivity.kt | 3 ++- .../rust/pro/CreationWizardActivity.kt | 3 ++- .../com/coldmint/rust/pro/EditActivity.kt | 7 +++--- .../coldmint/rust/pro/EditModInfoActivity.kt | 5 +++-- .../coldmint/rust/pro/ErrorInfoActivity.kt | 3 ++- .../coldmint/rust/pro/FileManagerActivity.kt | 7 +++--- .../rust/pro/GlobalOperationsActivity.kt | 3 ++- .../com/coldmint/rust/pro/LibraryActivity.kt | 3 ++- .../NetworkTemplatePackageDetailsActivity.kt | 3 ++- .../coldmint/rust/pro/OrderListActivity.kt | 3 ++- .../rust/pro/RecyclingStationActivity.kt | 3 ++- .../coldmint/rust/pro/ReleaseModActivity.kt | 3 ++- .../coldmint/rust/pro/ReportListActivity.kt | 3 ++- .../coldmint/rust/pro/ReviewModActivity.kt | 3 ++- .../com/coldmint/rust/pro/SearchActivity.kt | 5 +++-- .../java/com/coldmint/rust/pro/TagActivity.kt | 3 ++- .../rust/pro/TemplateMakerActivity.kt | 3 ++- .../com/coldmint/rust/pro/ThanksActivity.kt | 3 ++- .../com/coldmint/rust/pro/UserListActivity.kt | 3 ++- .../coldmint/rust/pro/ValueTypeActivity.kt | 3 ++- .../rust/pro/WorkManagementActivity.kt | 3 ++- .../rust/pro/adapters/TemplateAdapter.kt | 20 ++++++++++------- .../rust/pro/adapters/TemplateListAdapter.kt | 3 ++- .../rust/pro/fragments/AllUnitsFragment.kt | 3 ++- .../rust/pro/fragments/DatabaseFragment.kt | 3 ++- .../rust/pro/fragments/DynamicFragment.kt | 3 ++- .../rust/pro/fragments/FollowFragment.kt | 5 +++-- .../rust/pro/fragments/HistoryUnitFragment.kt | 3 ++- .../rust/pro/fragments/InsertCoinsFragment.kt | 3 ++- .../pro/fragments/LocalTemplateFragment.kt | 3 ++- .../rust/pro/fragments/MapFragment.kt | 3 ++- .../rust/pro/fragments/ModCommentsFragment.kt | 3 ++- .../rust/pro/fragments/ModFragment.kt | 3 ++- .../pro/fragments/NetworkTemplateFragment.kt | 3 ++- .../pro/fragments/PersonalHomeFragment.kt | 5 +++-- .../rust/pro/fragments/RankingFragment.kt | 3 ++- .../rust/pro/fragments/RecommendedFragment.kt | 7 +++--- .../pro/fragments/SaveTemplateFragment.kt | 3 ++- .../pro/fragments/SearchResultFragment.kt | 3 ++- .../fragments/TemplateCommunityFragment.kt | 6 ++++- .../rust/pro/fragments/UserGroupFragment.kt | 3 ++- .../rust/pro/ui/StableLinearLayoutManager.kt | 22 +++++++++++++++++++ .../rust/core/turret/TurretSketchpadView.kt | 2 +- 45 files changed, 132 insertions(+), 63 deletions(-) create mode 100644 app/src/main/java/com/coldmint/rust/pro/ui/StableLinearLayoutManager.kt diff --git a/app/src/main/java/com/coldmint/rust/pro/ActivateActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ActivateActivity.kt index 797e838..0beb5c2 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ActivateActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ActivateActivity.kt @@ -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() { 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 -> diff --git a/app/src/main/java/com/coldmint/rust/pro/ApplicationListActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ApplicationListActivity.kt index 264eef1..150a7c2 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ApplicationListActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ApplicationListActivity.kt @@ -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() { @@ -130,7 +131,7 @@ class ApplicationListActivity : BaseActivity() { // LinearLayoutManager.VERTICAL // ) // ) - viewBinding.appListView.layoutManager = LinearLayoutManager(this@ApplicationListActivity) + viewBinding.appListView.layoutManager = StableLinearLayoutManager(this@ApplicationListActivity) } diff --git a/app/src/main/java/com/coldmint/rust/pro/BookmarkManagerActivity.kt b/app/src/main/java/com/coldmint/rust/pro/BookmarkManagerActivity.kt index 798efde..888451c 100644 --- a/app/src/main/java/com/coldmint/rust/pro/BookmarkManagerActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/BookmarkManagerActivity.kt @@ -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() { bookmarkManager = BookmarkManager(this@BookmarkManagerActivity) bookmarkManager.load() viewBinding.bookmarkList.layoutManager = - LinearLayoutManager(this@BookmarkManagerActivity) + StableLinearLayoutManager(this@BookmarkManagerActivity) val bookmarks = bookmarkManager.list() updateView(bookmarks) viewBinding.fab.setOnClickListener { diff --git a/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt b/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt index 33206d6..71f59c6 100644 --- a/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt @@ -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() { @@ -40,7 +41,7 @@ class CreationWizardActivity : BaseActivity() { return } type = temType - viewBinding.recyclerView.layoutManager = LinearLayoutManager(this) + viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this) when (temType) { "mod" -> { loadMod() diff --git a/app/src/main/java/com/coldmint/rust/pro/EditActivity.kt b/app/src/main/java/com/coldmint/rust/pro/EditActivity.kt index 5018694..c9e32d0 100644 --- a/app/src/main/java/com/coldmint/rust/pro/EditActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/EditActivity.kt @@ -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() { // * 初始化右侧视图 // */ // fun initEndView() { -// editEndBinding.logView.layoutManager = LinearLayoutManager(this) +// editEndBinding.logView.layoutManager = StableLinearLayoutManager(this) // } //当用户切换到其他应用界面时 @@ -529,7 +530,7 @@ class EditActivity : BaseActivity() { 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() { } } } - val linearLayoutManager = LinearLayoutManager(this) + val linearLayoutManager = StableLinearLayoutManager(this) linearLayoutManager.orientation = RecyclerView.HORIZONTAL viewBinding.recyclerview.isVisible = true viewBinding.recyclerview.layoutManager = linearLayoutManager diff --git a/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt b/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt index 9dc7cad..f09020c 100644 --- a/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/EditModInfoActivity.kt @@ -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() { } } 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() { } } 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) diff --git a/app/src/main/java/com/coldmint/rust/pro/ErrorInfoActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ErrorInfoActivity.kt index 43e44b4..5c94309 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ErrorInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ErrorInfoActivity.kt @@ -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() { 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) } diff --git a/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt b/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt index 0593ae5..19f4591 100644 --- a/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt @@ -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() { } 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() { 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() diff --git a/app/src/main/java/com/coldmint/rust/pro/GlobalOperationsActivity.kt b/app/src/main/java/com/coldmint/rust/pro/GlobalOperationsActivity.kt index bbe598d..a612ac1 100644 --- a/app/src/main/java/com/coldmint/rust/pro/GlobalOperationsActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/GlobalOperationsActivity.kt @@ -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() 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 diff --git a/app/src/main/java/com/coldmint/rust/pro/LibraryActivity.kt b/app/src/main/java/com/coldmint/rust/pro/LibraryActivity.kt index 35a3232..51f7c74 100644 --- a/app/src/main/java/com/coldmint/rust/pro/LibraryActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/LibraryActivity.kt @@ -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() { 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 } diff --git a/app/src/main/java/com/coldmint/rust/pro/NetworkTemplatePackageDetailsActivity.kt b/app/src/main/java/com/coldmint/rust/pro/NetworkTemplatePackageDetailsActivity.kt index 2b52117..89d958a 100644 --- a/app/src/main/java/com/coldmint/rust/pro/NetworkTemplatePackageDetailsActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/NetworkTemplatePackageDetailsActivity.kt @@ -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 diff --git a/app/src/main/java/com/coldmint/rust/pro/OrderListActivity.kt b/app/src/main/java/com/coldmint/rust/pro/OrderListActivity.kt index 7734a50..c36475f 100644 --- a/app/src/main/java/com/coldmint/rust/pro/OrderListActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/OrderListActivity.kt @@ -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() { } val thisIntent = intent loadAll = thisIntent.getBooleanExtra("loadAll", false) - viewBinding.recyclerview.layoutManager = LinearLayoutManager(this) + viewBinding.recyclerview.layoutManager = StableLinearLayoutManager(this) loadList(loadAll) } } diff --git a/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt b/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt index c24d229..20e3c5c 100644 --- a/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt @@ -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() 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/" diff --git a/app/src/main/java/com/coldmint/rust/pro/ReleaseModActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ReleaseModActivity.kt index 9e9466e..9fbd59f 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ReleaseModActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ReleaseModActivity.kt @@ -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() { 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) diff --git a/app/src/main/java/com/coldmint/rust/pro/ReportListActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ReportListActivity.kt index 83b4126..31f80ea 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ReportListActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ReportListActivity.kt @@ -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() { showInfoToView(R.string.please_login_first) return } - viewBinding.recyclerView.layoutManager = LinearLayoutManager(this) + viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this) loadList(account) } } diff --git a/app/src/main/java/com/coldmint/rust/pro/ReviewModActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ReviewModActivity.kt index 1cf7131..d9fb7c8 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ReviewModActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ReviewModActivity.kt @@ -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() { showInfoToView(resId = R.string.please_login_first) return } - viewBinding.recyclerView.layoutManager = LinearLayoutManager(this) + viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this) loadList() } } diff --git a/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt b/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt index 8d0b3c8..81e62f8 100644 --- a/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt @@ -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() { 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() } diff --git a/app/src/main/java/com/coldmint/rust/pro/TagActivity.kt b/app/src/main/java/com/coldmint/rust/pro/TagActivity.kt index c8ec8a7..1058c50 100644 --- a/app/src/main/java/com/coldmint/rust/pro/TagActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/TagActivity.kt @@ -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() { } titleStr = bundle.getString("title") val action = bundle.getString("action") - viewBinding.recyclerView.layoutManager = LinearLayoutManager(this) + viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this) if (action == null) { showError("错误,action为空") diff --git a/app/src/main/java/com/coldmint/rust/pro/TemplateMakerActivity.kt b/app/src/main/java/com/coldmint/rust/pro/TemplateMakerActivity.kt index 4cfa20e..a4fec44 100644 --- a/app/src/main/java/com/coldmint/rust/pro/TemplateMakerActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/TemplateMakerActivity.kt @@ -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() { } 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) { diff --git a/app/src/main/java/com/coldmint/rust/pro/ThanksActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ThanksActivity.kt index 90a4d79..47f863e 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ThanksActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ThanksActivity.kt @@ -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() { viewBinding.recyclerView.addItemDecoration( divider ) - viewBinding.recyclerView.layoutManager = LinearLayoutManager(this) + viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(this) val list = ArrayList() list.add(ThanksDataBean("空调大郎", "帮助翻译俄语版本。", 1491779490)) list.add(ThanksDataBean("JDSA Ling", "制作助手新手模板,已被整合至助手内置模版。跟随助手更新。", 2735951230)) diff --git a/app/src/main/java/com/coldmint/rust/pro/UserListActivity.kt b/app/src/main/java/com/coldmint/rust/pro/UserListActivity.kt index 556d685..ac6c29f 100644 --- a/app/src/main/java/com/coldmint/rust/pro/UserListActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/UserListActivity.kt @@ -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() { } } viewBinding.recyclerView.layoutManager = - LinearLayoutManager(this@UserListActivity) + StableLinearLayoutManager(this@UserListActivity) val divider = MaterialDividerItemDecoration( this, MaterialDividerItemDecoration.VERTICAL diff --git a/app/src/main/java/com/coldmint/rust/pro/ValueTypeActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ValueTypeActivity.kt index 51a6500..ac34e88 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ValueTypeActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ValueTypeActivity.kt @@ -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() { 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) } diff --git a/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt b/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt index 76562f0..2fc43b7 100644 --- a/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt @@ -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() { 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 diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/TemplateAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/TemplateAdapter.kt index 18f83e8..fe40e56 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/TemplateAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/TemplateAdapter.kt @@ -89,15 +89,19 @@ class TemplateAdapter( view: View?, parent: ViewGroup ): View { - val templateGroupBinding = TemplateGroupBinding.inflate(layoutInflater, parent, false) - val templateClass = mGroup[groupPosition] - templateGroupBinding.templateName.text = templateClass.getName() - templateGroupBinding.templateNum.text = String.format( - templateNum, - mItemList[groupPosition].size - ) - return templateGroupBinding.root + try { + val templateClass = mGroup[groupPosition] + templateGroupBinding.templateName.text = templateClass.getName() + templateGroupBinding.templateNum.text = String.format( + templateNum, + mItemList[groupPosition].size + ) + return templateGroupBinding.root + } catch (e: Exception) { + e.printStackTrace() + return templateGroupBinding.root + } } //获取子项的view diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/TemplateListAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/TemplateListAdapter.kt index 6a328af..8f85634 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/TemplateListAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/TemplateListAdapter.kt @@ -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() list.add(editInfo) diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/AllUnitsFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/AllUnitsFragment.kt index 15bde47..fadd122 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/AllUnitsFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/AllUnitsFragment.kt @@ -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 = ArrayList() override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { - viewBinding.unitList.layoutManager = LinearLayoutManager(requireContext()) + viewBinding.unitList.layoutManager = StableLinearLayoutManager(requireContext()) val divider = MaterialDividerItemDecoration( requireContext(), MaterialDividerItemDecoration.VERTICAL diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/DatabaseFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/DatabaseFragment.kt index c18a66f..3706e6a 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/DatabaseFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/DatabaseFragment.kt @@ -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() { fun loadList() { - viewBinding.databaseList.layoutManager = LinearLayoutManager(requireContext()) + viewBinding.databaseList.layoutManager = StableLinearLayoutManager(requireContext()) val database_directory = AppSettings.getValue( AppSettings.Setting.DatabaseDirectory, requireContext().filesDir.absolutePath + "/databases/" diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/DynamicFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/DynamicFragment.kt index 1062a2e..b4be955 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/DynamicFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/DynamicFragment.kt @@ -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 } override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { - viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) + viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext()) loadList() } } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt index e06263e..9d2cc84 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt @@ -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() { 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() } diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/HistoryUnitFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/HistoryUnitFragment.kt index 66c7cfe..91a30b2 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/HistoryUnitFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/HistoryUnitFragment.kt @@ -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 diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt index 174af52..33207b3 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt @@ -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() { } 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 diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/MapFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/MapFragment.kt index 5d453ce..1747d5a 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/MapFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/MapFragment.kt @@ -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() { } override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { - viewBinding.mapList.layoutManager = LinearLayoutManager(requireContext()) + viewBinding.mapList.layoutManager = StableLinearLayoutManager(requireContext()) val divider = MaterialDividerItemDecoration( requireContext(), MaterialDividerItemDecoration.VERTICAL diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt index a9076c4..b21aa82 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt @@ -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() { override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { - viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) + viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext()) val divider = MaterialDividerItemDecoration( requireContext(), MaterialDividerItemDecoration.VERTICAL diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt index 13939a1..458fe40 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt @@ -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() { } override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { - viewBinding.modList.layoutManager = LinearLayoutManager(context) + viewBinding.modList.layoutManager = StableLinearLayoutManager(requireContext()) val divider = MaterialDividerItemDecoration( requireContext(), MaterialDividerItemDecoration.VERTICAL diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/NetworkTemplateFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/NetworkTemplateFragment.kt index 0a059d7..72c1693 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/NetworkTemplateFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/NetworkTemplateFragment.kt @@ -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() { override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { - viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) + viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext()) loadList() viewBinding.swipeRefreshLayout.setOnRefreshListener { loadList() diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/PersonalHomeFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/PersonalHomeFragment.kt index f963853..981ac88 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/PersonalHomeFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/PersonalHomeFragment.kt @@ -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() { var lastOffset = 0 var lastPosition = 0 val linearLayoutManager by lazy { - LinearLayoutManager(requireContext()) + StableLinearLayoutManager(requireContext()) } private var sortMode: WebMod.SortMode = WebMod.SortMode.Download_Number diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt index b5a4976..e6b17b8 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt @@ -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() { } 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() diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/SaveTemplateFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/SaveTemplateFragment.kt index d435771..f6174ad 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/SaveTemplateFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/SaveTemplateFragment.kt @@ -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() diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/SearchResultFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/SearchResultFragment.kt index 1cbe145..bfa2a10 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/SearchResultFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/SearchResultFragment.kt @@ -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()) } /** diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/TemplateCommunityFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/TemplateCommunityFragment.kt index ee4a3ce..3ae37b4 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/TemplateCommunityFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/TemplateCommunityFragment.kt @@ -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 divider ) - viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) + viewBinding.recyclerView.layoutManager = StableLinearLayoutManager(requireContext()) loadData() viewBinding.swipeRefreshLayout.setOnRefreshListener { loadData() @@ -50,6 +51,9 @@ class TemplateCommunityFragment : BaseFragment TemplatePhp.instance.getPublicTemplatePackageList(token, object : ApiCallBack { override fun onResponse(t: WebTemplatePackageListData) { + if (!isAdded){ + return + } viewBinding.swipeRefreshLayout.isVisible = true viewBinding.loadView.isVisible = false viewBinding.errorLayout.isVisible = false diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/UserGroupFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/UserGroupFragment.kt index c92a56e..622ae99 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/UserGroupFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/UserGroupFragment.kt @@ -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() dataList.add(UserGroupData(R.drawable.ic_qq, R.string.qq_group)) dataList.add(UserGroupData(R.drawable.ic_discord, R.string.discord_group)) diff --git a/app/src/main/java/com/coldmint/rust/pro/ui/StableLinearLayoutManager.kt b/app/src/main/java/com/coldmint/rust/pro/ui/StableLinearLayoutManager.kt new file mode 100644 index 0000000..de73ab4 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/ui/StableLinearLayoutManager.kt @@ -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() + } + } +} \ No newline at end of file diff --git a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretSketchpadView.kt b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretSketchpadView.kt index eb1e2b0..20d575c 100644 --- a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretSketchpadView.kt +++ b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/turret/TurretSketchpadView.kt @@ -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) //设置图像