|
@@ -24,17 +24,9 @@ import com.xplora.xpchat.observer.Listener;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
-public class VideoFragment extends DialogFragment implements Listener.PlayListener, View.OnClickListener {
|
|
|
- public String TAG = "losion / xpchat :" + getClass().getSimpleName();
|
|
|
- private Context mContext = null;
|
|
|
- private int position;
|
|
|
- private MessageBean bean;
|
|
|
+public class VideoFragment extends BaseActionFragment implements Listener.PlayListener {
|
|
|
private MediaPlayerUtils mMediaPlayerUtils = null;
|
|
|
private SurfaceHolder mSurfaceHolder = null;
|
|
|
- private ImageButton mPlayPauseBtn = null;
|
|
|
- private ImageButton mShareBtn = null;
|
|
|
- private ImageButton mSaveFileBtn = null;
|
|
|
- private ImageButton mCloseBtn = null;
|
|
|
|
|
|
public static VideoFragment newInstance(Context context) {
|
|
|
VideoFragment fragment = new VideoFragment();
|
|
@@ -42,35 +34,14 @@ public class VideoFragment extends DialogFragment implements Listener.PlayListen
|
|
|
return fragment;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
|
- getDialog().getWindow().requestFeature(Window.FEATURE_SWIPE_TO_DISMISS);
|
|
|
View rootView = inflater.inflate(R.layout.chat_fragment_video, container, false);
|
|
|
SurfaceView surfaceView = (SurfaceView) rootView.findViewById(R.id.surfaceView);
|
|
|
mSurfaceHolder = surfaceView.getHolder();
|
|
|
+ onCreateViewEx(rootView);
|
|
|
|
|
|
- mPlayPauseBtn = (ImageButton) rootView.findViewById(R.id.mPlayPauseBtn);
|
|
|
- mShareBtn = (ImageButton)rootView.findViewById(R.id.mShareBtn);
|
|
|
- mSaveFileBtn = (ImageButton)rootView.findViewById(R.id.mSaveFileBtn);
|
|
|
- mCloseBtn = (ImageButton)rootView.findViewById(R.id.mCloseBtn);
|
|
|
-
|
|
|
- mPlayPauseBtn.setOnClickListener(this);
|
|
|
- mShareBtn.setOnClickListener(this);
|
|
|
- mSaveFileBtn.setOnClickListener(this);
|
|
|
- mCloseBtn.setOnClickListener(this);
|
|
|
initVideo();
|
|
|
-
|
|
|
- TextView noFileText = (TextView)rootView.findViewById(R.id.mNoFileText);
|
|
|
- Uri uri = Uri.parse(bean.videoPath);
|
|
|
- if (noFileText != null) {
|
|
|
- noFileText.setVisibility(uri == null ? View.VISIBLE : View.GONE);
|
|
|
- }
|
|
|
return rootView;
|
|
|
}
|
|
|
|
|
@@ -100,10 +71,10 @@ public class VideoFragment extends DialogFragment implements Listener.PlayListen
|
|
|
} else if (v == mPlayPauseBtn) {
|
|
|
if (mMediaPlayerUtils.getIsPlaying()) {
|
|
|
mMediaPlayerUtils.mediaPause();
|
|
|
- setButtonStatus(false);
|
|
|
+ setPlayStatus(false);
|
|
|
} else {
|
|
|
mMediaPlayerUtils.mediaStart();
|
|
|
- setButtonStatus(true);
|
|
|
+ setPlayStatus(true);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -112,24 +83,15 @@ public class VideoFragment extends DialogFragment implements Listener.PlayListen
|
|
|
@Override
|
|
|
public void onCompletion(MediaPlayer mMediaPlayer) {
|
|
|
mMediaPlayer.seekTo(0);
|
|
|
- setButtonStatus(false);
|
|
|
+ setPlayStatus(false);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- private void setButtonStatus(boolean isPlaying) {
|
|
|
+ private void setPlayStatus(boolean isPlaying) {
|
|
|
int resId = isPlaying ? R.drawable.action_pause : R.drawable.action_play;
|
|
|
mPlayPauseBtn.setBackgroundResource(resId);
|
|
|
}
|
|
|
|
|
|
- public void setItemInfo(int position, MessageBean bean) {
|
|
|
- this.position = position;
|
|
|
- this.bean = bean;
|
|
|
- }
|
|
|
-
|
|
|
- private void remove() {
|
|
|
- dismissAllowingStateLoss();
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void onDestroy() {
|
|
|
Log.d(TAG, "onDestroy: ");
|
|
@@ -139,22 +101,22 @@ public class VideoFragment extends DialogFragment implements Listener.PlayListen
|
|
|
|
|
|
@Override
|
|
|
public void onPlayStart(MessageBean bean) {
|
|
|
- setButtonStatus(true);
|
|
|
+ setPlayStatus(true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onPlayFinish(MessageBean bean) {
|
|
|
mMediaPlayerUtils.mediaSeekTo(0);
|
|
|
- setButtonStatus(false);
|
|
|
+ setPlayStatus(false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onPlayCancel(MessageBean bean) {
|
|
|
- setButtonStatus(false);
|
|
|
+ setPlayStatus(false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onPlayException(String exMessage) {
|
|
|
- setButtonStatus(false);
|
|
|
+ setPlayStatus(false);
|
|
|
}
|
|
|
}
|