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
4555129f
Commit
4555129f
authored
Jan 20, 2021
by
gaodapeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化了bitmap的回收
parent
d3c90cdb
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
65 deletions
+84
-65
ImageVideoBanner.java
.../com/widget/imagevideobanner/banner/ImageVideoBanner.java
+47
-45
ImageVideoFragment.java
...om/widget/imagevideobanner/banner/ImageVideoFragment.java
+37
-20
No files found.
imageVideoBanner/src/main/java/com/widget/imagevideobanner/banner/ImageVideoBanner.java
View file @
4555129f
This diff is collapsed.
Click to expand it.
imageVideoBanner/src/main/java/com/widget/imagevideobanner/banner/ImageVideoFragment.java
View file @
4555129f
package
com
.
widget
.
imagevideobanner
.
banner
;
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
;
...
...
@@ -88,10 +91,10 @@ public class ImageVideoFragment extends Fragment {
view
=
LayoutInflater
.
from
(
getActivity
()).
inflate
(
R
.
layout
.
item_image_view
,
container
,
false
);
ImageView
imageView
=
view
.
findViewById
(
R
.
id
.
iv
);
File
file
=
new
File
(
bannerBean
.
getUrl
());
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
Glide
.
with
(
container
.
getContext
()).
load
(
file
)
.
into
(
imageView
);
}
else
{
}
else
{
Glide
.
with
(
container
.
getContext
()).
load
(
bannerBean
.
getUrl
())
.
into
(
imageView
);
}
...
...
@@ -116,20 +119,19 @@ public class ImageVideoFragment extends Fragment {
*/
public
void
setPicture
()
{
//视频未加载完成,使用菊花
if
(
bannerBean
.
getLoadingImage
()
==
null
)
{
if
(
bannerBean
.
getUrl
().
contains
(
"android.resource"
))
{
if
(
bannerBean
.
getLoadingImage
()
==
null
)
{
if
(
bannerBean
.
getUrl
().
contains
(
"android.resource"
))
{
ivWaitLoading
.
setVisibility
(
View
.
VISIBLE
);
ivWaitLoading
.
setImageResource
(
R
.
drawable
.
guide_defaut
);
llWaitLoading
.
setVisibility
(
View
.
GONE
);
}
else
{
}
else
{
ivWaitLoading
.
setVisibility
(
View
.
GONE
);
llWaitLoading
.
setVisibility
(
View
.
VISIBLE
);
}
}
else
{
//加载完成使用首帧图片
}
else
{
//加载完成使用首帧图片
ivWaitLoading
.
setVisibility
(
View
.
VISIBLE
);
ivWaitLoading
.
setImageBitmap
(
BitmapUtils
.
getBitmap
(
bannerBean
.
getLoadingImage
()));
llWaitLoading
.
setVisibility
(
View
.
GONE
);
}
}
...
...
@@ -142,7 +144,7 @@ public class ImageVideoFragment extends Fragment {
mVideoView
.
requestFocus
();
try
{
mVideoView
.
setVideoURI
(
Uri
.
parse
(
bannerBean
.
getUrl
()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
mVideoView
.
setOnCompletionListener
(
new
MediaPlayer
.
OnCompletionListener
()
{
...
...
@@ -221,7 +223,7 @@ public class ImageVideoFragment extends Fragment {
public
void
startPlayer
()
{
if
(
null
!=
mVideoView
)
{
// setWaitLoading();
Log
.
e
(
TAG
,
"startPlayer "
+
currentPosition
);
Log
.
e
(
TAG
,
"startPlayer "
+
currentPosition
);
mVideoView
.
setBackgroundColor
(
Color
.
TRANSPARENT
);
mVideoView
.
seekTo
(
currentPosition
);
mVideoView
.
start
();
...
...
@@ -265,7 +267,7 @@ public class ImageVideoFragment extends Fragment {
private
void
pausePlayer
()
{
if
(
null
!=
mVideoView
)
{
Log
.
e
(
TAG
,
"pausePlayer 当前进度是"
+
mVideoView
.
getCurrentPosition
());
Log
.
e
(
TAG
,
"pausePlayer 当前进度是"
+
mVideoView
.
getCurrentPosition
());
mVideoView
.
setBackgroundColor
(
getResources
().
getColor
(
R
.
color
.
white
));
playerPaused
=
true
;
this
.
currentPosition
=
mVideoView
.
getCurrentPosition
();
...
...
@@ -351,6 +353,21 @@ public class ImageVideoFragment extends Fragment {
sendPauseVideoMsg
();
}
@Override
public
void
onDestroyView
()
{
if
(
ivWaitLoading
!=
null
)
{
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