| | |
| | | import android.os.Handler; |
| | | import android.support.v7.widget.LinearLayoutManager; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import android.text.SpannableString; |
| | | import android.text.Spanned; |
| | | import android.text.style.ForegroundColorSpan; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | |
| | | |
| | | private int episodePage = 2;//当前页 |
| | | |
| | | //默认页大小为100 |
| | | private int pageSize = 100; |
| | | |
| | | private String fromName = null; |
| | | |
| | | public static DisplayImageOptions option = new DisplayImageOptions.Builder() |
| | |
| | | .build(); |
| | | |
| | | public static EpisodeFragment newInstance(VideoInfo videoInfo, |
| | | int playingPosition, int start, int end,String from) { |
| | | int playingPosition, int pageSize, int start, int end, String from) { |
| | | EpisodeFragment episodeFragment = new EpisodeFragment(); |
| | | Bundle args = new Bundle(); |
| | | args.putSerializable("video_info", videoInfo); |
| | | args.putInt("playing_position", playingPosition); |
| | | args.putInt("start", start); |
| | | args.putInt("end", end); |
| | | args.putInt("pageSize", pageSize); |
| | | args.putString("from", from); |
| | | episodeFragment.setArguments(args); |
| | | return episodeFragment; |
| | |
| | | } |
| | | |
| | | private void setFollowData(boolean attention) { |
| | | tv_cancle_follow.setBackgroundResource(R.drawable.shape_video_detail_follow_btn); |
| | | tv_cancle_follow.setTextColor(getResources().getColor(R.color.video_detail_follow_text_color)); |
| | | if (attention) { |
| | | tv_cancle_follow.setText("已关注"); |
| | | tv_cancle_follow.setCompoundDrawables(null, null, null, null); |
| | | } else { |
| | | tv_cancle_follow.setText("关注"); |
| | | Drawable drawable = getResources().getDrawable(R.drawable.ic_follow_add); |
| | | Drawable drawable = getResources().getDrawable(R.drawable.ic_follow_add_w); |
| | | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
| | | tv_cancle_follow.setCompoundDrawables(drawable, null, null, null); |
| | | } |
| | |
| | | .getString("from", ""); |
| | | |
| | | mPlayingPosition = bundle.getInt("playing_position"); |
| | | pageSize = bundle.getInt("pageSize", 100); |
| | | mStart = bundle.getInt("start"); |
| | | mEnd = bundle.getInt("end"); |
| | | |
| | |
| | | |
| | | tv_video_resource = contentView.findViewById(R.id.tv_video_resource); |
| | | ll_add_attention = contentView.findViewById(R.id.ll_add_attention); |
| | | ll_add_attention.setBackgroundResource(R.drawable.shape_video_detail_follow_bg); |
| | | tv_title = contentView.findViewById(R.id.tv_title); |
| | | tv_score = contentView.findViewById(R.id.tv_score); |
| | | tv_play_num = contentView.findViewById(R.id.tv_play_num); |
| | |
| | | break; |
| | | } |
| | | if (checkedResource != null) { |
| | | loadMoreEpisode(mVideoInfo.getId(), checkedResource.getId(), episodePage); |
| | | loadMoreEpisode(mVideoInfo.getId(), checkedResource.getId(), episodePage, pageSize); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private ProgressDialog pd; |
| | | |
| | | private void setResource(String resource) { |
| | | SpannableString st = new SpannableString(resource); |
| | | st.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.video_detail_resource_text_color)), 3, resource.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); |
| | | tv_video_resource.setText(st); |
| | | } |
| | | |
| | | private void initResource() { |
| | | |
| | | if (mVideoInfo.getResourceList() != null |
| | | && mVideoInfo.getResourceList().size() > 0) { |
| | | tv_video_resource.setVisibility(View.VISIBLE); |
| | | String resource = ""; |
| | | if (selectedUrl == null || selectedUrl.getPicture() == null) { |
| | | tv_video_resource.setText("来源:其他"); |
| | | resource = "来源:其他"; |
| | | } else { |
| | | tv_video_resource.setText("来源:" + selectedUrl.getName()); |
| | | resource = "来源:" + selectedUrl.getName(); |
| | | } |
| | | setResource(resource); |
| | | |
| | | popupWindow = new PopupWindow( |
| | | com.weikou.beibeivideo.util.DimenUtils.dip2px(getContext(), 120), |
| | | android.view.WindowManager.LayoutParams.WRAP_CONTENT); |
| | | popupWindow.setOutsideTouchable(true);// 点击外部可点击 |
| | | popupWindow.setBackgroundDrawable(new ColorDrawable(0));// 设置背景 |
| | | popupWindow.setAnimationStyle(R.style.PopupAnimation); |
| | | popupWindow.setFocusable(true);// 获取焦点 |
| | | |
| | |
| | | ListView.LayoutParams param = new ListView.LayoutParams( |
| | | FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); |
| | | lv.setLayoutParams(param); |
| | | lv.setBackground(getResources().getDrawable(R.drawable.shape_video_detail_resource_bg)); |
| | | |
| | | lv.setOnItemClickListener(new OnItemClickListener() { |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | |
| | | pd.show(); |
| | | getVideoDetail(mVideoInfo.getId(), urlList |
| | | .get(position).getId(), mVideoInfo |
| | | .getThirdType(), true,fromName); |
| | | .getThirdType(), true, fromName); |
| | | } |
| | | selectedUrl = urlList.get(position); |
| | | if (selectedUrl == null || selectedUrl.getPicture() == null) { |
| | | tv_video_resource.setText("来源:其他"); |
| | | setResource("来源:其他"); |
| | | } else { |
| | | tv_video_resource.setText("来源:" + selectedUrl.getName()); |
| | | setResource("来源:" + selectedUrl.getName()); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | lv.setAdapter(new ResourceAdapter(urlList)); |
| | | lv.setDivider(new ColorDrawable(Color.BLACK)); |
| | | lv.setDividerHeight(1); |
| | | lv.setDividerHeight(0); |
| | | popupWindow.setContentView(lv); |
| | | /* |
| | | * Window dialogWindow = dialog.getWindow(); dialogWindow.get |
| | |
| | | ImageView iv = view.findViewById(R.id.iv_resource); |
| | | TextView tv = view.findViewById(R.id.tv_resource); |
| | | try { |
| | | Glide.with(getActivity().getApplicationContext()) |
| | | .load(reList.get(position).getPicture().contains("http://") ? reList |
| | | .get(position).getPicture() : BeibeiConstant.HOST |
| | | + "/BuWan/" + reList.get(position).getPicture()) |
| | | Glide.with(iv) |
| | | .load(reList.get(position).getPicture()) |
| | | .apply(new RequestOptions().placeholder(R.drawable.from_other).error(R.drawable.from_other)) |
| | | .into(iv); |
| | | } catch (IllegalArgumentException e) { |
| | |
| | | } else { |
| | | tv.setText(reList.get(position).getName()); |
| | | } |
| | | |
| | | int background = 0; |
| | | |
| | | if (reList.size() <= 1) { |
| | | background = reList.get(position).isChecked() ? R.drawable.shape_video_detail_resource_single_item_selected_bg : R.drawable.shape_video_detail_resource_single_item_bg; |
| | | } else { |
| | | if (position == 0) { |
| | | background = reList.get(position).isChecked() ? R.drawable.shape_video_detail_resource_top_item_selected_bg : R.drawable.shape_video_detail_resource_top_item_bg; |
| | | } else if (position == reList.size() - 1) { |
| | | background = reList.get(position).isChecked() ? R.drawable.shape_video_detail_resource_bottom_item_selected_bg : R.drawable.shape_video_detail_resource_bottom_item_bg; |
| | | } else { |
| | | background = reList.get(position).isChecked() ? R.drawable.shape_video_detail_resource_middle_item_selected_bg : R.drawable.shape_video_detail_resource_middle_item_bg; |
| | | } |
| | | } |
| | | view.setBackgroundResource(background); |
| | | |
| | | return view; |
| | | } |
| | | } |
| | |
| | | * @param videoId |
| | | * @param resourceId |
| | | */ |
| | | private synchronized void loadMoreEpisode(String videoId, String resourceId, int page) { |
| | | BeibeiVideoAPI.getVideoEpisodeList(ll_add_attention.getContext(), UserUtil.getUid(getContext()), resourceId, videoId, page, new |
| | | private synchronized void loadMoreEpisode(String videoId, String resourceId, int page, int pageSize) { |
| | | BeibeiVideoAPI.getVideoEpisodeList(ll_add_attention.getContext(), UserUtil.getUid(getContext()), resourceId, videoId, page, pageSize, new |
| | | |
| | | BasicTextHttpResponseHandler() { |
| | | @Override |