Commit 9ffe80e9b1f7a3f7fefb7a54725b57191f7fb1d7
Exists in
yxb_dev
and in
2 other branches
no message
Showing
10 changed files
with
202 additions
and
92 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,25 +2,20 @@ 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 | 10 | import android.widget.FrameLayout; |
11 | 11 | import android.widget.ImageView; |
12 | -import android.widget.TextView; | |
13 | 12 | |
14 | 13 | import com.share.mvpsdk.base.BasePresenter; |
15 | 14 | import com.share.mvpsdk.base.activity.BaseMVPCompatActivity; |
15 | +import com.share.mvpsdk.utils.ToastUtils; | |
16 | 16 | import com.shunzhi.parent.R; |
17 | -import com.shunzhi.parent.adapter.MyConsultAdapter; | |
18 | -import com.shunzhi.parent.bean.MyConsultBean; | |
19 | 17 | import com.shunzhi.parent.ui.fragment.consult.ConsultTwoLevelFragment; |
20 | 18 | |
21 | -import java.util.ArrayList; | |
22 | -import java.util.List; | |
23 | - | |
24 | 19 | public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements View.OnClickListener { |
25 | 20 | |
26 | 21 | public static void getInstance(Context context,String channel,String titleName){ |
... | ... | @@ -36,9 +31,12 @@ public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements Vi |
36 | 31 | |
37 | 32 | String channel,titleName; |
38 | 33 | |
39 | - FrameLayout frame_consult_two; | |
34 | + FrameLayout frame_consult; | |
35 | + | |
36 | + ConsultTwoLevelFragment consultTwoLevelFragment; | |
37 | + | |
38 | + FragmentTransaction fragmentTransaction=null; | |
40 | 39 | |
41 | - ConsultTwoLevelFragment consultTwoLevelFragment=null; | |
42 | 40 | @Override |
43 | 41 | protected void initView(Bundle savedInstanceState) { |
44 | 42 | initViews(); |
... | ... | @@ -55,19 +53,23 @@ public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements Vi |
55 | 53 | titleName=getIntent().getStringExtra("titleName"); |
56 | 54 | ivBack = findViewById(R.id.ivBack); |
57 | 55 | ivBack.setOnClickListener(this); |
58 | - frame_consult_two=findViewById(R.id.frame_consult_two); | |
59 | 56 | |
60 | 57 | et_search = findViewById(R.id.et_search); |
58 | + consultTwoLevelFragment=new ConsultTwoLevelFragment(); | |
59 | + et_search=findViewById(R.id.et_search); | |
60 | + ivSearch=findViewById(R.id.ivSearch); | |
61 | + ivBack=findViewById(R.id.ivBack); | |
62 | + frame_consult=findViewById(R.id.frame_consult); | |
61 | 63 | |
62 | - ivSearch = findViewById(R.id.ivSearch); | |
63 | 64 | ivSearch.setOnClickListener(this); |
65 | + ivBack.setOnClickListener(this); | |
64 | 66 | |
65 | - consultTwoLevelFragment=new ConsultTwoLevelFragment(); | |
66 | 67 | Bundle bundle=new Bundle(); |
67 | 68 | bundle.putString("channel",channel); |
68 | 69 | bundle.putString("titleName",titleName); |
69 | 70 | consultTwoLevelFragment.setArguments(bundle); |
70 | - getSupportFragmentManager().beginTransaction().add(R.id.frame_consult_two,consultTwoLevelFragment) | |
71 | + fragmentTransaction=getSupportFragmentManager().beginTransaction(); | |
72 | + fragmentTransaction.add(R.id.frame_consult,consultTwoLevelFragment) | |
71 | 73 | .show(consultTwoLevelFragment).commit(); |
72 | 74 | |
73 | 75 | } | ... | ... |
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,14 @@ 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 | + tvLocalAddress.setText(AppContext.getInstance().district); | |
83 | 87 | videoplayer.batteryLevel.setVisibility(View.GONE); |
84 | 88 | videoplayer.replayTextView.setVisibility(View.GONE); |
85 | 89 | videoplayer.backButton.setVisibility(View.GONE); |
86 | 90 | |
87 | 91 | // mPresenter.getTools(layout_control); |
88 | 92 | mPresenter.getBanners("2", AppContext.getInstance().district); |
89 | - mPresenter.getContextChannel(AppContext.getInstance().district, 0, 1, 1); | |
93 | + | |
90 | 94 | |
91 | 95 | initBroadCast(); |
92 | 96 | |
... | ... | @@ -95,8 +99,27 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
95 | 99 | |
96 | 100 | private void initRecycler() { |
97 | 101 | recycler_context.setLayoutManager(new LinearLayoutManager(getActivity())); |
98 | - contextAdapter = new ContextAdapter(getActivity()); | |
102 | +// contextAdapter = new ContextAdapter(getActivity()); | |
103 | + recycler_context.setLoadingListener(new XRecyclerView.LoadingListener() { | |
104 | + @Override | |
105 | + public void onRefresh() { | |
106 | + //refresh data here | |
107 | + pageIndex = 1; | |
108 | + contextList.clear(); | |
109 | + mPresenter.getContextChannel(AppContext.getInstance().district, 0, 1, pageIndex); | |
110 | + recycler_context.refreshComplete(); | |
111 | + } | |
99 | 112 | |
113 | + @Override | |
114 | + public void onLoadMore() { | |
115 | + // load more data here | |
116 | + pageIndex = pageIndex + 1; | |
117 | + mPresenter.getContextChannel(AppContext.getInstance().district, 0, 1, pageIndex); | |
118 | + recycler_context.refreshComplete(); | |
119 | + } | |
120 | + }); | |
121 | + pageIndex = 1; | |
122 | + mPresenter.getContextChannel(AppContext.getInstance().district, 0, 1, pageIndex); | |
100 | 123 | } |
101 | 124 | |
102 | 125 | private void initListeners() { |
... | ... | @@ -117,7 +140,7 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
117 | 140 | xBanner.setOnItemClickListener(new XBanner.OnItemClickListener() { |
118 | 141 | @Override |
119 | 142 | public void onItemClick(XBanner banner, int position) { |
120 | - WebViewActivity.getInstance(getContext(),imgesUrl.get(position),-1); | |
143 | + WebViewActivity.getInstance(getContext(), imgesUrl.get(position), -1); | |
121 | 144 | } |
122 | 145 | }); |
123 | 146 | |
... | ... | @@ -174,7 +197,7 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
174 | 197 | @Override |
175 | 198 | public void onReceive(Context context, Intent intent) { |
176 | 199 | if (intent.getAction().equals(AppContext.LOCATION_CITYNAME + "")) { |
177 | - tvLocalAddress.setText(AppContext.getInstance().cityName); | |
200 | + tvLocalAddress.setText(AppContext.getInstance().district); | |
178 | 201 | } |
179 | 202 | } |
180 | 203 | }; |
... | ... | @@ -202,47 +225,53 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
202 | 225 | |
203 | 226 | @Override |
204 | 227 | public void showChannel(final List<ChannelBean> list) { |
205 | - for (int i = 0; i < list.size(); i++) { | |
206 | - TextAndImgShowView textAndImgShowView = new TextAndImgShowView(getActivity()); | |
207 | - textAndImgShowView.setTextColor(R.color.textColor); | |
208 | - textAndImgShowView.setText(list.get(i).getChannelName()); | |
228 | + if (first) { | |
229 | + layout_control.removeAllViews(); | |
230 | + for (int i = 0; i < list.size(); i++) { | |
231 | + TextAndImgShowView textAndImgShowView = new TextAndImgShowView(getActivity()); | |
232 | + textAndImgShowView.setTextColor(R.color.textColor); | |
233 | + textAndImgShowView.setText(list.get(i).getChannelName()); | |
209 | 234 | // textAndImgShowView.setImgs(R.drawable.play, Integer.parseInt(list.get(i).getChannelImage())); |
210 | - textAndImgShowView.addImgs(list.get(i).getChannelImage()); | |
211 | - textAndImgShowView.setSelect(true); | |
212 | - textAndImgShowView.setWidth(getActivity(), layout_control); | |
213 | - textAndImgShowView.setBackground(AttrsUtils.getAttrs(getActivity()).getDrawable(0)); | |
214 | - textAndImgShowView.setTag(list.get(i)); | |
215 | - textAndImgShowView.setOnClickListener(new View.OnClickListener() { | |
216 | - @Override | |
217 | - public void onClick(View view) { | |
218 | - ChannelBean channelBean= (ChannelBean) view.getTag(); | |
219 | - ConsultOneLevelActivity.getInstance(getActivity(),channelBean.getId()+""); | |
220 | - } | |
221 | - }); | |
222 | - layout_control.addView(textAndImgShowView); | |
235 | + textAndImgShowView.addImgs(list.get(i).getChannelImage()); | |
236 | + textAndImgShowView.setSelect(true); | |
237 | + textAndImgShowView.setWidth(getActivity(), layout_control); | |
238 | + textAndImgShowView.setBackground(AttrsUtils.getAttrs(getActivity()).getDrawable(0)); | |
239 | + textAndImgShowView.setTag(list.get(i)); | |
240 | + textAndImgShowView.setOnClickListener(new View.OnClickListener() { | |
241 | + @Override | |
242 | + public void onClick(View view) { | |
243 | + ChannelBean channelBean = (ChannelBean) view.getTag(); | |
244 | + ConsultOneLevelActivity.getInstance(getActivity(), channelBean.getId() + ""); | |
245 | + } | |
246 | + }); | |
247 | + layout_control.addView(textAndImgShowView); | |
248 | + } | |
249 | + first = false; | |
223 | 250 | } |
224 | 251 | |
225 | 252 | |
226 | - | |
227 | - | |
228 | 253 | } |
229 | 254 | |
230 | 255 | @Override |
231 | 256 | public void showContext(List<ChannelContextBean> list) { |
232 | - contextList.clear(); | |
233 | 257 | contextList.addAll(list); |
234 | - contextAdapter.addAll(contextList); | |
235 | - recycler_context.setAdapter(contextAdapter); | |
236 | - | |
237 | - | |
258 | + if (contextAdapter == null) { | |
259 | + contextAdapter = new ContextAdapter(getActivity()); | |
260 | + contextAdapter.addAll(contextList); | |
261 | + recycler_context.setAdapter(contextAdapter); | |
262 | + } else { | |
263 | + contextAdapter.addAll(contextList); | |
264 | + contextAdapter.notifyDataSetChanged(); | |
265 | + } | |
238 | 266 | } |
239 | 267 | |
240 | 268 | @Override |
241 | 269 | public void getCity(String name) { |
270 | + first=true; | |
242 | 271 | tvLocalAddress.setText(name.split(" ")[1]); |
243 | 272 | mPresenter.getBanners("2", name.split(" ")[2]); |
244 | 273 | mPresenter.getContextChannel(name.split(" ")[2], 0, 1, 1); |
245 | - AppContext.getInstance().cityName=name.split(" ")[1]; | |
246 | - AppContext.getInstance().district=name.split(" ")[2]; | |
274 | + AppContext.getInstance().cityName = name.split(" ")[1]; | |
275 | + AppContext.getInstance().district = name.split(" ")[2]; | |
247 | 276 | } |
248 | 277 | } | ... | ... |
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,24 @@ 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 | |
40 | +import retrofit2.http.HEAD; | |
41 | + | |
41 | 42 | public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneContract.ConsultOnePresenter, |
42 | 43 | ConsultOneContract.IConsultOneModel> implements View.OnClickListener, ConsultOneContract.IConsultOneView { |
43 | 44 | |
44 | - RecyclerView recyclerViewGrally, recyclerViewConsultOne; | |
45 | + RecyclerView recyclerViewGrally; | |
46 | + XRecyclerView recyclerViewConsultOne; | |
45 | 47 | |
46 | 48 | MyGrallyAdapter myGrallyAdapter = null; |
47 | 49 | |
... | ... | @@ -49,7 +51,13 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
49 | 51 | |
50 | 52 | LinearLayout layout_control; |
51 | 53 | |
54 | + | |
55 | + List<ChannelContextBean> myConsultBeanList = new ArrayList<>(); | |
56 | + boolean first=true; | |
57 | + | |
52 | 58 | String channel = ""; |
59 | + int pageIndex; | |
60 | + | |
53 | 61 | |
54 | 62 | @Override |
55 | 63 | public int getLayoutId() { |
... | ... | @@ -87,9 +95,30 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
87 | 95 | layout_control.measure(0, 0); |
88 | 96 | recyclerViewGrally = view.findViewById(R.id.recyclerViewGrally); |
89 | 97 | recyclerViewConsultOne = view.findViewById(R.id.recyclerViewConsultOne); |
98 | + recyclerViewConsultOne.setLayoutManager(new LinearLayoutManager(getActivity())); | |
99 | + recyclerViewConsultOne.setLoadingListener(new XRecyclerView.LoadingListener() { | |
100 | + @Override | |
101 | + public void onRefresh() { | |
102 | + //refresh data here | |
103 | + pageIndex = 1; | |
104 | + myConsultBeanList.clear(); | |
105 | + mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, pageIndex); | |
106 | + recyclerViewConsultOne.refreshComplete(); | |
107 | + } | |
108 | + | |
109 | + @Override | |
110 | + public void onLoadMore() { | |
111 | + // load more data here | |
112 | + pageIndex = pageIndex + 1; | |
113 | + mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, pageIndex); | |
114 | + recyclerViewConsultOne.refreshComplete(); | |
115 | + } | |
116 | + }); | |
117 | + pageIndex = 1; | |
118 | + mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, pageIndex); | |
90 | 119 | |
91 | 120 | mPresenter.getBanners("3", AppContext.getInstance().district); |
92 | - mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, 1); | |
121 | + | |
93 | 122 | } |
94 | 123 | |
95 | 124 | public void showSearchContent(String keyword) { |
... | ... | @@ -120,13 +149,20 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
120 | 149 | |
121 | 150 | @Override |
122 | 151 | public void showConsultContent(List<ChannelContextBean> list) { |
123 | - if (null == myConsultAdapter) myConsultAdapter = new MyConsultAdapter(getActivity()); | |
124 | - myConsultAdapter.addAll(list); | |
125 | - recyclerViewConsultOne.setAdapter(myConsultAdapter); | |
152 | + myConsultBeanList.addAll(list); | |
153 | + if (myConsultAdapter == null) { | |
154 | + myConsultAdapter = new MyConsultAdapter(getActivity()); | |
155 | + myConsultAdapter.addAll(myConsultBeanList); | |
156 | + recyclerViewConsultOne.setAdapter(myConsultAdapter); | |
157 | + } else { | |
158 | + myConsultAdapter.addAll(myConsultBeanList); | |
159 | + myConsultAdapter.notifyDataSetChanged(); | |
160 | + } | |
126 | 161 | } |
127 | 162 | |
128 | 163 | @Override |
129 | 164 | public void showChannel(List<ChannelBean> list) { |
165 | + layout_control.removeAllViews(); | |
130 | 166 | for (int i = 0; i < list.size(); i++) { |
131 | 167 | TextAndImgShowView textAndImgShowView = new TextAndImgShowView(getActivity()); |
132 | 168 | textAndImgShowView.setTextColor(R.color.textColor); |
... | ... | @@ -140,7 +176,7 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
140 | 176 | @Override |
141 | 177 | public void onClick(View view) { |
142 | 178 | ChannelBean channelBean = (ChannelBean) view.getTag(); |
143 | - ConsultTwoLevelActivity.getInstance(getActivity(), channelBean.getId() + "",channelBean.getChannelName()); | |
179 | + ConsultTwoLevelActivity.getInstance(getActivity(), channelBean.getId() + "", channelBean.getChannelName()); | |
144 | 180 | } |
145 | 181 | }); |
146 | 182 | layout_control.addView(textAndImgShowView); |
... | ... | @@ -181,7 +217,7 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
181 | 217 | |
182 | 218 | @Override |
183 | 219 | public void onBindViewHolder(GuangGaoBean object, int position) { |
184 | - Glide.with(getActivity()).load(AppConfig.BASE_URL_FILE + object.fileSrc).error(R.drawable.ic_launcher_foreground).into(iv_grally); | |
220 | + Glide.with(getActivity()).load(AppConfig.BASE_URL_IMG + object.fileSrc).error(R.drawable.ic_launcher_foreground).into(iv_grally); | |
185 | 221 | tv_grally_title.setText(object.describe + ""); |
186 | 222 | } |
187 | 223 | } | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/consult/ConsultTwoLevelFragment.java
... | ... | @@ -3,18 +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; |
12 | -import com.shunzhi.parent.AppConfig; | |
13 | 13 | import com.shunzhi.parent.AppContext; |
14 | 14 | import com.shunzhi.parent.R; |
15 | 15 | import com.shunzhi.parent.adapter.MyConsultAdapter; |
16 | 16 | import com.shunzhi.parent.bean.GuangGaoBean; |
17 | -import com.shunzhi.parent.bean.MyConsultBean; | |
18 | 17 | import com.shunzhi.parent.bean.channel.ChannelBean; |
19 | 18 | import com.shunzhi.parent.bean.channel.ChannelContextBean; |
20 | 19 | import com.shunzhi.parent.contract.consult.consultone.ConsultOneContract; |
... | ... | @@ -31,11 +30,13 @@ public class ConsultTwoLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
31 | 30 | |
32 | 31 | TextView tvContentName; |
33 | 32 | |
34 | - RecyclerView recyclerView; | |
33 | + XRecyclerView recyclerView; | |
35 | 34 | |
36 | 35 | MyConsultAdapter myConsultAdapter = null; |
37 | 36 | |
37 | + List<ChannelContextBean> myConsultBeanList = new ArrayList<>(); | |
38 | 38 | |
39 | + int pageIndex = 1; | |
39 | 40 | String channel="",titleName; |
40 | 41 | @Override |
41 | 42 | public int getLayoutId() { |
... | ... | @@ -50,8 +51,46 @@ public class ConsultTwoLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
50 | 51 | recyclerView = view.findViewById(R.id.recyclerView); |
51 | 52 | |
52 | 53 | mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel),0,1); |
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); | |
75 | + | |
76 | +// initRecyclerView(); | |
53 | 77 | } |
54 | 78 | |
79 | +// private void initRecyclerView() { | |
80 | +// | |
81 | +// if (null == myConsultAdapter) myConsultAdapter = new MyConsultAdapter(getActivity()); | |
82 | +// for (int i = 0; i < 12; i++) { | |
83 | +// MyConsultBean myConsultBean = new MyConsultBean(); | |
84 | +// myConsultBean.consultCounts = i + ""; | |
85 | +// myConsultBean.consultContent = "咨询内容" + i; | |
86 | +// myConsultBean.consultTitle = "咨询标题" + i; | |
87 | +// myConsultBean.consultZhuanfaCounts = "转发:" + i; | |
88 | +// myConsultBeanList.add(myConsultBean); | |
89 | +// } | |
90 | +// myConsultAdapter.addAll(myConsultBeanList); | |
91 | +// recyclerView.setAdapter(myConsultAdapter); | |
92 | +// } | |
93 | + | |
55 | 94 | @NonNull |
56 | 95 | @Override |
57 | 96 | public BasePresenter initPresenter() { |
... | ... | @@ -70,9 +109,15 @@ public class ConsultTwoLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
70 | 109 | |
71 | 110 | @Override |
72 | 111 | public void showConsultContent(List<ChannelContextBean> list) { |
73 | - if (null == myConsultAdapter) myConsultAdapter = new MyConsultAdapter(getActivity()); | |
74 | - myConsultAdapter.addAll(list); | |
75 | - recyclerView.setAdapter(myConsultAdapter); | |
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 | + } | |
76 | 121 | } |
77 | 122 | |
78 | 123 | @Override |
... | ... | @@ -81,5 +126,4 @@ public class ConsultTwoLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
81 | 126 | } |
82 | 127 | |
83 | 128 | |
84 | - | |
85 | 129 | } | ... | ... |
app/src/main/res/layout/activity_consult_two_level.xml
... | ... | @@ -9,11 +9,9 @@ |
9 | 9 | tools:context="com.shunzhi.parent.ui.activity.consult.ConsultTwoLevelActivity"> |
10 | 10 | |
11 | 11 | <include layout="@layout/layout_search_back"/> |
12 | - | |
13 | 12 | <FrameLayout |
14 | 13 | android:layout_width="match_parent" |
15 | 14 | android:layout_height="match_parent" |
16 | - android:id="@+id/frame_consult_two" | |
15 | + android:id="@+id/frame_consult" | |
17 | 16 | ></FrameLayout> |
18 | - | |
19 | 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
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | android:orientation="vertical" |
7 | 7 | tools:context="com.shunzhi.parent.ui.fragment.ConsultFragment"> |
8 | 8 | |
9 | - <include layout="@layout/layout_search" /> | |
9 | + <include layout="@layout/layout_search"/> | |
10 | 10 | |
11 | 11 | <com.stx.xhb.xbanner.XBanner |
12 | 12 | android:id="@+id/xBanner" |
... | ... | @@ -14,23 +14,18 @@ |
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:layout_marginLeft="@dimen/size_dp_10" | |
21 | - android:layout_marginRight="@dimen/size_dp_10" | |
22 | - android:paddingTop="@dimen/size_dp_10"> | |
23 | 17 | |
24 | - <include layout="@layout/layout_textandimgshow" /> | |
18 | +<include layout="@layout/layout_textandimgshow" | |
19 | + /> | |
25 | 20 | |
26 | - </LinearLayout> | |
27 | 21 | |
28 | 22 | <LinearLayout |
29 | 23 | android:layout_width="match_parent" |
30 | - android:layout_height="wrap_content" | |
31 | - android:orientation="vertical" | |
24 | + android:layout_height="0dp" | |
32 | 25 | android:paddingLeft="@dimen/size_dp_10" |
33 | - android:paddingRight="@dimen/size_dp_10"> | |
26 | + android:paddingRight="@dimen/size_dp_10" | |
27 | + android:layout_weight="3" | |
28 | + android:orientation="vertical"> | |
34 | 29 | |
35 | 30 | <TextView |
36 | 31 | android:layout_width="match_parent" |
... | ... | @@ -44,18 +39,18 @@ |
44 | 39 | android:layout_width="match_parent" |
45 | 40 | android:layout_height="wrap_content"> |
46 | 41 | |
47 | - <android.support.v7.widget.RecyclerView | |
42 | + <com.jcodecraeer.xrecyclerview.XRecyclerView | |
48 | 43 | android:id="@+id/recycler_content" |
49 | 44 | android:layout_width="match_parent" |
50 | - android:layout_height="match_parent"> | |
51 | - | |
52 | - </android.support.v7.widget.RecyclerView> | |
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