fixed crashes

This commit is contained in:
Mariotaku Lee 2016-04-19 19:06:09 +08:00
parent 2a78139e94
commit 2a7d99e33c
2 changed files with 7 additions and 4 deletions

View File

@ -933,6 +933,7 @@ public final class MediaViewerActivity extends BaseActivity implements Constants
@Override @Override
protected void displayMedia(CacheDownloadLoader.Result result) { protected void displayMedia(CacheDownloadLoader.Result result) {
mVideoView.setVideoURI(result.cacheUri); mVideoView.setVideoURI(result.cacheUri);
mVideoControl.setVisibility(View.GONE);
setMediaViewVisible(true); setMediaViewVisible(true);
final FragmentActivity activity = getActivity(); final FragmentActivity activity = getActivity();
if (activity != null) { if (activity != null) {
@ -967,6 +968,7 @@ public final class MediaViewerActivity extends BaseActivity implements Constants
mMediaPlayer = null; mMediaPlayer = null;
mVideoViewProgress.removeCallbacks(mVideoProgressRunnable); mVideoViewProgress.removeCallbacks(mVideoProgressRunnable);
mVideoViewProgress.setVisibility(View.GONE); mVideoViewProgress.setVisibility(View.GONE);
mVideoControl.setVisibility(View.GONE);
mMediaPlayerError = what; mMediaPlayerError = what;
return true; return true;
} }
@ -988,12 +990,12 @@ public final class MediaViewerActivity extends BaseActivity implements Constants
} }
private void updateVolume() { private void updateVolume() {
final MediaPlayer mp = mMediaPlayer;
if (mp == null || mp.isPlaying()) return;
final ImageButton b = mVolumeButton; final ImageButton b = mVolumeButton;
if (b != null) { if (b != null) {
b.setImageResource(mPlayAudio ? R.drawable.ic_action_speaker_max : R.drawable.ic_action_speaker_muted); b.setImageResource(mPlayAudio ? R.drawable.ic_action_speaker_max : R.drawable.ic_action_speaker_muted);
} }
final MediaPlayer mp = mMediaPlayer;
if (mp == null) return;
if (mPlayAudio) { if (mPlayAudio) {
mp.setVolume(1, 1); mp.setVolume(1, 1);
} else { } else {
@ -1048,6 +1050,7 @@ public final class MediaViewerActivity extends BaseActivity implements Constants
mPlayPauseButton.setOnClickListener(this); mPlayPauseButton.setOnClickListener(this);
mVolumeButton.setOnClickListener(this); mVolumeButton.setOnClickListener(this);
mVideoControl.setVisibility(View.GONE);
startLoading(false); startLoading(false);
setMediaViewVisible(false); setMediaViewVisible(false);
updateVolume(); updateVolume();

View File

@ -66,8 +66,8 @@ public abstract class ParcelableUsersLoader extends AsyncTaskLoader<List<Parcela
} }
protected boolean hasId(final String id) { protected boolean hasId(final String id) {
for (final ParcelableUser user : mData) { for (int i = 0; i < mData.size(); i++) {
if (TextUtils.equals(user.key.getId(), id)) return true; if (TextUtils.equals(mData.get(i).key.getId(), id)) return true;
} }
return false; return false;
} }