@Override public void onSuccess(String response) { Log.d(TAG, "the response --> " + response); Movie movie = MJsonUtil.gson.fromJson(response, new TypeToken<Movie>() {}.getType()); if (movie.getErrorCode() == 0) { mCurrentMovieDetail = movie; videoUri = movie.getData().getFilmUrl(); String title = movie.getData().getMovieName(); Log.d(TAG, "reponse video url: " + videoUri + " the name -->> " + title); mVideoView.setVideoURI(Uri.parse(videoUri), title); mVideoView.requestFocus(); // updateShareTVdatabase(movie, // mVideoView.getCurrentPosition()); int mPostion = getIntent().getIntExtra(Constants.MovieExtra.EXTRA_MOVIE_POSTION, 0); Log.d(TAG, "mPostion: " + mPostion); mVideoView.seekTo(mPostion); mVideoView.start(); // 需要更新底部的Fragment的信息 if (mNeedShowChildFragmentLater) { mNeedShowChildFragmentLater = false; Log.d(TAG, "show child fragment later"); showChildFragment(mRadioGroup.getCheckedRadioButtonId()); } } else { Log.d(TAG, movie.getErrorMsg()); } }
@Override protected void onPause() { mVideoView.pause(); updateShareTVdatabase(mCurrentMovieDetail, mVideoView.getCurrentPosition()); Log.d(TAG, "mVideoView.getCurrentPosition():" + mVideoView.getCurrentPosition()); Log.d(TAG, "moveid:" + mCurrentMovieDetail.getData().getMovieId()); super.onPause(); }
private void updateShareTVdatabase(Movie movie, int postion) { // TODO Auto-generated method stub Cursor mCursor = null; SQLiteDatabase db = null; try { Log.d("renjun1", "111111111"); // SQLiteDatabase db = dbHelper.getWritableDatabase(); db = dbHelper.getWritableDatabase(); mCursor = db.query( FlyShareTVdataHelper.TBL_HISTORY_VIDEOS, new String[] {"_id,_uri"}, "_id=?", new String[] {movie.getData().getMovieId()}, null, null, null); ContentValues values = new ContentValues(); String nowTime = getCurrentTime(); String filename = movie.getData().getMovieName(); String thumb = movie.getData().getThumb(); Log.d("renjun1", "filename:" + filename); Log.d("renjun1", "videoUri " + videoUri); Log.d("renjun1", "nowTime " + nowTime); Log.d("renjun1", "postion:" + postion); values.put("_uri", movie.getData().getFilmUrl()); values.put("_id", movie.getData().getMovieId()); values.put("_time", nowTime); values.put("_pos", postion); values.put("_name", filename); values.put("_thumb", thumb); if (mCursor == null || mCursor.getCount() == 0) { Log.d("renjun1", "22222222"); dbHelper.insert(values); } else { Log.d("renjun1", "3333333333"); dbHelper.update(values, movie.getData().getMovieId()); } } finally { if (mCursor != null) { mCursor.close(); } if (db != null) { db.close(); } } }
/** 注意,在这里统一所有的按钮点击处理!!! */ @Override public void onClick(View v) { switch (v.getId()) { case R.id.image_share: Log.d(TAG, "share...."); showShare(); break; case R.id.image_download: Log.d(TAG, "download...."); ToastUtils.ToastAdd(getContext(), "已加入下载队列"); VideoItem vitem = new VideoItem(); vitem.setVideoUri(mCurrentMovieDetail.getData().getFilmUrl()); vitem.setfileName(mCurrentMovieDetail.getData().getMovieName()); vitem.setMoveId(mCurrentMovieDetail.getData().getMovieId()); Log.d("renjun3", "moveiddetail: " + mCurrentMovieDetail.getData().getMovieId()); // DownloadVideoManager mDmger = new DownloadVideoManager(getApplication()); // mDmger.addVideoToDownQuee(vitem); Intent intent = new Intent(); intent.setClass(context, DownloadManagerService.class); intent.setAction("cn.fxdata.tv.download_action"); Bundle bud = new Bundle(); bud.putSerializable("videoRes", vitem); intent.putExtras(bud); startService(intent); // mBinder.addVideoToDownQuee(vitem); // vitem.setVideoUri(videoUri); // mDmger.setRemotePath(videoUri); // break; case R.id.image_fav: Log.d(TAG, "favorate...."); if (isSelected) { isSelected = false; if (mCurrentMovieDetail != null) { FavDbUtil.getInstance(getContext()).removeFavVideo(movieId); ToastUtils.ToastAdd(getContext(), "取消收藏"); image_fav.setImageResource(R.drawable.vedio_fav_normal); } } else { isSelected = true; String movieIdString = movieId; if (mCurrentMovieDetail.getData() != null && movieIdString != null) { String movieName = mCurrentMovieDetail.getData().getMovieName(); String movieTime = mCurrentMovieDetail.getData().getReleaseTime() == null ? "" : mCurrentMovieDetail.getData().getReleaseTime(); // 获得影片的缩略图url,方便加载 String movieImageUrl = mCurrentMovieDetail.getData().getFilmUrl(); String praiseTimeString = "1212"; if (movieName != null) { FavDbUtil.getInstance(getContext()) .addUpdateFavVideo( movieIdString, movieName, movieTime, praiseTimeString, movieImageUrl); ToastUtils.ToastAdd(getContext(), "收藏成功"); image_fav.setImageResource(R.drawable.vedio_fav_pressed); } else { ToastUtils.ToastAdd(getContext(), "电影名称为空,无法收藏"); } } else { ToastUtils.ToastAdd(getContext(), "电影数据为空,无法收藏"); } } break; } }
private void showChildFragment(int id) { if (null == mCurrentMovieDetail) { mNeedShowChildFragmentLater = true; return; } switch (id) { case R.id.video_detail_comment: if (null != mCurrentMovieDetail && null != mCommentFragment && null == mCommentFragment.getArguments()) { // 将MovieId传递给评论Fragment Bundle bundle = new Bundle(); // 这里的调用有可能在mCurrentMovieDetail初始化前, // 因此需要在mCurrentMovieDetail调用完成后再调用它一次 bundle.putString( Constants.MovieExtra.EXTRA_MOVIE_ID, mCurrentMovieDetail.getData().getMovieId()); mCommentFragment.setArguments(bundle); } fragmentManager.show("video_detail_comments"); fragmentId = 0; break; case R.id.video_detail_channel: // 影片选集 if (null != mCurrentMovieDetail && null != mEpisodeFragment && null == mEpisodeFragment.getArguments()) { mEpisodeFragment.setForplayVideoViewActivity(this); // 将MovieId传递给评论Fragment Bundle bundle = new Bundle(); // 这里的调用有可能在mCurrentMovieDetail初始化前, // 因此需要在mCurrentMovieDetail调用完成后再调用它一次 bundle.putString( Constants.MovieExtra.EXTRA_MOVIE_ID, mCurrentMovieDetail.getData().getMovieId()); mEpisodeFragment.setArguments(bundle); } fragmentManager.show("video_detail_channel"); fragmentId = 1; break; case R.id.video_detail_description: if (null != mCurrentMovieDetail && null != mDetailFragment && null == mDetailFragment.getArguments()) { Bundle bundle = new Bundle(); bundle.putString( Constants.MovieExtra.EXTRA_MOVIE_AREA, mCurrentMovieDetail.getData().getArea()); bundle.putString( Constants.MovieExtra.EXTRA_MOVIE_DETAIL, mCurrentMovieDetail.getData().getDetail()); bundle.putString( Constants.MovieExtra.EXTRA_MOVIE_ID, mCurrentMovieDetail.getData().getMovieId()); bundle.putString( Constants.MovieExtra.EXTRA_MOVIE_NAME, mCurrentMovieDetail.getData().getMovieName()); bundle.putString( Constants.MovieExtra.EXTRA_MOVIE_PATH, mCurrentMovieDetail.getData().getFilmUrl()); bundle.putString( Constants.MovieExtra.EXTRA_MOVIE_RELEASE_TIME, mCurrentMovieDetail.getData().getReleaseTime()); bundle.putString( Constants.MovieExtra.EXTRA_MOVIE_TYPE, mCurrentMovieDetail.getData().getType()); bundle.putString(Constants.MovieExtra.EXTRA_MOVIE_THUMB, mMovieThumb); mDetailFragment.setArguments(bundle); } fragmentManager.show("video_detail_description"); fragmentId = 2; break; } }