Commit 0b0ac86b authored by gaodapeng's avatar gaodapeng

优化,把同步生成改成异步生成。把bitmap加上回收机制

parent ed47c127
......@@ -117,9 +117,9 @@ public class ImageVideoBanner extends FrameLayout implements ViewPager.OnPageCha
if (sExecutor == null) {
sExecutor = Executors.newScheduledThreadPool(5);
}
Future<Boolean> submit = sExecutor.submit(new Callable<Boolean>() {
sExecutor.execute(new Runnable() {
@Override
public Boolean call() {
public void run() {
try {
String url = bannerBean.getUrl();
if (!url.contains("android.resource")) {
......@@ -132,19 +132,12 @@ public class ImageVideoBanner extends FrameLayout implements ViewPager.OnPageCha
b.recycle();
mmr.release();
}
return true;
} catch (Exception e) {
return false;
e.printStackTrace();
}
}
});
try {
submit.get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
......
package com.widget.imagebanner.view;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
......@@ -354,6 +357,19 @@ public class ImageVideoFragment extends Fragment {
sendPauseVideoMsg();
}
@Override
public void onDestroyView() {
Drawable drawable = ivWaitLoading.getDrawable();
ivWaitLoading.setImageDrawable(null);
if (drawable instanceof BitmapDrawable) {
Bitmap bm = ((BitmapDrawable) drawable).getBitmap();
if (!bm.isRecycled()) {
bm.recycle();
}
}
super.onDestroyView();
}
@Override
public void onDestroy() {
super.onDestroy();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment