From 49a38821f202cdde8ed19533b0f4a3853219b04b Mon Sep 17 00:00:00 2001 From: inorichi Date: Sun, 6 Dec 2015 10:02:29 +0100 Subject: [PATCH] Animate recycler view decorations --- .../kanade/mangafeed/ui/catalogue/CataloguePresenter.java | 8 ++++++++ .../mangafeed/ui/decoration/DividerItemDecoration.java | 7 ++++--- .../mangafeed/ui/manga/chapter/ChaptersFragment.java | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CataloguePresenter.java b/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CataloguePresenter.java index dc4729bbfc..54819bb2b2 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CataloguePresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CataloguePresenter.java @@ -3,6 +3,7 @@ package eu.kanade.mangafeed.ui.catalogue; import android.os.Bundle; import android.text.TextUtils; +import com.bumptech.glide.Glide; import com.pushtorefresh.storio.sqlite.operations.put.PutResult; import java.util.List; @@ -77,6 +78,13 @@ public class CataloguePresenter extends BasePresenter { (view, error) -> Timber.e(error.getMessage())); } + @Override + protected void onDestroy() { + // Catalogue covers are probably not going to be needed for a long time + Glide.get(getContext()).clearMemory(); + super.onDestroy(); + } + public void startRequesting(int sourceId) { source = sourceManager.get(sourceId); restartRequest(null); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/decoration/DividerItemDecoration.java b/app/src/main/java/eu/kanade/mangafeed/ui/decoration/DividerItemDecoration.java index 2be3732c8c..1a449234f6 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/decoration/DividerItemDecoration.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/decoration/DividerItemDecoration.java @@ -40,13 +40,14 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration { final int left = parent.getPaddingLeft(); final int right = parent.getWidth() - parent.getPaddingRight(); final int childCount = parent.getChildCount(); + final int dividerHeight = mDivider.getIntrinsicHeight(); for (int i=1; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); - final int size = mDivider.getIntrinsicHeight(); - final int top = child.getTop() - params.topMargin; - final int bottom = top + size; + final int ty = (int)(child.getTranslationY() + 0.5f); + final int top = child.getTop() - params.topMargin + ty; + final int bottom = top + dividerHeight; mDivider.setBounds(left, top, right, bottom); mDivider.draw(c); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java index 43f9bbf0f8..8f44b938d9 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java @@ -76,6 +76,7 @@ public class ChaptersFragment extends BaseRxFragment implemen linearLayout = new LinearLayoutManager(getActivity()); recyclerView.setLayoutManager(linearLayout); recyclerView.addItemDecoration(new DividerItemDecoration(ContextCompat.getDrawable(getContext(), R.drawable.line_divider))); + recyclerView.setHasFixedSize(true); adapter = new ChaptersAdapter(this); recyclerView.setAdapter(adapter);