Skip to content

Commit

Permalink
Properly fix (this time for good) the performance issue with continuo…
Browse files Browse the repository at this point in the history
…us vertical mode
  • Loading branch information
RobbWatershed committed May 15, 2019
1 parent bbbb3fe commit 14c3eaa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import me.devsaki.hentoid.R;
import me.devsaki.hentoid.util.ImageLoaderThreadExecutor;
import me.devsaki.hentoid.util.Preferences;
import timber.log.Timber;


public final class ImageRecyclerAdapter extends RecyclerView.Adapter<ImageRecyclerAdapter.ImageViewHolder> {
Expand Down Expand Up @@ -77,6 +78,7 @@ private ImageViewHolder(@NonNull View itemView) {
void setImageUri(String uri) {
imgView.recycle();
imgView.setMinimumScaleType(getScaleType());
Timber.i(">>>>IMG %s", uri);
imgView.setImage(ImageSource.uri(uri));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
.observe(this, this::onImagesChanged);

if (Preferences.isViewerResumeLastLeft())
new Handler().postDelayed(() -> recyclerView.scrollToPosition(viewModel.getInitialPosition()), 200);
recyclerView.scrollToPosition(viewModel.getInitialPosition());
}

@Override
Expand Down Expand Up @@ -124,6 +124,7 @@ private void initPager(View rootView) {

llm = new PrefetchLinearLayoutManager(getContext());
llm.setItemPrefetchEnabled(true);
llm.setPreloadItemCount(2);
recyclerView.setLayoutManager(llm);

pageSnapWidget = new PageSnapWidget(recyclerView)
Expand Down Expand Up @@ -267,8 +268,6 @@ public void onBrowseModeChange() {
llm.setReverseLayout(Preferences.getViewerDirection() != currentLayoutDirection);

llm.setOrientation(getOrientation());
// Lighten the load of preloading images when using vertical mode
llm.setPreloadItemCount(Preferences.Constant.PREF_VIEWER_ORIENTATION_HORIZONTAL == Preferences.getViewerOrientation() ? 2 : 1);
pageSnapWidget.setPageSnapEnabled(Preferences.Constant.PREF_VIEWER_ORIENTATION_VERTICAL != Preferences.getViewerOrientation());
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/item_viewer_image.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:minHeight="300dp"
/>

0 comments on commit 14c3eaa

Please sign in to comment.