Hide video preference when video is not avaiable.

Change-Id: Ic4efc21d41b328591f2146534b7edecd86cb83ac
Fix: 35855399
Test: manual
This commit is contained in:
Fan Zhang
2017-03-07 15:58:35 -08:00
parent e0b65fce67
commit 26ce68c0ea

View File

@@ -62,6 +62,7 @@ public class VideoPreference extends Preference {
.build();
mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
if (mMediaPlayer != null && mMediaPlayer.getDuration() > 0) {
setVisible(true);
setLayoutResource(R.layout.video_preference);
mPreviewResource = attributes.getResourceId(
@@ -71,6 +72,8 @@ public class VideoPreference extends Preference {
mMediaPlayer.setOnPreparedListener(mediaPlayer -> mediaPlayer.setLooping(true));
mAnimationAvailable = true;
} else {
setVisible(false);
}
} catch (Exception e) {
Log.w(TAG, "Animation resource not found. Will not show animation.");