Commit 81d7f8c8174155b8ef2318efef2b8292b6031815
1 parent
d878a8a1
Exists in
yxb_dev
and in
2 other branches
no message
Showing
10 changed files
with
225 additions
and
107 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/AppContext.java
... | ... | @@ -3,18 +3,17 @@ package com.shunzhi.parent; |
3 | 3 | import android.content.Context; |
4 | 4 | import android.content.Intent; |
5 | 5 | import android.content.SharedPreferences; |
6 | -import android.util.Log; | |
7 | 6 | |
8 | 7 | import com.amap.api.location.AMapLocation; |
9 | 8 | import com.amap.api.location.AMapLocationClient; |
10 | 9 | import com.amap.api.location.AMapLocationClientOption; |
10 | +import com.amap.api.location.AMapLocationClientOption.AMapLocationMode; | |
11 | 11 | import com.amap.api.location.AMapLocationListener; |
12 | 12 | import com.netease.nimlib.sdk.NIMClient; |
13 | 13 | import com.netease.nimlib.sdk.SDKOptions; |
14 | 14 | import com.netease.nimlib.sdk.StatusBarNotificationConfig; |
15 | 15 | import com.netease.nimlib.sdk.auth.LoginInfo; |
16 | 16 | import com.share.mvpsdk.global.GlobalApplication; |
17 | -import com.amap.api.location.AMapLocationClientOption.AMapLocationMode; | |
18 | 17 | |
19 | 18 | /** |
20 | 19 | * Created by Administrator on 2018/3/7 0007. |
... | ... | @@ -137,7 +136,8 @@ public class AppContext extends GlobalApplication { |
137 | 136 | sendBroadcast(intent); |
138 | 137 | stopLocation(); |
139 | 138 | } else { |
140 | - cityName = "定位失败"; | |
139 | + cityName = "定位失败";district="定位失败"; | |
140 | + | |
141 | 141 | // Log.d("mlocation:","errorCode="+aMapLocation.getErrorCode()+"errorInfo="+aMapLocation.getErrorInfo()); |
142 | 142 | } |
143 | 143 | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/consult/ConsultTwoLevelActivity.java
... | ... | @@ -2,22 +2,19 @@ package com.shunzhi.parent.ui.activity.consult; |
2 | 2 | |
3 | 3 | import android.content.Context; |
4 | 4 | import android.content.Intent; |
5 | -import android.support.annotation.NonNull; | |
6 | 5 | import android.os.Bundle; |
7 | -import android.support.v7.widget.RecyclerView; | |
6 | +import android.support.annotation.NonNull; | |
7 | +import android.support.v4.app.FragmentTransaction; | |
8 | 8 | import android.view.View; |
9 | 9 | import android.widget.EditText; |
10 | +import android.widget.FrameLayout; | |
10 | 11 | import android.widget.ImageView; |
11 | -import android.widget.TextView; | |
12 | 12 | |
13 | 13 | import com.share.mvpsdk.base.BasePresenter; |
14 | 14 | import com.share.mvpsdk.base.activity.BaseMVPCompatActivity; |
15 | +import com.share.mvpsdk.utils.ToastUtils; | |
15 | 16 | import com.shunzhi.parent.R; |
16 | -import com.shunzhi.parent.adapter.MyConsultAdapter; | |
17 | -import com.shunzhi.parent.bean.MyConsultBean; | |
18 | - | |
19 | -import java.util.ArrayList; | |
20 | -import java.util.List; | |
17 | +import com.shunzhi.parent.ui.fragment.consult.ConsultTwoLevelFragment; | |
21 | 18 | |
22 | 19 | public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements View.OnClickListener { |
23 | 20 | |
... | ... | @@ -32,6 +29,13 @@ public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements Vi |
32 | 29 | EditText et_search; |
33 | 30 | |
34 | 31 | String channel; |
32 | + | |
33 | + FrameLayout frame_consult; | |
34 | + | |
35 | + ConsultTwoLevelFragment consultTwoLevelFragment; | |
36 | + | |
37 | + FragmentTransaction fragmentTransaction=null; | |
38 | + | |
35 | 39 | @Override |
36 | 40 | protected void initView(Bundle savedInstanceState) { |
37 | 41 | initViews(); |
... | ... | @@ -45,13 +49,22 @@ public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements Vi |
45 | 49 | |
46 | 50 | private void initViews() { |
47 | 51 | channel=getIntent().getStringExtra("channel"); |
48 | - ivBack = findViewById(R.id.ivBack); | |
49 | - ivBack.setOnClickListener(this); | |
50 | - | |
51 | - et_search = findViewById(R.id.et_search); | |
52 | + consultTwoLevelFragment=new ConsultTwoLevelFragment(); | |
53 | + et_search=findViewById(R.id.et_search); | |
54 | + ivSearch=findViewById(R.id.ivSearch); | |
55 | + ivBack=findViewById(R.id.ivBack); | |
56 | + frame_consult=findViewById(R.id.frame_consult); | |
52 | 57 | |
53 | - ivSearch = findViewById(R.id.ivSearch); | |
54 | 58 | ivSearch.setOnClickListener(this); |
59 | + ivBack.setOnClickListener(this); | |
60 | + | |
61 | + Bundle bundle=new Bundle(); | |
62 | + bundle.putString("channel",channel); | |
63 | + consultTwoLevelFragment.setArguments(bundle); | |
64 | + ToastUtils.showToast("channel="+channel); | |
65 | + fragmentTransaction=getSupportFragmentManager().beginTransaction(); | |
66 | + fragmentTransaction.add(R.id.frame_consult,consultTwoLevelFragment) | |
67 | + .show(consultTwoLevelFragment).commit(); | |
55 | 68 | |
56 | 69 | } |
57 | 70 | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/ConsultFragment.java
... | ... | @@ -8,13 +8,14 @@ import android.os.Bundle; |
8 | 8 | import android.support.annotation.NonNull; |
9 | 9 | import android.support.annotation.Nullable; |
10 | 10 | import android.support.v7.widget.LinearLayoutManager; |
11 | -import android.support.v7.widget.RecyclerView; | |
11 | +import android.util.Log; | |
12 | 12 | import android.view.View; |
13 | 13 | import android.widget.ImageView; |
14 | 14 | import android.widget.LinearLayout; |
15 | 15 | import android.widget.TextView; |
16 | 16 | |
17 | 17 | import com.bumptech.glide.Glide; |
18 | +import com.jcodecraeer.xrecyclerview.XRecyclerView; | |
18 | 19 | import com.share.mvpsdk.base.BasePresenter; |
19 | 20 | import com.share.mvpsdk.base.fragment.BaseMVPCompatFragment; |
20 | 21 | import com.shunzhi.parent.AppConfig; |
... | ... | @@ -46,7 +47,7 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
46 | 47 | |
47 | 48 | XBanner xBanner; |
48 | 49 | |
49 | - RecyclerView recycler_context; | |
50 | + XRecyclerView recycler_context; | |
50 | 51 | |
51 | 52 | ContextAdapter contextAdapter; |
52 | 53 | |
... | ... | @@ -62,6 +63,9 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
62 | 63 | |
63 | 64 | CityPicker cityPicker = null; |
64 | 65 | |
66 | + int pageIndex = 1; | |
67 | + boolean first = true; | |
68 | + | |
65 | 69 | @Override |
66 | 70 | public int getLayoutId() { |
67 | 71 | return R.layout.fragment_zi_xun; |
... | ... | @@ -79,14 +83,16 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
79 | 83 | tvLocalAddress = view.findViewById(R.id.tvLocalAddress); |
80 | 84 | layout_control = view.findViewById(R.id.layout_control); |
81 | 85 | |
82 | - tvLocalAddress.setText(AppContext.getInstance().cityName); | |
86 | + Log.e("aaasasas",AppContext.getInstance().district); | |
87 | + | |
88 | + tvLocalAddress.setText(AppContext.getInstance().district); | |
83 | 89 | videoplayer.batteryLevel.setVisibility(View.GONE); |
84 | 90 | videoplayer.replayTextView.setVisibility(View.GONE); |
85 | 91 | videoplayer.backButton.setVisibility(View.GONE); |
86 | 92 | |
87 | 93 | // mPresenter.getTools(layout_control); |
88 | 94 | mPresenter.getBanners("2", AppContext.getInstance().district); |
89 | - mPresenter.getContextChannel(AppContext.getInstance().district, 0, 1, 1); | |
95 | + | |
90 | 96 | |
91 | 97 | initBroadCast(); |
92 | 98 | |
... | ... | @@ -95,8 +101,27 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
95 | 101 | |
96 | 102 | private void initRecycler() { |
97 | 103 | recycler_context.setLayoutManager(new LinearLayoutManager(getActivity())); |
98 | - contextAdapter = new ContextAdapter(getActivity()); | |
104 | +// contextAdapter = new ContextAdapter(getActivity()); | |
105 | + recycler_context.setLoadingListener(new XRecyclerView.LoadingListener() { | |
106 | + @Override | |
107 | + public void onRefresh() { | |
108 | + //refresh data here | |
109 | + pageIndex = 1; | |
110 | + contextList.clear(); | |
111 | + mPresenter.getContextChannel(AppContext.getInstance().district, 0, 1, pageIndex); | |
112 | + recycler_context.refreshComplete(); | |
113 | + } | |
99 | 114 | |
115 | + @Override | |
116 | + public void onLoadMore() { | |
117 | + // load more data here | |
118 | + pageIndex = pageIndex + 1; | |
119 | + mPresenter.getContextChannel(AppContext.getInstance().district, 0, 1, pageIndex); | |
120 | + recycler_context.refreshComplete(); | |
121 | + } | |
122 | + }); | |
123 | + pageIndex = 1; | |
124 | + mPresenter.getContextChannel(AppContext.getInstance().district, 0, 1, pageIndex); | |
100 | 125 | } |
101 | 126 | |
102 | 127 | private void initListeners() { |
... | ... | @@ -117,7 +142,7 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
117 | 142 | xBanner.setOnItemClickListener(new XBanner.OnItemClickListener() { |
118 | 143 | @Override |
119 | 144 | public void onItemClick(XBanner banner, int position) { |
120 | - WebViewActivity.getInstance(getContext(),imgesUrl.get(position),-1); | |
145 | + WebViewActivity.getInstance(getContext(), imgesUrl.get(position), -1); | |
121 | 146 | } |
122 | 147 | }); |
123 | 148 | |
... | ... | @@ -169,7 +194,7 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
169 | 194 | @Override |
170 | 195 | public void onReceive(Context context, Intent intent) { |
171 | 196 | if (intent.getAction().equals(AppContext.LOCATION_CITYNAME + "")) { |
172 | - tvLocalAddress.setText(AppContext.getInstance().cityName); | |
197 | + tvLocalAddress.setText(AppContext.getInstance().district); | |
173 | 198 | } |
174 | 199 | } |
175 | 200 | }; |
... | ... | @@ -197,47 +222,54 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
197 | 222 | |
198 | 223 | @Override |
199 | 224 | public void showChannel(final List<ChannelBean> list) { |
200 | - for (int i = 0; i < list.size(); i++) { | |
201 | - TextAndImgShowView textAndImgShowView = new TextAndImgShowView(getActivity()); | |
202 | - textAndImgShowView.setTextColor(R.color.textColor); | |
203 | - textAndImgShowView.setText(list.get(i).getChannelName()); | |
225 | + if (first) { | |
226 | + layout_control.removeAllViews(); | |
227 | + for (int i = 0; i < list.size(); i++) { | |
228 | + TextAndImgShowView textAndImgShowView = new TextAndImgShowView(getActivity()); | |
229 | + textAndImgShowView.setTextColor(R.color.textColor); | |
230 | + textAndImgShowView.setText(list.get(i).getChannelName()); | |
204 | 231 | // textAndImgShowView.setImgs(R.drawable.play, Integer.parseInt(list.get(i).getChannelImage())); |
205 | - textAndImgShowView.addImgs(list.get(i).getChannelImage()); | |
206 | - textAndImgShowView.setSelect(true); | |
207 | - textAndImgShowView.setWidth(getActivity(), layout_control); | |
208 | - textAndImgShowView.setBackground(AttrsUtils.getAttrs(getActivity()).getDrawable(0)); | |
209 | - textAndImgShowView.setTag(list.get(i)); | |
210 | - textAndImgShowView.setOnClickListener(new View.OnClickListener() { | |
211 | - @Override | |
212 | - public void onClick(View view) { | |
213 | - ChannelBean channelBean= (ChannelBean) view.getTag(); | |
214 | - ConsultOneLevelActivity.getInstance(getActivity(),channelBean.getId()+""); | |
215 | - } | |
216 | - }); | |
217 | - layout_control.addView(textAndImgShowView); | |
232 | + textAndImgShowView.addImgs(list.get(i).getChannelImage()); | |
233 | + textAndImgShowView.setSelect(true); | |
234 | + textAndImgShowView.setWidth(getActivity(), layout_control); | |
235 | + textAndImgShowView.setBackground(AttrsUtils.getAttrs(getActivity()).getDrawable(0)); | |
236 | + textAndImgShowView.setTag(list.get(i)); | |
237 | + textAndImgShowView.setOnClickListener(new View.OnClickListener() { | |
238 | + @Override | |
239 | + public void onClick(View view) { | |
240 | + ChannelBean channelBean = (ChannelBean) view.getTag(); | |
241 | + ConsultOneLevelActivity.getInstance(getActivity(), channelBean.getId() + ""); | |
242 | + } | |
243 | + }); | |
244 | + layout_control.addView(textAndImgShowView); | |
245 | + } | |
246 | + first = false; | |
218 | 247 | } |
219 | 248 | |
220 | 249 | |
221 | - | |
222 | - | |
223 | 250 | } |
224 | 251 | |
225 | 252 | @Override |
226 | 253 | public void showContext(List<ChannelContextBean> list) { |
227 | - contextList.clear(); | |
254 | + Log.e("aaaadxasdas-===", "111111"); | |
228 | 255 | contextList.addAll(list); |
229 | - contextAdapter.addAll(contextList); | |
230 | - recycler_context.setAdapter(contextAdapter); | |
231 | - | |
232 | - | |
256 | + if (contextAdapter == null) { | |
257 | + contextAdapter = new ContextAdapter(getActivity()); | |
258 | + contextAdapter.addAll(contextList); | |
259 | + recycler_context.setAdapter(contextAdapter); | |
260 | + } else { | |
261 | + contextAdapter.addAll(contextList); | |
262 | + contextAdapter.notifyDataSetChanged(); | |
263 | + } | |
233 | 264 | } |
234 | 265 | |
235 | 266 | @Override |
236 | 267 | public void getCity(String name) { |
268 | + first=true; | |
237 | 269 | tvLocalAddress.setText(name.split(" ")[1]); |
238 | 270 | mPresenter.getBanners("2", name.split(" ")[2]); |
239 | 271 | mPresenter.getContextChannel(name.split(" ")[2], 0, 1, 1); |
240 | - AppContext.getInstance().cityName=name.split(" ")[1]; | |
241 | - AppContext.getInstance().district=name.split(" ")[2]; | |
272 | + AppContext.getInstance().cityName = name.split(" ")[1]; | |
273 | + AppContext.getInstance().district = name.split(" ")[2]; | |
242 | 274 | } |
243 | 275 | } | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/consult/ConsultOneLevelFragment.java
... | ... | @@ -5,7 +5,6 @@ import android.support.annotation.NonNull; |
5 | 5 | import android.support.annotation.Nullable; |
6 | 6 | import android.support.v7.widget.LinearLayoutManager; |
7 | 7 | import android.support.v7.widget.RecyclerView; |
8 | -import android.util.Log; | |
9 | 8 | import android.view.LayoutInflater; |
10 | 9 | import android.view.View; |
11 | 10 | import android.view.ViewGroup; |
... | ... | @@ -15,6 +14,7 @@ import android.widget.LinearLayout; |
15 | 14 | import android.widget.TextView; |
16 | 15 | |
17 | 16 | import com.bumptech.glide.Glide; |
17 | +import com.jcodecraeer.xrecyclerview.XRecyclerView; | |
18 | 18 | import com.share.mvpsdk.base.BasePresenter; |
19 | 19 | import com.share.mvpsdk.base.adapter.BaseRecyclerViewAdapter; |
20 | 20 | import com.share.mvpsdk.base.adapter.BaseRecyclerViewHolder; |
... | ... | @@ -26,22 +26,22 @@ import com.shunzhi.parent.AppContext; |
26 | 26 | import com.shunzhi.parent.R; |
27 | 27 | import com.shunzhi.parent.adapter.MyConsultAdapter; |
28 | 28 | import com.shunzhi.parent.bean.GuangGaoBean; |
29 | -import com.shunzhi.parent.bean.MyConsultBean; | |
30 | 29 | import com.shunzhi.parent.bean.channel.ChannelBean; |
31 | 30 | import com.shunzhi.parent.bean.channel.ChannelContextBean; |
32 | 31 | import com.shunzhi.parent.contract.consult.consultone.ConsultOneContract; |
33 | 32 | import com.shunzhi.parent.presenter.consult.consultone.ConsultOnePresenter; |
34 | -import com.shunzhi.parent.ui.activity.consult.ConsultOneLevelActivity; | |
35 | 33 | import com.shunzhi.parent.ui.activity.consult.ConsultTwoLevelActivity; |
36 | 34 | import com.shunzhi.parent.util.AttrsUtils; |
37 | 35 | import com.shunzhi.parent.views.TextAndImgShowView; |
38 | 36 | |
37 | +import java.util.ArrayList; | |
39 | 38 | import java.util.List; |
40 | 39 | |
41 | 40 | public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneContract.ConsultOnePresenter, |
42 | 41 | ConsultOneContract.IConsultOneModel> implements View.OnClickListener, ConsultOneContract.IConsultOneView { |
43 | 42 | |
44 | - RecyclerView recyclerViewGrally, recyclerViewConsultOne; | |
43 | + RecyclerView recyclerViewGrally; | |
44 | + XRecyclerView recyclerViewConsultOne; | |
45 | 45 | |
46 | 46 | MyGrallyAdapter myGrallyAdapter = null; |
47 | 47 | |
... | ... | @@ -49,9 +49,11 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
49 | 49 | |
50 | 50 | LinearLayout layout_control; |
51 | 51 | |
52 | - List<MyConsultBean> myConsultBeanList = null; | |
52 | + List<ChannelContextBean> myConsultBeanList = new ArrayList<>(); | |
53 | + boolean first=true; | |
53 | 54 | |
54 | - String channel=""; | |
55 | + String channel = ""; | |
56 | + int pageIndex; | |
55 | 57 | |
56 | 58 | @Override |
57 | 59 | public int getLayoutId() { |
... | ... | @@ -60,7 +62,7 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
60 | 62 | |
61 | 63 | @Override |
62 | 64 | public void initUI(View view, @Nullable Bundle savedInstanceState) { |
63 | - initViews(view); | |
65 | + initViews(view); | |
64 | 66 | } |
65 | 67 | |
66 | 68 | private void initRecyclerView(List<GuangGaoBean> guangGaoBeanList) { |
... | ... | @@ -83,16 +85,37 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
83 | 85 | } |
84 | 86 | |
85 | 87 | private void initViews(View view) { |
86 | - channel=getArguments().getString("channel"); | |
88 | + channel = getArguments().getString("channel"); | |
87 | 89 | ToastUtils.showToast(channel); |
88 | 90 | layout_control = view.findViewById(R.id.layout_control); |
89 | 91 | layout_control.measure(0, 0); |
90 | 92 | // mPresenter.getTools(layout_control); |
91 | 93 | recyclerViewGrally = view.findViewById(R.id.recyclerViewGrally); |
92 | 94 | recyclerViewConsultOne = view.findViewById(R.id.recyclerViewConsultOne); |
95 | + recyclerViewConsultOne.setLayoutManager(new LinearLayoutManager(getActivity())); | |
96 | + recyclerViewConsultOne.setLoadingListener(new XRecyclerView.LoadingListener() { | |
97 | + @Override | |
98 | + public void onRefresh() { | |
99 | + //refresh data here | |
100 | + pageIndex = 1; | |
101 | + myConsultBeanList.clear(); | |
102 | + mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, pageIndex); | |
103 | + recyclerViewConsultOne.refreshComplete(); | |
104 | + } | |
105 | + | |
106 | + @Override | |
107 | + public void onLoadMore() { | |
108 | + // load more data here | |
109 | + pageIndex = pageIndex + 1; | |
110 | + mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, pageIndex); | |
111 | + recyclerViewConsultOne.refreshComplete(); | |
112 | + } | |
113 | + }); | |
114 | + pageIndex = 1; | |
115 | + mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, pageIndex); | |
93 | 116 | |
94 | 117 | mPresenter.getBanners("3", AppContext.getInstance().district); |
95 | - mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, 1); | |
118 | + | |
96 | 119 | // initRecyclerViewConsult(); |
97 | 120 | } |
98 | 121 | |
... | ... | @@ -137,31 +160,43 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
137 | 160 | |
138 | 161 | @Override |
139 | 162 | public void showConsultContent(List<ChannelContextBean> list) { |
140 | - if (null == myConsultAdapter) myConsultAdapter = new MyConsultAdapter(getActivity()); | |
141 | - myConsultAdapter.addAll(list); | |
142 | - recyclerViewConsultOne.setAdapter(myConsultAdapter); | |
163 | + myConsultBeanList.addAll(list); | |
164 | + if (myConsultAdapter == null) { | |
165 | + myConsultAdapter = new MyConsultAdapter(getActivity()); | |
166 | + myConsultAdapter.addAll(myConsultBeanList); | |
167 | + recyclerViewConsultOne.setAdapter(myConsultAdapter); | |
168 | + } else { | |
169 | + myConsultAdapter.addAll(myConsultBeanList); | |
170 | + myConsultAdapter.notifyDataSetChanged(); | |
171 | + } | |
172 | +// if (null == myConsultAdapter) myConsultAdapter = new MyConsultAdapter(getActivity()); | |
173 | +// myConsultAdapter.addAll(list); | |
174 | +// recyclerViewConsultOne.setAdapter(myConsultAdapter); | |
143 | 175 | } |
144 | 176 | |
145 | 177 | @Override |
146 | 178 | public void showChannel(List<ChannelBean> list) { |
147 | - for (int i = 0; i < list.size(); i++) { | |
148 | - TextAndImgShowView textAndImgShowView = new TextAndImgShowView(getActivity()); | |
149 | - textAndImgShowView.setTextColor(R.color.textColor); | |
150 | - textAndImgShowView.setText(list.get(i).getChannelName()); | |
179 | + if(first) { | |
180 | + for (int i = 0; i < list.size(); i++) { | |
181 | + TextAndImgShowView textAndImgShowView = new TextAndImgShowView(getActivity()); | |
182 | + textAndImgShowView.setTextColor(R.color.textColor); | |
183 | + textAndImgShowView.setText(list.get(i).getChannelName()); | |
151 | 184 | // textAndImgShowView.setImgs(R.drawable.play, Integer.parseInt(list.get(i).getChannelImage())); |
152 | - textAndImgShowView.addImgs(list.get(i).getChannelImage()); | |
153 | - textAndImgShowView.setSelect(true); | |
154 | - textAndImgShowView.setWidth(getActivity(), layout_control); | |
155 | - textAndImgShowView.setBackground(AttrsUtils.getAttrs(getActivity()).getDrawable(0)); | |
156 | - textAndImgShowView.setTag(list.get(i)); | |
157 | - textAndImgShowView.setOnClickListener(new View.OnClickListener() { | |
158 | - @Override | |
159 | - public void onClick(View view) { | |
160 | - ChannelBean channelBean= (ChannelBean) view.getTag(); | |
161 | - ConsultTwoLevelActivity.getInstance(getActivity(),channelBean.getId()+""); | |
162 | - } | |
163 | - }); | |
164 | - layout_control.addView(textAndImgShowView); | |
185 | + textAndImgShowView.addImgs(list.get(i).getChannelImage()); | |
186 | + textAndImgShowView.setSelect(true); | |
187 | + textAndImgShowView.setWidth(getActivity(), layout_control); | |
188 | + textAndImgShowView.setBackground(AttrsUtils.getAttrs(getActivity()).getDrawable(0)); | |
189 | + textAndImgShowView.setTag(list.get(i)); | |
190 | + textAndImgShowView.setOnClickListener(new View.OnClickListener() { | |
191 | + @Override | |
192 | + public void onClick(View view) { | |
193 | + ChannelBean channelBean = (ChannelBean) view.getTag(); | |
194 | + ConsultTwoLevelActivity.getInstance(getActivity(), channelBean.getId() + ""); | |
195 | + } | |
196 | + }); | |
197 | + layout_control.addView(textAndImgShowView); | |
198 | + } | |
199 | + first=false; | |
165 | 200 | } |
166 | 201 | } |
167 | 202 | |
... | ... | @@ -199,8 +234,8 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
199 | 234 | |
200 | 235 | @Override |
201 | 236 | public void onBindViewHolder(GuangGaoBean object, int position) { |
202 | - Glide.with(getActivity()).load(AppConfig.BASE_URL_IMG+object.fileSrc).error(R.drawable.ic_launcher_foreground).into(iv_grally); | |
203 | - tv_grally_title.setText(object.describe+""); | |
237 | + Glide.with(getActivity()).load(AppConfig.BASE_URL_IMG + object.fileSrc).error(R.drawable.ic_launcher_foreground).into(iv_grally); | |
238 | + tv_grally_title.setText(object.describe + ""); | |
204 | 239 | } |
205 | 240 | } |
206 | 241 | } | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/consult/ConsultTwoLevelFragment.java
... | ... | @@ -3,16 +3,17 @@ package com.shunzhi.parent.ui.fragment.consult; |
3 | 3 | import android.os.Bundle; |
4 | 4 | import android.support.annotation.NonNull; |
5 | 5 | import android.support.annotation.Nullable; |
6 | -import android.support.v7.widget.RecyclerView; | |
6 | +import android.support.v7.widget.LinearLayoutManager; | |
7 | 7 | import android.view.View; |
8 | 8 | import android.widget.TextView; |
9 | 9 | |
10 | +import com.jcodecraeer.xrecyclerview.XRecyclerView; | |
10 | 11 | import com.share.mvpsdk.base.BasePresenter; |
11 | 12 | import com.share.mvpsdk.base.fragment.BaseMVPCompatFragment; |
13 | +import com.shunzhi.parent.AppContext; | |
12 | 14 | import com.shunzhi.parent.R; |
13 | 15 | import com.shunzhi.parent.adapter.MyConsultAdapter; |
14 | 16 | import com.shunzhi.parent.bean.GuangGaoBean; |
15 | -import com.shunzhi.parent.bean.MyConsultBean; | |
16 | 17 | import com.shunzhi.parent.bean.channel.ChannelBean; |
17 | 18 | import com.shunzhi.parent.bean.channel.ChannelContextBean; |
18 | 19 | import com.shunzhi.parent.contract.consult.consultone.ConsultOneContract; |
... | ... | @@ -29,11 +30,14 @@ public class ConsultTwoLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
29 | 30 | |
30 | 31 | TextView tvContentName; |
31 | 32 | |
32 | - RecyclerView recyclerView; | |
33 | + XRecyclerView recyclerView; | |
33 | 34 | |
34 | 35 | MyConsultAdapter myConsultAdapter = null; |
35 | 36 | |
36 | - List<MyConsultBean> myConsultBeanList = new ArrayList<>(); | |
37 | + List<ChannelContextBean> myConsultBeanList = new ArrayList<>(); | |
38 | + | |
39 | + int pageIndex = 1; | |
40 | + String channel; | |
37 | 41 | |
38 | 42 | @Override |
39 | 43 | public int getLayoutId() { |
... | ... | @@ -44,8 +48,30 @@ public class ConsultTwoLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
44 | 48 | public void initUI(View view, @Nullable Bundle savedInstanceState) { |
45 | 49 | tvContentName = view.findViewById(R.id.tvContentName); |
46 | 50 | tvContentName.setText(""); |
47 | - | |
48 | 51 | recyclerView = view.findViewById(R.id.recyclerView); |
52 | + channel = getArguments().getString("channel"); | |
53 | + recyclerView = view.findViewById(R.id.recyclerViewConsultOne); | |
54 | + recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); | |
55 | + recyclerView.setLoadingListener(new XRecyclerView.LoadingListener() { | |
56 | + @Override | |
57 | + public void onRefresh() { | |
58 | + //refresh data here | |
59 | + pageIndex = 1; | |
60 | + myConsultBeanList.clear(); | |
61 | + mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, pageIndex); | |
62 | + recyclerView.refreshComplete(); | |
63 | + } | |
64 | + | |
65 | + @Override | |
66 | + public void onLoadMore() { | |
67 | + // load more data here | |
68 | + pageIndex = pageIndex + 1; | |
69 | + mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, pageIndex); | |
70 | + recyclerView.refreshComplete(); | |
71 | + } | |
72 | + }); | |
73 | + pageIndex = 1; | |
74 | + mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, pageIndex); | |
49 | 75 | |
50 | 76 | // initRecyclerView(); |
51 | 77 | } |
... | ... | @@ -83,7 +109,15 @@ public class ConsultTwoLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
83 | 109 | |
84 | 110 | @Override |
85 | 111 | public void showConsultContent(List<ChannelContextBean> list) { |
86 | - | |
112 | + myConsultBeanList.addAll(list); | |
113 | + if (myConsultAdapter == null) { | |
114 | + myConsultAdapter = new MyConsultAdapter(getActivity()); | |
115 | + myConsultAdapter.addAll(myConsultBeanList); | |
116 | + recyclerView.setAdapter(myConsultAdapter); | |
117 | + } else { | |
118 | + myConsultAdapter.addAll(myConsultBeanList); | |
119 | + myConsultAdapter.notifyDataSetChanged(); | |
120 | + } | |
87 | 121 | } |
88 | 122 | |
89 | 123 | @Override |
... | ... | @@ -92,5 +126,4 @@ public class ConsultTwoLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
92 | 126 | } |
93 | 127 | |
94 | 128 | |
95 | - | |
96 | 129 | } | ... | ... |
app/src/main/res/layout/activity_consult_two_level.xml
... | ... | @@ -9,5 +9,9 @@ |
9 | 9 | tools:context="com.shunzhi.parent.ui.activity.consult.ConsultTwoLevelActivity"> |
10 | 10 | |
11 | 11 | <include layout="@layout/layout_search_back"/> |
12 | - | |
12 | + <FrameLayout | |
13 | + android:layout_width="match_parent" | |
14 | + android:layout_height="match_parent" | |
15 | + android:id="@+id/frame_consult" | |
16 | + ></FrameLayout> | |
13 | 17 | </LinearLayout> | ... | ... |
app/src/main/res/layout/fragment_consult_one_level.xml
... | ... | @@ -19,12 +19,12 @@ |
19 | 19 | |
20 | 20 | <include layout="@layout/layout_textandimgshow"/> |
21 | 21 | |
22 | - <android.support.v7.widget.RecyclerView | |
22 | + <com.jcodecraeer.xrecyclerview.XRecyclerView | |
23 | 23 | android:layout_marginTop="@dimen/size_dp_10" |
24 | 24 | android:layout_width="match_parent" |
25 | 25 | android:layout_height="0dp" |
26 | 26 | android:layout_weight="3" |
27 | 27 | android:id="@+id/recyclerViewConsultOne" |
28 | - ></android.support.v7.widget.RecyclerView> | |
28 | + ></com.jcodecraeer.xrecyclerview.XRecyclerView> | |
29 | 29 | |
30 | 30 | </LinearLayout> | ... | ... |
app/src/main/res/layout/fragment_consult_two_level.xml
... | ... | @@ -17,12 +17,14 @@ |
17 | 17 | android:paddingBottom="@dimen/size_dp_5" |
18 | 18 | /> |
19 | 19 | |
20 | - <android.support.v7.widget.RecyclerView | |
20 | + <com.jcodecraeer.xrecyclerview.XRecyclerView | |
21 | 21 | android:layout_marginLeft="@dimen/size_dp_10" |
22 | 22 | android:layout_marginRight="@dimen/size_dp_10" |
23 | 23 | android:id="@+id/recyclerView" |
24 | 24 | android:layout_width="match_parent" |
25 | - android:layout_height="match_parent"></android.support.v7.widget.RecyclerView> | |
25 | + android:layout_height="match_parent"> | |
26 | + | |
27 | + </com.jcodecraeer.xrecyclerview.XRecyclerView> | |
26 | 28 | |
27 | 29 | |
28 | 30 | </LinearLayout> | ... | ... |
app/src/main/res/layout/fragment_zi_xun.xml
... | ... | @@ -14,23 +14,17 @@ |
14 | 14 | android:layout_height="0dp" |
15 | 15 | android:layout_weight="2"></com.stx.xhb.xbanner.XBanner> |
16 | 16 | |
17 | - <LinearLayout | |
18 | - android:layout_width="match_parent" | |
19 | - android:layout_height="wrap_content" | |
20 | - android:paddingTop="@dimen/size_dp_10" | |
21 | - android:layout_marginLeft="@dimen/size_dp_10" | |
22 | - android:layout_marginRight="@dimen/size_dp_10" | |
23 | - > | |
24 | 17 | |
25 | 18 | <include layout="@layout/layout_textandimgshow" |
26 | 19 | /> |
27 | 20 | |
28 | - </LinearLayout> | |
21 | + | |
29 | 22 | <LinearLayout |
30 | 23 | android:layout_width="match_parent" |
31 | - android:layout_height="wrap_content" | |
24 | + android:layout_height="0dp" | |
32 | 25 | android:paddingLeft="@dimen/size_dp_10" |
33 | 26 | android:paddingRight="@dimen/size_dp_10" |
27 | + android:layout_weight="3" | |
34 | 28 | android:orientation="vertical"> |
35 | 29 | |
36 | 30 | <TextView |
... | ... | @@ -44,18 +38,19 @@ |
44 | 38 | <LinearLayout |
45 | 39 | android:layout_width="match_parent" |
46 | 40 | android:layout_height="wrap_content"> |
47 | - <android.support.v7.widget.RecyclerView | |
48 | - android:id="@+id/recycler_content" | |
49 | - android:layout_width="match_parent" | |
50 | - android:layout_height="match_parent"> | |
51 | 41 | |
52 | - </android.support.v7.widget.RecyclerView> | |
42 | + <com.jcodecraeer.xrecyclerview.XRecyclerView | |
43 | + android:id="@+id/recycler_content" | |
44 | + android:layout_width="match_parent" | |
45 | + android:layout_height="wrap_content"> | |
46 | + </com.jcodecraeer.xrecyclerview.XRecyclerView> | |
53 | 47 | </LinearLayout> |
54 | 48 | </LinearLayout> |
55 | 49 | |
56 | 50 | |
57 | 51 | <FrameLayout |
58 | 52 | android:layout_width="match_parent" |
53 | + android:visibility="gone" | |
59 | 54 | android:layout_height="0dp" |
60 | 55 | android:layout_margin="@dimen/size_dp_10" |
61 | 56 | android:layout_weight="2"> |
... | ... | @@ -63,7 +58,8 @@ |
63 | 58 | <cn.jzvd.JZVideoPlayerStandard |
64 | 59 | android:id="@+id/videoplayer" |
65 | 60 | android:layout_width="match_parent" |
66 | - android:layout_height="match_parent"></cn.jzvd.JZVideoPlayerStandard> | |
61 | + android:layout_height="match_parent" | |
62 | + ></cn.jzvd.JZVideoPlayerStandard> | |
67 | 63 | |
68 | 64 | <TextView |
69 | 65 | android:id="@+id/tvVideoTitle" | ... | ... |
mvpsdk/build.gradle