Browse Source

Animate recycler view decorations

inorichi 9 years ago
parent
commit
49a38821f2

+ 8 - 0
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<CatalogueFragment> {
                 (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);

+ 4 - 3
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);
             }

+ 1 - 0
app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java

@@ -76,6 +76,7 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> 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);