Skip to content

Commit

Permalink
新增实现拉取视频资源和其他优化
Browse files Browse the repository at this point in the history
新增
1.新增实现拉取视频资源并显示

优化
1.优化了布局层级结构,减少过度绘制
2.优化了数据加载逻辑,数据加载更加流畅快速
3.优化部分上下滑动列表卡顿的问题
  • Loading branch information
zhongzilu committed Dec 1, 2016
1 parent 0a4b020 commit 52978b5
Show file tree
Hide file tree
Showing 16 changed files with 828 additions and 293 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public static Context getAppContext(){
}

public static void setNetworkType(NetworkUtil.Type type){
networkType = type;
if (type == NetworkUtil.Type.NULL) {
isNetworkOK = false;
return;
}
networkType = type;
isNetworkOK = true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.zhongzilu.bit100.application.helper;

import com.zhongzilu.bit100.model.bean.PushModel;
import com.zhongzilu.bit100.model.bean.VideoBean;
import com.zhongzilu.bit100.view.adapter.MainRecyclerViewAdapter;

import java.util.ArrayList;

/**
* 动画视频帮助类
* Created by zhongzilu on 16-12-1.
*/
public class AnimateHelper {

public static ArrayList<PushModel> build(VideoBean[] array){
ArrayList<PushModel> list = new ArrayList<>();
for (VideoBean bean : array){
list.add(AnimateHelper.build(bean));
}
return list;
}

public static PushModel build(VideoBean bean){
return new PushModel(MainRecyclerViewAdapter.TYPE_MAIN_VIDEO_ITEM, bean);
}

// public static ArrayList<VideoBean> build(JSONArray array){
// ArrayList<VideoBean> list = new ArrayList<>();
// for (int i=0; i<array.length(); i++){
// AnimateHelper.build(array.getJSONObject(i));
// }
// return list;
// }
//
// public static VideoBean build(JSONObject animate){
// String id = getValue(animate, "Id");
// String name = getValue(animate, "Name");
// String duration = getValue(animate, "Duration");
// String videoSite = getValue(animate, "VideoSite");
// String originVideoUrl = getValue(animate, "VideoUrl");
// String author = getValue(animate, "Author");
// String year = getValue(animate, "Year");
// String brief = getValue(animate, "Brief");
// String homePic = getValue(animate, "HomePic");
// String detailPic = getValue(animate, "DetailPic");
// JSONObject videoSourceObject = null;
// try {
// videoSourceObject = animate.getJSONObject("VideoSource");
// String uhd = videoSourceObject.has("uhd") ? videoSourceObject.getString("uhd") : null;
// String hd = videoSourceObject.has("hd") ? videoSourceObject.getString("hd") : null;
// String sd = videoSourceObject.has("sd") ? videoSourceObject.getString("sd") : null;
// uhd = uhd.replace(";", "&");
// hd = uhd.replace(";", "&");
// sd = uhd.replace(";", "&");
// } catch (JSONException e) {
//// e.printStackTrace();
// } finally {
// return new VideoBean(id, author, year, duration, originVideoUrl, )
// }
//
// }
//
// public static String getValue(JSONObject obj, String name){
// try {
// obj.getString(name);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// return null;
// }
}
113 changes: 113 additions & 0 deletions app/src/main/java/com/zhongzilu/bit100/model/bean/VideoBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.zhongzilu.bit100.model.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
* 视频对象实体类
* Created by zhongzilu on 16-12-1.
*/
public class VideoBean implements Parcelable{
/**
"Id": "1520",
"Author": "Pierre DUCOS",
"Year": "2014",
"Duration": "08:31",
"VideoUrl": "http://v.youku.com/v_show/id_XODM3OTQ5ODQw.html",
"VideoSite": "youku",
"Brief": "这是一个关于战争的动画短片,看完后,感触很多。战争从来都是残酷的,绝不是糖果与烟花堆积出的和平有趣。短片的前半段很甜美可爱,后半段就灰暗阴沉了,一起来看看吧。",
"HomePic": "http://ww3.sinaimg.cn/large/0066P23Wjw1ern8suixa2j3034034aah.jpg",
"DetailPic": "http://ww2.sinaimg.cn/large/0066P23Wjw1ern8syrd90j30hs07s75l.jpg",
"Player": "http://i.animetaste.net/player/?id=5622",
"ShareLink": "http://aimozhen.com/view/5622/",
"Name": "La Detente(511)",
"VideoSource": {
"uhd": "http://i.animetaste.net/m3u8?originId=XODM3OTQ5ODQw&id=5622",
"hd": "http://i.animetaste.net/m3u8?originId=XODM3OTQ5ODQw&id=5622",
"sd": "http://i.animetaste.net/m3u8?originId=XODM3OTQ5ODQw&id=5622"
}
**/

public String Id,
Author,
Year,
Duration,
VideoUrl,
VideoSite,
Brief,
HomePic,
DetailPic,
Player,
ShareLink,
Name;
public VideoSourceBean VideoSource;

public VideoBean(String id, String author, String year, String duration,
String videoUrl, String videoSite, String brief,
String homePic, String detailPic, String player,
String shareLink, String name, VideoSourceBean videoSource) {
Id = id;
Author = author;
Year = year;
Duration = duration;
VideoUrl = videoUrl;
VideoSite = videoSite;
Brief = brief;
HomePic = homePic;
DetailPic = detailPic;
Player = player;
ShareLink = shareLink;
Name = name;
VideoSource = videoSource;
}

protected VideoBean(Parcel in) {
Id = in.readString();
Author = in.readString();
Year = in.readString();
Duration = in.readString();
VideoUrl = in.readString();
VideoSite = in.readString();
Brief = in.readString();
HomePic = in.readString();
DetailPic = in.readString();
Player = in.readString();
ShareLink = in.readString();
Name = in.readString();
VideoSource = in.readParcelable(VideoSourceBean.class.getClassLoader());
}

public static final Creator<VideoBean> CREATOR = new Creator<VideoBean>() {
@Override
public VideoBean createFromParcel(Parcel in) {
return new VideoBean(in);
}

@Override
public VideoBean[] newArray(int size) {
return new VideoBean[size];
}
};

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(Id);
dest.writeString(Author);
dest.writeString(Year);
dest.writeString(Duration);
dest.writeString(VideoUrl);
dest.writeString(VideoSite);
dest.writeString(Brief);
dest.writeString(HomePic);
dest.writeString(DetailPic);
dest.writeString(Player);
dest.writeString(ShareLink);
dest.writeString(Name);
dest.writeParcelable(VideoSource, flags);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.zhongzilu.bit100.model.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
* Created by zhongzilu on 16-12-1.
*/
public class VideoCategoryBean implements Parcelable{
/**
"id": "1",
"name": "归类无能",
"count": 0
*/

public String id;
public String name;
public int count;

protected VideoCategoryBean(Parcel in) {
id = in.readString();
name = in.readString();
count = in.readInt();
}

public static final Creator<VideoCategoryBean> CREATOR = new Creator<VideoCategoryBean>() {
@Override
public VideoCategoryBean createFromParcel(Parcel in) {
return new VideoCategoryBean(in);
}

@Override
public VideoCategoryBean[] newArray(int size) {
return new VideoCategoryBean[size];
}
};

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeString(name);
dest.writeInt(count);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.zhongzilu.bit100.model.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
* 视频清晰度资源实体类
* Created by zhongzilu on 16-12-1.
*/
public class VideoSourceBean implements Parcelable{
/**
"VideoSource": {
"uhd": "http://i.animetaste.net/m3u8?originId=XODM3OTQ5ODQw&id=5622",
"hd": "http://i.animetaste.net/m3u8?originId=XODM3OTQ5ODQw&id=5622",
"sd": "http://i.animetaste.net/m3u8?originId=XODM3OTQ5ODQw&id=5622"
}
*/
public String uhd,
hd,
sd;

protected VideoSourceBean(Parcel in) {
uhd = in.readString();
hd = in.readString();
sd = in.readString();
}

public static final Creator<VideoSourceBean> CREATOR = new Creator<VideoSourceBean>() {
@Override
public VideoSourceBean createFromParcel(Parcel in) {
return new VideoSourceBean(in);
}

@Override
public VideoSourceBean[] newArray(int size) {
return new VideoSourceBean[size];
}
};

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(uhd);
dest.writeString(hd);
dest.writeString(sd);
}
}
Loading

0 comments on commit 52978b5

Please sign in to comment.