From cffd907af1423a6762188e6facfd3b240b6a7611 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Sat, 20 Jul 2024 16:51:47 -0700 Subject: [PATCH] Improved perf of recyclerview --- .../frontend/filebrowser/GsFileBrowserDialog.java | 7 ++++--- .../filebrowser/GsFileBrowserListAdapter.java | 11 +++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserDialog.java b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserDialog.java index e3d716ac5e..6134b3639a 100644 --- a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserDialog.java +++ b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserDialog.java @@ -149,9 +149,10 @@ public void onViewCreated(final View root, final @Nullable Bundle savedInstanceS root.setBackgroundColor(rcolor(_dopt.backgroundColor)); - final LinearLayoutManager lam = (LinearLayoutManager) _recyclerList.getLayoutManager(); - final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activity, lam.getOrientation()); - _recyclerList.addItemDecoration(dividerItemDecoration); + // final LinearLayoutManager lam = (LinearLayoutManager) _recyclerList.getLayoutManager(); + // final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activity, lam.getOrientation()); + // _recyclerList.addItemDecoration(dividerItemDecoration); + _recyclerList.setItemViewCacheSize(20); _filesystemViewerAdapter = new GsFileBrowserListAdapter(_dopt, activity); _recyclerList.setAdapter(_filesystemViewerAdapter); diff --git a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java index 1b47ecc848..74d648ea70 100644 --- a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java +++ b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java @@ -184,15 +184,14 @@ public void onBindViewHolder(@NonNull FilesystemViewerViewHolder holder, int pos } } - holder.description.setTextColor(ContextCompat.getColor(_context, _dopt.secondaryTextColor)); + final boolean isFile = file.isFile(); - holder.image.postDelayed(() -> { - holder.image.setImageResource(isSelected ? _dopt.selectedItemImage : (!file.isFile() ? _dopt.folderImage : _dopt.fileImage)); - holder.description.setText(!_dopt.descModtimeInsteadOfParent || holder.title.getText().toString().equals("..") + holder.description.setText(!_dopt.descModtimeInsteadOfParent || holder.title.getText().toString().equals("..") ? descriptionFile.getAbsolutePath() : formatFileDescription(file, _prefApp.getString("pref_key__file_description_format", ""))); - }, 60); + holder.description.setTextColor(ContextCompat.getColor(_context, _dopt.secondaryTextColor)); + holder.image.setImageResource(isSelected ? _dopt.selectedItemImage : isFile ? _dopt.fileImage : _dopt.folderImage); holder.image.setColorFilter(ContextCompat.getColor(_context, - isSelected ? _dopt.accentColor : (!file.isFile() ? _dopt.folderColor : _dopt.fileColor)), + isSelected ? _dopt.accentColor : isFile? _dopt.fileColor : _dopt.folderColor), android.graphics.PorterDuff.Mode.SRC_ATOP); if (!isSelected && isFavourite) { holder.image.setColorFilter(0xFFE3B51B);