From 980ba326b6ca9542b5b35fe7b1468c8fc605ef1e Mon Sep 17 00:00:00 2001 From: litao Date: Mon, 12 Sep 2016 10:31:19 +0800 Subject: [PATCH] fix #2 OOM when load many images --- build.gradle | 2 +- .../java/com/litao/android/lib/adapter/PhotosAdapter.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8484671..1636f0b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0-beta3' + classpath 'com.android.tools.build:gradle:2.1.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/lib/src/main/java/com/litao/android/lib/adapter/PhotosAdapter.java b/lib/src/main/java/com/litao/android/lib/adapter/PhotosAdapter.java index c69196c..88baeb5 100644 --- a/lib/src/main/java/com/litao/android/lib/adapter/PhotosAdapter.java +++ b/lib/src/main/java/com/litao/android/lib/adapter/PhotosAdapter.java @@ -98,6 +98,11 @@ public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { return vh; } + @Override + public void onViewRecycled(ViewHolder holder) { + super.onViewRecycled(holder); + Glide.clear(holder.mImageView); + } @Override public void onBindViewHolder(ViewHolder viewHolder, int i) {