Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
ImageVideoBanner
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangjiantao
ImageVideoBanner
Commits
0b0ac86b
Commit
0b0ac86b
authored
Oct 19, 2020
by
gaodapeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化,把同步生成改成异步生成。把bitmap加上回收机制
parent
ed47c127
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
ImageVideoBanner.java
...rc/main/java/com/widget/imagebanner/ImageVideoBanner.java
+4
-11
ImageVideoFragment.java
.../java/com/widget/imagebanner/view/ImageVideoFragment.java
+16
-0
No files found.
banner/src/main/java/com/widget/imagebanner/ImageVideoBanner.java
View file @
0b0ac86b
...
...
@@ -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
();
}
}
...
...
banner/src/main/java/com/widget/imagebanner/view/ImageVideoFragment.java
View file @
0b0ac86b
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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment