使用方式1
*View直接得到所有数据
1.创建要得到数据Bean
这里一VideoBean
public class VideoBean {
private int start;
private int number;
private int point_time;
private int more;
private List<ListBean> list;
public int getStart() {
return start;
}
public void setStart(int start) {
this.start = start;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public int getPoint_time() {
return point_time;
}
public void setPoint_time(int point_time) {
this.point_time = point_time;
}
public int getMore() {
return more;
}
public void setMore(int more) {
this.more = more;
}
public List<ListBean> getList() {
return list;
}
public void setList(List<ListBean> list) {
this.list = list;
}
public static class ListBean {
/**
* id : 32528
* view_type : 4
* type : 4
* column_name : 施工
* theme : 投资1300亿元的锂电新能源项目在玉林市开工
* description : 70万吨锂电新能源材料一体化产业基地项目落地玉林,将打造当今世界规模最大、产业集聚最高、技术最先进、竞争力最强的锂电新能源材料一体化产业基地,玉林具有毗邻粤港澳大湾区、对接珠三角、面向东南亚的区位优势,具有工业经济发展的无限潜力
* lead : 70万吨锂电项目是自治区重点推进的重大项目,对于进一步强龙头、补链条、聚集群,优化玉林乃至广西产业结构,推动工业高质量发展具有重要的带动、示范和引领作用
* video_is_sans_href : 0
* video_url : https://s.seetao.com/Public/Uploads/video/2020-07-24/5f1a4049d9275.mp4
* video_flow : 8M
* image_url : https://s.seetao.com/Public/Uploads/publicity/2020-07-24/y_0xle0zstrz09z.png
* is_good : 0
* is_collect : 0
* is_comment : 1
* link : https://www.seetao.com/app_details/32528/zh/android/version/2.html
* share_link : https://www.seetao.com/m_details/32528/zh.html
*/
private String id;
private int view_type;
private String type;
private String column_name;
private String theme;
private String description;
private String lead;
private String video_is_sans_href;
private String video_url;
private String video_flow;
private String image_url;
private int is_good;
private int is_collect;
private String is_comment;
private String link;
private String share_link;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getView_type() {
return view_type;
}
public void setView_type(int view_type) {
this.view_type = view_type;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getColumn_name() {
return column_name;
}
public void setColumn_name(String column_name) {
this.column_name = column_name;
}
public String getTheme() {
return theme;
}
public void setTheme(String theme) {
this.theme = theme;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLead() {
return lead;
}
public void setLead(String lead) {
this.lead = lead;
}
public String getVideo_is_sans_href() {
return video_is_sans_href;
}
public void setVideo_is_sans_href(String video_is_sans_href) {
this.video_is_sans_href = video_is_sans_href;
}
public String getVideo_url() {
return video_url;
}
public void setVideo_url(String video_url) {
this.video_url = video_url;
}
public String getVideo_flow() {
return video_flow;
}
public void setVideo_flow(String video_flow) {
this.video_flow = video_flow;
}
public String getImage_url() {
return image_url;
}
public void setImage_url(String image_url) {
this.image_url = image_url;
}
public int getIs_good() {
return is_good;
}
public void setIs_good(int is_good) {
this.is_good = is_good;
}
public int getIs_collect() {
return is_collect;
}
public void setIs_collect(int is_collect) {
this.is_collect = is_collect;
}
public String getIs_comment() {
return is_comment;
}
public void setIs_comment(String is_comment) {
this.is_comment = is_comment;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public String getShare_link() {
return share_link;
}
public void setShare_link(String share_link) {
this.share_link = share_link;
}
}
}
在具体Fra gment使用
/**
* 继承BaseSmartFramgent1<传入需要的得到数据bean类>
* 如果要加载loading页实现ILoadBaseView
*/
public class VideoFragment extends BaseSmartFramgent1<VideoBean> implements ILoadBaseView {
LoadingView loadingView;
// 重写initVeiw 这里操作组件绑定数据
@Override
protected void initVeiw() {
loadData();
}
/**
* 1.创建请求类型
* Get 创建GetRequset对象后缀请求的Url
* POST 创建PostRequset对象后缀请求的Url
* 2.设置请求参数
* 3.设置请求类
* 4.调用doRequest(传入Request对象)
*/
private void loadData() {
GetRequset<VideoBean> requset = new GetRequset<VideoBean>("/app/v_1_6/article/videolist");
requset.setParams(ParamsUtils.getCommonParams());
requset.setType(VideoBean.class);
doRequest(requset);
}
// 绑定Xmlid
@Override
protected int getLayoutId() {
return R.layout.fragment_video;
}
// 绑定View
@Override
protected void bindingView(View view) {
super.bindingView(view);
}
// 得到请求结果
@Override
public void onResult(MvpResponse<VideoBean> data) {
if (data.getCode() == 1) {
// 显示loading
showPopLoading();
Toast.makeText(getActivity(), data.getData().getList().get(1).getShare_link(), Toast.LENGTH_SHORT).show();
// 加载完数据关闭loading
closeLaoding();
} else {
showPopLoading();
Toast.makeText(getActivity(), data.getMsg(), Toast.LENGTH_SHORT).show();
closeLaoding();
}
}
@Override
public <T extends View> T findViewById(int id) {
return null;
}
// 设置loadingView页面
@Override
public void setLoadingView(LoadingView loadingView) {
this.loadingView = loadingView;
}
// 返回loadingView页面便于在接口操作
@Override
public LoadingView getLoadingView() {
return loadingView;
}
// 是否加入回退栈
@Override
public boolean isNeedAddToBackStacl() {
return false;
}
// 处理上一个Framgment
@Override
public Action handPerFragment() {
return Action.NONE;
}
}
使用方式2
- 重写model层对数据进行处理
网友评论