Hide video preference when video is not avaiable.
Change-Id: Ic4efc21d41b328591f2146534b7edecd86cb83ac Fix: 35855399 Test: manual
This commit is contained in:
@@ -62,6 +62,7 @@ public class VideoPreference extends Preference {
|
|||||||
.build();
|
.build();
|
||||||
mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
|
mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
|
||||||
if (mMediaPlayer != null && mMediaPlayer.getDuration() > 0) {
|
if (mMediaPlayer != null && mMediaPlayer.getDuration() > 0) {
|
||||||
|
setVisible(true);
|
||||||
setLayoutResource(R.layout.video_preference);
|
setLayoutResource(R.layout.video_preference);
|
||||||
|
|
||||||
mPreviewResource = attributes.getResourceId(
|
mPreviewResource = attributes.getResourceId(
|
||||||
@@ -71,6 +72,8 @@ public class VideoPreference extends Preference {
|
|||||||
|
|
||||||
mMediaPlayer.setOnPreparedListener(mediaPlayer -> mediaPlayer.setLooping(true));
|
mMediaPlayer.setOnPreparedListener(mediaPlayer -> mediaPlayer.setLooping(true));
|
||||||
mAnimationAvailable = true;
|
mAnimationAvailable = true;
|
||||||
|
} else {
|
||||||
|
setVisible(false);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.w(TAG, "Animation resource not found. Will not show animation.");
|
Log.w(TAG, "Animation resource not found. Will not show animation.");
|
||||||
|
Reference in New Issue
Block a user