private void dropCatch() { VolleyTools tools = VolleyTools.getInstance(this.getContext()); tools.addToRequestQueue( new StringRequest( Method.POST, Constants.ServerConfig.DROP_URL, new Listener<String>() { @Override public void onSuccess(String response) { Log.d(TAG, "the response --> " + response); try { JSONObject object = new JSONObject(response); if (object.optInt("error_code") == 0) { isCatch = false; mImgFollowMe.setBackgroundResource(R.drawable.vedio_followme_normal); ToastUtils.ToastAdd(getContext(), "弃追成功!"); } else { isCatch = true; mImgFollowMe.setBackgroundResource(R.drawable.vedio_followme_pressed); ToastUtils.ToastAdd(getContext(), "弃追失败,请重试!"); } } catch (JSONException e) { e.printStackTrace(); } } @Override public void onError(VolleyError error) { isCatch = true; mImgFollowMe.setBackgroundResource(R.drawable.vedio_followme_pressed); Toast.makeText(getContext(), "弃追失败,请重试!", Toast.LENGTH_SHORT).show(); Log.d(TAG, "the response --> " + error.toString()); } @Override public void onCancel() { isCatch = true; mImgFollowMe.setBackgroundResource(R.drawable.vedio_followme_pressed); Toast.makeText(getContext(), "弃追失败,请重试!", Toast.LENGTH_SHORT).show(); } }) { @Override public Map<String, String> getParams() throws AuthFailureError { Map<String, String> map = new HashMap<String, String>(); map.put("chase_id", movieId); return map; } }, tools.VolleyTAG); }
private void catchMeRequest() { VolleyTools tools = VolleyTools.getInstance(this.getContext()); tools.addToRequestQueue( new StringRequest( Method.POST, Constants.ServerConfig.FOLLOW_ME_URL2, new Listener<String>() { @Override public void onSuccess(String response) { Log.d(TAG, "onSuccess" + response); isCatch = true; mImgFollowMe.setBackgroundResource(R.drawable.vedio_followme_pressed); ToastUtils.ToastAdd(getContext(), "追到手拉,快去来追我列表看看"); // Toast.makeText(getContext(), "追剧成功", // Toast.LENGTH_SHORT).show(); } @Override public void onError(VolleyError error) { isCatch = false; mImgFollowMe.setBackgroundResource(R.drawable.vedio_followme_normal); ToastUtils.ToastAdd(getContext(), "追剧失败"); // Toast.makeText(getContext(), "追剧失败,请重试", // Toast.LENGTH_SHORT).show(); Log.d(TAG, "onError"); } }) { @Override public Map<String, String> getParams() throws AuthFailureError { Map<String, String> map = new HashMap<String, String>(); map.put("user_id", getUserId()); return map; } }, tools.VolleyTAG); }
@SuppressLint("LongLogTag") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this; setContentView(R.layout.act_video_play_view_detail); // 拿到数据库实例 dbHelper = new FlyShareTVdataHelper(this); initFragments(); initView(); Intent intent = new Intent(this, DownloadManagerService.class); // intent.setAction("cn.fxdata.tv.download_action"); // startService(intent); // bindService(intent,conn,0); mVideoView.setOnToggleFullScreen(this); mVideoView.setBackClickInterface(this); mVideoView.setOnPreparedListener( new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { bar.setVisibility(View.GONE); } }); calculateVideoViewSize(); mVideoView.setDimensions(width, height); videoControllerView = new cn.fxdata.tv.view.video.VideoControllerView(this); mVideoView.setMediaController(videoControllerView); videoUri = null; if (getIntent().getExtras() == null) { ToastUtils.ToastAdd(getContext(), "数据为空"); mVideoView.setVideoURI(Uri.parse("http://fx.72zhe.com/static/fx/sample.mp4")); videoUri = "http://fx.72zhe.com/static/fx/sample.mp4"; } else if (getIntent().hasExtra(Constants.MovieExtra.EXTRA_MOVIE_PATH)) { if (getIntent().hasExtra(Constants.MovieExtra.EXTRA_MOVIE_ID)) { movieId = getIntent().getExtras().getString(Constants.MovieExtra.EXTRA_MOVIE_ID); Log.d(TAG, "forplay video movieID: " + movieId); VolleyTools tools = VolleyTools.getInstance(this.getContext()); tools.addToRequestQueue( new StringRequest( Method.GET, Constants.ServerConfig.MOVIE_DETAIL_URL + "&movie_id=" + movieId, getMovieDetailListener), tools.VolleyTAG); // 判断是否是收藏的视频,显示不同的收藏状态图片 boolean isFav = FavDbUtil.getInstance(getContext()).isFavVideo(movieId); isSelected = isFav; Log.d(TAG, "The fav video is -->> " + isFav); if (isFav) { image_fav.setImageResource(R.drawable.vedio_fav_pressed); } else { image_fav.setImageResource(R.drawable.vedio_fav_normal); } } else { String path = getIntent().getExtras().getString(Constants.MovieExtra.EXTRA_MOVIE_PATH); Log.i(TAG, "path : " + path); mVideoView.setVideoURI(Uri.parse(path)); videoUri = path; mVideoView.requestFocus(); // updateShareTVdatabase(videoUri, // mVideoView.getCurrentPosition()); // mVideoView.start(); int mPostion = getIntent().getIntExtra(Constants.MovieExtra.EXTRA_MOVIE_POSTION, 0); Log.d(TAG, "mPostion: " + mPostion); mVideoView.seekTo(mPostion); mVideoView.start(); } if (getIntent().hasExtra(Constants.MovieExtra.EXTRA_MOVIE_THUMB)) { mMovieThumb = getIntent().getExtras().getString(Constants.MovieExtra.EXTRA_MOVIE_THUMB); } } else if (getIntent().hasExtra(Constants.MovieExtra.EXTRA_MOVIE_ID)) { movieId = getIntent().getExtras().getString(Constants.MovieExtra.EXTRA_MOVIE_ID); Log.d(TAG, "forplay video movieID: " + movieId); VolleyTools tools = VolleyTools.getInstance(this.getContext()); tools.addToRequestQueue( new StringRequest( Method.GET, Constants.ServerConfig.MOVIE_DETAIL_URL + "&movie_id=" + movieId, getMovieDetailListener), tools.VolleyTAG); // 判断是否是收藏的视频,显示不同的收藏状态图片 boolean isFav = FavDbUtil.getInstance(getContext()).isFavVideo(movieId); isSelected = isFav; Log.d(TAG, "The fav video is -->> " + isFav); if (isFav) { image_fav.setImageResource(R.drawable.vedio_fav_pressed); } else { image_fav.setImageResource(R.drawable.vedio_fav_normal); } } else { ToastUtils.ToastAdd(getContext(), "视频播放地址为空"); /* * mVideoView.setVideoURI(Uri.parse( * "http://fx.72zhe.com/static/fx/sample.mp4")); videoUri = * "http://fx.72zhe.com/static/fx/sample.mp4"; * * mVideoView.requestFocus(); updateShareTVdatabase(videoUri, * mVideoView.getCurrentPosition()); mVideoView.start(); */ } }