IntroduceFragment.java
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package com.hh.xuetubao.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.TextView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.adapter.IntroduceGridAdapter;
import com.hh.xuetubao.bean.CourseDetailInfoBean;
import com.hh.xuetubao.bean.Event;
import com.hh.xuetubao.model.LearnModel;
import com.hh.xuetubao.mvp.BaseMvpFragment;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
/**
* 介绍Fragment
*/
public class IntroduceFragment extends BaseMvpFragment<CommonPresenter, LearnModel> implements ICommonView {
Unbinder unbinder;
@BindView(R.id.tv_title)
TextView tvTitle;
@BindView(R.id.tv_count_people)
TextView tvCount;
@BindView(R.id.tv_sort)
TextView tvSort;
@BindView(R.id.tv_jianjie_show)
TextView tvJianjieShow;
@BindView(R.id.gridview)
GridView gridview;
private String lessonOid;
private LearnModel model;
private List<String> list = new ArrayList<>();
private IntroduceGridAdapter gridAdapter;
@Override
public int getLayoutId() {
return R.layout.fragment_introduce;
}
@Override
public void initView(@Nullable Bundle savedInstanceState) {
lessonOid = getTag();
tvTitle.setFocusable(true);
tvTitle.setFocusableInTouchMode(true);
tvTitle.requestFocus();
gridAdapter = new IntroduceGridAdapter(list, getActivity());
gridview.setAdapter(gridAdapter);
}
@Override
public void initData() {
model = new LearnModel();
model.getModel(this, 2, 1, lessonOid);
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public LearnModel getModel() {
return new LearnModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 2 && intent == 1) {
CourseDetailInfoBean bean = (CourseDetailInfoBean) o;
Log.e("zhangtao", bean.toString());
tvCount.setText(bean.getLearningPeopleCount());
if (bean.getLessonName() != null)
tvTitle.setText(bean.getLessonName());
if (bean.getDifficult() != null)
tvSort.setText(bean.getDifficult());
if (bean.getLessonDesc() != null)
tvJianjieShow.setText(bean.getLessonDesc());
if (bean.getSkillLst() != null)
list.addAll(bean.getSkillLst());
gridAdapter.notifyDataSetChanged();
if (bean.getLessonCoverUrl() != null) {
Event event = new Event(2, null, null, null, null, bean.getLessonCoverUrl());
EventBus.getDefault().postSticky(event);
}
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// TODO: inflate a fragment view
View rootView = super.onCreateView(inflater, container, savedInstanceState);
unbinder = ButterKnife.bind(this, rootView);
return rootView;
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
}