| | |
| | | import android.content.SharedPreferences; |
| | | import android.database.Cursor; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.Color; |
| | | import android.graphics.Rect; |
| | | import android.graphics.drawable.ColorDrawable; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.support.v7.widget.LinearLayoutManager; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | import android.widget.AdapterView.OnItemClickListener; |
| | | import android.widget.BaseAdapter; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.GridView; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.ListView; |
| | |
| | | import android.widget.Toast; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | |
| | | import com.umeng.socialize.media.UMWeb; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.db.WatchHistoryTable; |
| | | import com.weikou.beibeivideo.entity.Follow; |
| | | import com.weikou.beibeivideo.entity.Play; |
| | |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.VideoResource; |
| | | import com.weikou.beibeivideo.entity.ad.ExpressAdContainer; |
| | | import com.weikou.beibeivideo.entity.video.FunshionPlayInfo; |
| | | import com.weikou.beibeivideo.ui.login.LoginActivity; |
| | | import com.weikou.beibeivideo.ui.video.EpisodeNewAdapter; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.GlideCircleTransform; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | import com.weikou.beibeivideo.util.ui.DividerItemDecoration; |
| | | import com.yeshi.buwanshequ.R; |
| | | import com.weikou.beibeivideo.R; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONArray; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.lang.reflect.Type; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | private int mEnd; |
| | | private int mPlayingPosition; |
| | | private VideoInfo mVideoInfo = null; |
| | | private static RecyclerView rv_episode; |
| | | private RecyclerView rv_episode; |
| | | |
| | | private LinearLayout fl_report; |
| | | private ImageView iv_favourite; |
| | |
| | | private FrameLayout fl_native_ad1; |
| | | |
| | | private EpisodeNewAdapter episodeAdapter; |
| | | |
| | | final String TAG = "EpisodeFragment"; |
| | | |
| | | private boolean episodeLoading = false;//剧集是否正在加载更多 |
| | | |
| | | private boolean episodeHasMore = true;//是否还有更多的剧集 |
| | | |
| | | private int episodePage = 2;//当前页 |
| | | |
| | | public static DisplayImageOptions option = new DisplayImageOptions.Builder() |
| | | .showImageForEmptyUri(R.drawable.from_other) |
| | |
| | | tv_play_num.setText("播放:" + VideoUtil.getWatchCountShortName(mVideoInfo.getWatchCount())); |
| | | } |
| | | |
| | | public class SpacesItemDecoration extends RecyclerView.ItemDecoration { |
| | | private int space; |
| | | |
| | | public SpacesItemDecoration(int space) { |
| | | this.space = space; |
| | | } |
| | | |
| | | @Override |
| | | public void getItemOffsets(Rect outRect, View view, |
| | | RecyclerView parent, RecyclerView.State state) { |
| | | int position = parent.getChildAdapterPosition(view); |
| | | outRect.left = space; |
| | | if (mVideoInfo != null && position == VideoUtil.videoEpisodeList.size() - 1) |
| | | outRect.right = space; |
| | | } |
| | | } |
| | | |
| | | private void loadEpisode() { |
| | | |
| | | int type = 0; |
| | | |
| | | if (mVideoInfo.getShowType() == 1) { |
| | | // 综艺或者电影 |
| | | type = EpisodeNewAdapter.TYPE_ZONGYI; |
| | | |
| | | } else if (mVideoInfo.getShowType() == 2) { |
| | | // 电视剧动漫 |
| | | type = EpisodeNewAdapter.TYPE_DIANSHIJU; |
| | | } |
| | | episodeAdapter = new EpisodeNewAdapter(getContext(), mVideoInfo, type, mPlayingPosition, new EpisodeNewAdapter.ISelectVideoEpisodeListener() { |
| | | @Override |
| | | public void onClick(int position, VideoDetailInfo detailInfo) { |
| | | setEpisodeSelected(position); |
| | | getUrl(detailInfo); |
| | | } |
| | | }); |
| | | LinearLayoutManager ms = new LinearLayoutManager(getContext()); |
| | | ms.setOrientation(LinearLayoutManager.HORIZONTAL); |
| | | rv_episode.setHasFixedSize(true); |
| | | rv_episode.setNestedScrollingEnabled(false); |
| | | if (rv_episode.getLayoutManager() == null) |
| | | rv_episode.setLayoutManager(ms); |
| | | |
| | | if (rv_episode.getItemDecorationCount() == 0) |
| | | rv_episode.addItemDecoration(new SpacesItemDecoration(DimenUtils.dip2px(getContext(), 10))); |
| | | } |
| | | |
| | | |
| | | //设置选中状态 |
| | | private void setEpisodeSelected(int position) { |
| | | mPlayingPosition = position; |
| | | episodeAdapter.setPlayingPosition(mPlayingPosition); |
| | | refresh(); |
| | | Playlocation playlocation = new Playlocation(); |
| | | playlocation.setPosition(position); |
| | | EventBus.getDefault().post(playlocation); |
| | | } |
| | | |
| | | private void setFollowData(boolean attention) { |
| | | 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.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
| | | tv_cancle_follow.setCompoundDrawables(drawable, null, null, null); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | EventBus.getDefault().register(this); |
| | | mVideoInfo = (VideoInfo) getArguments() |
| | | Log.i(TAG, "onCreateView"); |
| | | Bundle bundle = getArguments(); |
| | | mVideoInfo = (VideoInfo) bundle |
| | | .getSerializable("video_info"); |
| | | mPlayingPosition = getArguments().getInt("playing_position"); |
| | | mStart = getArguments().getInt("start"); |
| | | mEnd = getArguments().getInt("end"); |
| | | mPlayingPosition = bundle.getInt("playing_position"); |
| | | mStart = bundle.getInt("start"); |
| | | mEnd = bundle.getInt("end"); |
| | | |
| | | if (bundle != null) |
| | | bundle.clear(); |
| | | |
| | | //防止没有内容崩溃 |
| | | if (mVideoInfo == null) |
| | | return; |
| | | |
| | | tv_video_resource = contentView.findViewById(R.id.tv_video_resource); |
| | | ll_add_attention = contentView.findViewById(R.id.ll_add_attention); |
| | |
| | | tv_update_time = contentView.findViewById(R.id.tv_update_time); |
| | | tv_cancle_follow = contentView.findViewById(R.id.tv_cancle_follow); |
| | | try { |
| | | Glide.with(getActivity().getApplicationContext()).load(mVideoInfo.getAttention().getMoviePicture()).error(R.drawable.ic_default).placeholder(R.drawable.ic_default).centerCrop().into(iv_moive_img); |
| | | Glide.with(getActivity().getApplicationContext()).load(mVideoInfo.getAttention().getMoviePicture()) |
| | | .apply(new RequestOptions().centerCrop().placeholder(R.drawable.ic_default).error(R.drawable.ic_default)) |
| | | .into(iv_moive_img); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | tv_star_name.setText(mVideoInfo.getAttention().getMovieName() + ""); |
| | | tv_update_time.setText(mVideoInfo.getAttention().getUpdateInfo() + ""); |
| | | if (mVideoInfo.getAttention().isAttention()) { |
| | | tv_cancle_follow.setText("已关注"); |
| | | tv_cancle_follow.setBackgroundResource(R.color.gray); |
| | | } else { |
| | | tv_cancle_follow.setText("关注"); |
| | | tv_cancle_follow.setBackgroundResource(R.color.yellow); |
| | | } |
| | | setFollowData(mVideoInfo.getAttention().isAttention()); |
| | | |
| | | tv_cancle_follow.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | |
| | | fl_native_ad1 = contentView |
| | | .findViewById(R.id.fl_native_ad_1); |
| | | rv_episode = contentView.findViewById(R.id.rv_episode); |
| | | if (mVideoInfo.getShowType() == 1) { |
| | | // 综艺或者电影 |
| | | episodeAdapter = new EpisodeNewAdapter(getContext(), mVideoInfo, EpisodeNewAdapter.TYPE_ZONGYI, mPlayingPosition); |
| | | } else if (mVideoInfo.getShowType() == 2) { |
| | | // 电视剧动漫 |
| | | episodeAdapter = new EpisodeNewAdapter(getContext(), mVideoInfo, EpisodeNewAdapter.TYPE_DIANSHIJU, mPlayingPosition); |
| | | } |
| | | LinearLayoutManager ms = new LinearLayoutManager(getContext()); |
| | | ms.setOrientation(LinearLayoutManager.HORIZONTAL); |
| | | |
| | | rv_episode.setLayoutManager(ms); |
| | | //设置间距 |
| | | DividerItemDecoration decoration = new DividerItemDecoration(); |
| | | decoration.setSize(com.weikou.beibeivideo.util.DimenUtils.dip2px(getContext(), 10)); |
| | | rv_episode.addItemDecoration(decoration); |
| | | rv_episode.setAdapter(episodeAdapter); |
| | | |
| | | |
| | | //TODO 点击事件响应 |
| | | // rv_episode.setOnItemClickListener(new OnItemClickListener() { |
| | | // @Override |
| | | // public void onItemClick(AdapterView<?> parent, View view, |
| | | // int position, long id) { |
| | | // VideoDetailInfo videoDetailInfo = (VideoDetailInfo) parent |
| | | // .getItemAtPosition(position); |
| | | // if (selectedUrl == null) { |
| | | // return; |
| | | // } |
| | | // mPlayingPosition = position; |
| | | // episodeAdapter = new EpisodeAdapter(mVideoInfo, |
| | | // mPlayingPosition); |
| | | // episodeAdapter2 = new EpisodeAdapter2(mVideoInfo, |
| | | // mPlayingPosition); |
| | | // refresh(); |
| | | // Playlocation playlocation = new Playlocation(); |
| | | // playlocation.setPosition(position); |
| | | // EventBus.getDefault().post(playlocation); |
| | | // getUrl(videoDetailInfo); |
| | | // } |
| | | // }); |
| | | contentView.findViewById(R.id.iv_share).setOnClickListener(this); |
| | | contentView.findViewById(R.id.iv_offline_cache).setOnClickListener(this); |
| | | fl_report = contentView.findViewById(R.id.fl_report); |
| | | iv_favourite = contentView.findViewById(R.id.iv_add_to_favourite); |
| | | fl_report.setOnClickListener(this); |
| | | iv_favourite.setOnClickListener(this); |
| | | |
| | | loadEpisode(); |
| | | refresh(); |
| | | isCollect(); |
| | | loadAD1(); |
| | | setFrom(mVideoInfo); |
| | | if (VideoUtil.videoEpisodeList != null && VideoUtil.videoEpisodeList.size() > 1) { |
| | | rv_episode.setVisibility(View.VISIBLE); |
| | | } else |
| | | rv_episode.setVisibility(View.GONE); |
| | | |
| | | // |
| | | rv_episode.addOnScrollListener(new RecyclerView.OnScrollListener() { |
| | | @Override |
| | | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { |
| | | super.onScrollStateChanged(recyclerView, newState); |
| | | LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager(); |
| | | int first = manager.findFirstVisibleItemPosition(); |
| | | int last = manager.findLastVisibleItemPosition(); |
| | | int total = manager.getItemCount(); |
| | | if (newState == RecyclerView.SCROLL_STATE_IDLE) { |
| | | if (mVideoInfo == null) |
| | | return; |
| | | if (!episodeLoading && episodeHasMore && last == total - 1) {//加载更多 |
| | | VideoResource checkedResource = null; |
| | | for (VideoResource vr : mVideoInfo.getResourceList()) { |
| | | checkedResource = vr; |
| | | break; |
| | | } |
| | | if (checkedResource != null) { |
| | | loadMoreEpisode(mVideoInfo.getId(), checkedResource.getId(), episodePage); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onScrolled(RecyclerView recyclerView, int dx, final int dy) { |
| | | super.onScrolled(recyclerView, dx, dy); |
| | | } |
| | | }); |
| | | |
| | | |
| | | EventBus.getDefault().register(this); |
| | | } |
| | | |
| | | |
| | | public void onEventMainThread(Playlocation playlocation) { |
| | | mPlayingPosition = playlocation.getPosition(); |
| | | //TODO 重新赋值 |
| | | // episodeAdapter = new EpisodeAdapter(mVideoInfo, |
| | | // mPlayingPosition); |
| | | // loadEpisode(); |
| | | refresh(); |
| | | } |
| | | |
| | | |
| | | public void onEventMainThread(FunshionPlayInfo info) { |
| | | Log.i(TAG, "风行选集:" + info.getPosition()); |
| | | mPlayingPosition = info.getPosition(); |
| | | episodeAdapter.setPlayingPosition(mPlayingPosition); |
| | | refresh(); |
| | | rv_episode.scrollToPosition(mPlayingPosition); |
| | | } |
| | | |
| | | private void addAttention(String uid, String loginId) { |
| | |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SingleToast.showToast(ll_add_attention.getContext(), "添加关注成功!"); |
| | | mVideoInfo.getAttention().setAttention(true); |
| | | tv_cancle_follow.setText("已关注"); |
| | | tv_cancle_follow.setBackgroundColor(getResources().getColor(R.color.gray)); |
| | | setFollowData(mVideoInfo.getAttention().isAttention()); |
| | | |
| | | } |
| | | } |
| | | }); |
| | |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SingleToast.showToast(ll_add_attention.getContext(), "取消关注成功!"); |
| | | mVideoInfo.getAttention().setAttention(false); |
| | | tv_cancle_follow.setText("关注"); |
| | | tv_cancle_follow.setBackgroundColor(getResources().getColor(R.color.yellow)); |
| | | setFollowData(mVideoInfo.getAttention().isAttention()); |
| | | } |
| | | } |
| | | }); |
| | |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | Log.i(TAG, "onResume:"); |
| | | super.onResume(); |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroyView() { |
| | | Log.i(TAG, "onDestroyView:"); |
| | | super.onDestroyView(); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | EventBus.getDefault().unregister(this); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | Log.i(TAG, "onPause"); |
| | | super.onPause(); |
| | | } |
| | | |
| | |
| | | .optString("Url")); |
| | | info.setParams(jsonObject.getJSONObject("Data") |
| | | .optString("Params")); |
| | | info.setAid(jsonObject.getJSONObject("Data") |
| | | .optString("Aid")); |
| | | info.setVid(jsonObject.getJSONObject("Data") |
| | | .optString("Vid")); |
| | | info.setCode(jsonObject.getJSONObject("Data") |
| | | .optString("Code")); |
| | | Play play = new Play(); |
| | | play.setPlayUrl(info); |
| | | EventBus.getDefault().post(play); |
| | |
| | | /** |
| | | * 刷新adapter |
| | | */ |
| | | public void refresh() { |
| | | rv_episode.setAdapter(episodeAdapter); |
| | | public void refresh() { |
| | | if (rv_episode.getAdapter() != null) |
| | | rv_episode.getAdapter().notifyDataSetChanged(); |
| | | else |
| | | rv_episode.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Log.i(TAG, "refresh"); |
| | | rv_episode.setAdapter(episodeAdapter); |
| | | if (mPlayingPosition > 4) |
| | | rv_episode.scrollToPosition(mPlayingPosition); |
| | | } |
| | | }, 500); |
| | | |
| | | |
| | | } |
| | | |
| | | // 加载播放页第一条广告,先设置加载上下文环境和条件 |
| | | private void loadAD1() { |
| | | new ExpressAdManager(ExpressAdManager.SOURCE_GDT, getContext()).loadVideoDetailAd(1, new ExpressAdManager.IAdLoadListener() { |
| | | new ExpressAdManager(AdUtil.AD_TYPE.gdt2, getContext()).loadVideoDetailPlayerBottomAd(new ExpressAdManager.IAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(List<ExpressAdContainer> adList) { |
| | | if (adList != null && adList.size() > 0) { |
| | | fl_native_ad1.setVisibility(View.VISIBLE); |
| | | final ExpressAdContainer ad = adList.get(0); |
| | | if (getActivity() == null) |
| | | return; |
| | | |
| | | ExpressAdManager.render(getActivity(), adList.get(0), fl_native_ad1, new ExpressAdManager.IAdEventListener() { |
| | | @Override |
| | | public void closeAd() { |
| | | fl_native_ad1.removeAllViews(); |
| | | } |
| | | }); |
| | | ExpressAdManager.renderAd(getActivity(), adList.get(0), new ExpressAdManager.IAdRenderListener() { |
| | | @Override |
| | | public void onRenderSuccess(List<ExpressAdContainer> adList) { |
| | | ExpressAdManager.fillAd(adList.get(0), fl_native_ad1); |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail(List<ExpressAdContainer> adList) { |
| | | |
| | | } |
| | | }, new ExpressAdManager.IAdEventListener() { |
| | | @Override |
| | | public void closeAd(ExpressAdContainer ad) { |
| | | fl_native_ad1.removeAllViews(); |
| | | } |
| | | }); |
| | | |
| | | } else { |
| | | //加载穿山甲 |
| | | new ExpressAdManager(AdUtil.AD_TYPE.csj, getContext()).loadVideoDetailPlayerBottomAd(new ExpressAdManager.IAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(List<ExpressAdContainer> adList) { |
| | | if (adList != null && adList.size() > 0) { |
| | | ExpressAdManager.renderAndFillAd(getActivity(), adList.get(0), fl_native_ad1, new ExpressAdManager.IAdEventListener() { |
| | | @Override |
| | | public void closeAd(ExpressAdContainer ad) { |
| | | fl_native_ad1.removeAllViews(); |
| | | } |
| | | }); |
| | | } else { |
| | | fl_native_ad1.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | |
| | | |
| | | public void onEventMainThread(VideoInfo videoInfo) { |
| | | mVideoInfo = videoInfo; |
| | | if (VideoUtil.videoEpisodeList != null && VideoUtil.videoEpisodeList.size() > 1) { |
| | | rv_episode.setVisibility(View.VISIBLE); |
| | | } else |
| | | rv_episode.setVisibility(View.GONE); |
| | | setFrom(videoInfo); |
| | | iv_favourite.setEnabled(true); |
| | | fl_report.setEnabled(true); |
| | | rv_episode.setAdapter(episodeAdapter); |
| | | |
| | | } |
| | | |
| | | private void setFrom(VideoInfo info) { |
| | |
| | | |
| | | ListView lv = new ListView(getContext()); |
| | | ListView.LayoutParams param = new ListView.LayoutParams( |
| | | FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); |
| | | FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); |
| | | lv.setLayoutParams(param); |
| | | lv.setOnItemClickListener(new OnItemClickListener() { |
| | | @Override |
| | |
| | | } |
| | | }); |
| | | lv.setAdapter(new ResourceAdapter(urlList)); |
| | | lv.setDividerHeight(0); |
| | | lv.setDivider(new ColorDrawable(Color.BLACK)); |
| | | lv.setDividerHeight(1); |
| | | popupWindow.setContentView(lv); |
| | | /* |
| | | * Window dialogWindow = dialog.getWindow(); dialogWindow.get |
| | |
| | | public View getView(int position, View convertView, ViewGroup parent) { |
| | | View view = LayoutInflater.from(ll_add_attention.getContext()).inflate( |
| | | R.layout.item_resource, null); |
| | | ImageView iv = (ImageView) view.findViewById(R.id.iv_resource); |
| | | TextView tv = (TextView) view.findViewById(R.id.tv_resource); |
| | | // if (reList.get(position) == null |
| | | // || reList.get(position).getPicture() == null) { |
| | | // ImageLoader.getInstance().displayImage( |
| | | // "drawable://" + R.drawable.from_other, iv); |
| | | // } else { |
| | | // ImageLoader.getInstance().displayImage( |
| | | // reList.get(position).getPicture(), iv, option); |
| | | // } |
| | | 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()) |
| | | .placeholder(R.drawable.from_other) |
| | | .error(R.drawable.from_other).crossFade().into(iv); |
| | | .apply(new RequestOptions().placeholder(R.drawable.from_other).error(R.drawable.from_other)) |
| | | .into(iv); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | .toString(), |
| | | new TypeToken<VideoInfo>() { |
| | | }.getType()); |
| | | if (videoInfo != null) { |
| | | |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application,videoInfo.getVideoDetailList(),false); |
| | | |
| | | } |
| | | // 附加字段 |
| | | if (jsonObject.optJSONObject("Extra1") != null) { |
| | | if (jsonObject.optJSONObject("Extra1").optJSONObject("Attention") != null) { |
| | |
| | | if (extraData != null) |
| | | videoInfo.setExtraData(extraData.toString()); |
| | | |
| | | if (videoInfo.getVideoDetailList() == null |
| | | || videoInfo.getVideoDetailList().isEmpty()) { |
| | | if (VideoUtil.videoEpisodeList == null |
| | | || VideoUtil.videoEpisodeList.isEmpty()) { |
| | | Toast.makeText(getContext(), "影片已删除", |
| | | Toast.LENGTH_LONG).show(); |
| | | getActivity().finish(); |
| | | return; |
| | | } |
| | | |
| | | if (rv_episode.getAdapter() != null) |
| | | rv_episode.getAdapter().notifyDataSetChanged(); |
| | | // videoInfo.setSave(jsonObject.getJSONObject("Data").optBoolean("Save")); |
| | | if (isSetup) { |
| | | mVideoInfo.getVideoDetailList().clear(); |
| | | mVideoInfo.setVideoDetailList(videoInfo |
| | | .getVideoDetailList()); |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application,videoInfo.getVideoDetailList(),false); |
| | | |
| | | EventBus.getDefault().post(videoInfo); |
| | | int position = 0; |
| | | // boolean isFromWatchHistory = false; |
| | |
| | | "playing_position", 0); |
| | | } |
| | | // if (isFromWatchHistory) { |
| | | getUrl(videoInfo.getVideoDetailList().get(position)); |
| | | getUrl(VideoUtil.videoEpisodeList.get(position)); |
| | | EventBus.getDefault() |
| | | .post(videoInfo |
| | | .getVideoDetailList() |
| | | .post(VideoUtil.videoEpisodeList |
| | | .get(position)); |
| | | // } else {// 不是从观看记录点击过来 --跳到当前播放的集数 |
| | | // getUrl(videoInfo.getVideoDetailList().get(position)); |
| | |
| | | public void run() { |
| | | EventBus.getDefault().post(videoInfo); |
| | | EventBus.getDefault().post( |
| | | videoInfo.getVideoDetailList() |
| | | VideoUtil.videoEpisodeList |
| | | .get(0)); |
| | | } |
| | | }, 200); |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 加载更多剧集 |
| | | * |
| | | * @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 |
| | | |
| | | BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws |
| | | Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | JSONObject data = jsonObject.optJSONObject("Data"); |
| | | episodeHasMore = data.optBoolean("hasMore"); |
| | | JSONArray array = data.optJSONArray("list"); |
| | | if (array != null && array.length() > 0) {// |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoDetailInfo> list = gson.fromJson(array.toString(), new TypeToken<List<VideoDetailInfo>>() { |
| | | }.getType()); |
| | | if (list != null && list.size() > 0) { |
| | | episodePage++; |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application,list,true); |
| | | rv_episode.getAdapter().notifyDataSetChanged(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | episodeLoading = true; |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | episodeLoading = false; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onStop() { |
| | | super.onStop(); |
| | | Log.i(TAG, "onStop"); |
| | | } |
| | | |
| | | } |