>
map.put("targetType", ChatRecommendBean.TARGET_TYPE_IMAGE_TEXT + "");
|
|
|
177
|
map.put("appToken", ProfileManager.getInstance().getKeyMessageToken(getContext()));
|
|
|
178
|
CommonParams.addCommonParams(map);
|
|
|
179
|
Log.d(TAG, "loginSign: " + map);
|
|
|
180
|
loadingDialog.show();
|
|
|
181
|
OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
|
|
|
182
|
@Override
|
|
|
183
|
public void onError(Call call, Exception e) {
|
|
|
184
|
loadingDialog.dismiss();
|
|
|
185
|
ToastUtil.showToast(getContext(), e.getMessage(), Toast.LENGTH_SHORT);
|
|
|
186
|
}
|
|
|
187
|
|
|
|
188
|
@Override
|
|
|
189
|
public void onResponse(String response) {
|
|
|
190
|
loadingDialog.dismiss();
|
|
|
191
|
String code = JsonUtils.getKeyResult(response, "code");
|
|
|
192
|
String desc = JsonUtils.getKeyResult(response, "desc");
|
|
|
193
|
if ("1000".equals(code)) {
|
|
|
194
|
chat_share_info_remind.setVisibility(View.GONE);
|
|
|
195
|
ProfileManager.getInstance().setFirstComeIn(getActivity(), "label");
|
|
|
196
|
startActivity(new Intent(getActivity(), PublishItemsActivity.class));
|
|
|
197
|
} else if ("8010".equals(code)) {
|
|
|
198
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
|
199
|
ToastUtil.showToast(getContext(), desc + map, Toast.LENGTH_LONG);
|
|
|
200
|
} else {
|
|
|
201
|
ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
|
|
|
202
|
}
|
|
|
203
|
}
|
|
|
204
|
});
|
|
|
205
|
|
|
|
206
|
}
|
|
|
207
|
|
|
166
|
208
|
public void refreshList() {
|
|
167
|
209
|
if (view == null)
|
|
168
|
210
|
return;
|
|
|
@ -176,9 +218,9 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
|
|
176
|
218
|
|
|
177
|
219
|
Map<String, String> map = new HashMap<>();
|
|
178
|
220
|
map.put("selected", "1");
|
|
179
|
|
if (MainApplication.isLogin()) {
|
|
180
|
|
map.put("user_id", MainApplication.userId);
|
|
181
|
|
}
|
|
|
221
|
CommonParams.addCommonParams(map);
|
|
|
222
|
Log.d(TAG, "requestHeaderData: " + map);
|
|
|
223
|
|
|
182
|
224
|
OkHttpUtils.get().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
|
|
183
|
225
|
@Override
|
|
184
|
226
|
public void onError(Call call, Exception e) {
|
|
|
@ -188,21 +230,21 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
|
|
188
|
230
|
refreshView.stopLoadMore();
|
|
189
|
231
|
}
|
|
190
|
232
|
if (getActivity() != null) {
|
|
191
|
|
ToastUtil.showToast(getActivity().getApplicationContext(), "加载失败,请重试", Toast.LENGTH_SHORT);
|
|
|
233
|
ToastUtil.showToast(getActivity().getApplicationContext(), "加载失败,请重试:" + e.getMessage(), Toast.LENGTH_SHORT);
|
|
192
|
234
|
}
|
|
193
|
235
|
}
|
|
194
|
236
|
|
|
195
|
237
|
@Override
|
|
196
|
238
|
public void onResponse(String response) {
|
|
197
|
|
String rtnCode = JsonUtils.getKeyResult(response, "code");
|
|
198
|
|
String rtnDesc = JsonUtils.getKeyResult(response, "desc");
|
|
199
|
|
if ("1000".equals(rtnCode)) {
|
|
200
|
|
String rtnData = JsonUtils.getKeyResult(response, "data");
|
|
201
|
|
ArrayList<ChatRecommendBean> topicData = (ArrayList<ChatRecommendBean>) JsonUtils.parseToObjectList(rtnData, ChatRecommendBean.class);
|
|
|
239
|
String code = JsonUtils.getKeyResult(response, "code");
|
|
|
240
|
String desc = JsonUtils.getKeyResult(response, "desc");
|
|
|
241
|
if ("1000".equals(code)) {
|
|
|
242
|
String data = JsonUtils.getKeyResult(response, "data");
|
|
|
243
|
ArrayList<ChatRecommendBean> topicData = (ArrayList<ChatRecommendBean>) JsonUtils.parseToObjectList(data, ChatRecommendBean.class);
|
|
202
|
244
|
chatRecommendAdapter.setHeaderData(topicData);
|
|
203
|
245
|
requestData();
|
|
204
|
246
|
} else {
|
|
205
|
|
ToastUtil.showToast(getActivity().getApplicationContext(), rtnDesc, Toast.LENGTH_SHORT);
|
|
|
247
|
ToastUtil.showToast(getActivity().getApplicationContext(), desc, Toast.LENGTH_SHORT);
|
|
206
|
248
|
}
|
|
207
|
249
|
}
|
|
208
|
250
|
});
|
|
|
@ -211,15 +253,10 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
|
|
211
|
253
|
private void requestData() {
|
|
212
|
254
|
String url = MainApplication.urlNew + "/topic/info/list.do";
|
|
213
|
255
|
Map<String, String> map = new HashMap<>();
|
|
214
|
|
if (MainApplication.isLogin()) {
|
|
215
|
|
map.put("userId", MainApplication.userId);
|
|
216
|
|
}
|
|
217
|
256
|
map.put("page", page + "");
|
|
218
|
257
|
map.put("limit", "20");
|
|
|
258
|
CommonParams.addCommonParams(map);
|
|
219
|
259
|
|
|
220
|
|
if (MainApplication.isLogin()) {
|
|
221
|
|
map.put("user_id", MainApplication.userId);
|
|
222
|
|
}
|
|
223
|
260
|
OkHttpUtils.get().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
|
|
224
|
261
|
@Override
|
|
225
|
262
|
public void onError(Call call, Exception e) {
|
|
|
@ -238,11 +275,11 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
|
|
238
|
275
|
} else {
|
|
239
|
276
|
refreshView.stopLoadMore();
|
|
240
|
277
|
}
|
|
241
|
|
String rtnCode = JsonUtils.getKeyResult(response, "code");
|
|
242
|
|
String rtnDesc = JsonUtils.getKeyResult(response, "desc");
|
|
243
|
|
if ("1000".equals(rtnCode)) {
|
|
244
|
|
String rtnData = JsonUtils.getKeyResult(response, "data");
|
|
245
|
|
ArrayList<ChatRecommendBean> chatRecommendBeans = (ArrayList<ChatRecommendBean>) JsonUtils.parseToObjectList(rtnData, ChatRecommendBean.class);
|
|
|
278
|
String code = JsonUtils.getKeyResult(response, "code");
|
|
|
279
|
String desc = JsonUtils.getKeyResult(response, "desc");
|
|
|
280
|
if ("1000".equals(code)) {
|
|
|
281
|
String data = JsonUtils.getKeyResult(response, "data");
|
|
|
282
|
ArrayList<ChatRecommendBean> chatRecommendBeans = (ArrayList<ChatRecommendBean>) JsonUtils.parseToObjectList(data, ChatRecommendBean.class);
|
|
246
|
283
|
if (page == 1) {
|
|
247
|
284
|
refreshView.setLoadComplete(false);
|
|
248
|
285
|
chatRecommendAdapter.setData(chatRecommendBeans);
|
|
|
@ -254,7 +291,7 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
|
|
254
|
291
|
refreshView.setLoadComplete(true);
|
|
255
|
292
|
}
|
|
256
|
293
|
} else {
|
|
257
|
|
ToastUtil.showToast(getActivity().getApplicationContext(), rtnDesc, Toast.LENGTH_SHORT);
|
|
|
294
|
ToastUtil.showToast(getActivity().getApplicationContext(), desc, Toast.LENGTH_SHORT);
|
|
258
|
295
|
}
|
|
259
|
296
|
}
|
|
260
|
297
|
});
|
|
|
@ -4,6 +4,7 @@ import android.os.Build;
|
|
4
|
4
|
|
|
5
|
5
|
import com.electric.chargingpile.BuildConfig;
|
|
6
|
6
|
import com.electric.chargingpile.application.MainApplication;
|
|
|
7
|
import com.electric.chargingpile.manager.ProfileManager;
|
|
7
|
8
|
|
|
8
|
9
|
import java.util.Map;
|
|
9
|
10
|
|
|
|
@ -13,23 +14,24 @@ public class CommonParams {
|
|
13
|
14
|
public static void addCommonParams(Map<String, String> map) {
|
|
14
|
15
|
if (MainApplication.isLogin()) {
|
|
15
|
16
|
map.put("userId", MainApplication.userId);
|
|
16
|
|
map.put("deviceOs", "android");
|
|
17
|
|
map.put("appVer", BuildConfig.VERSION_NAME);
|
|
18
|
|
// map.put("appToken", "");
|
|
19
|
|
map.put("deviceOsVer", Build.VERSION.RELEASE);
|
|
20
|
|
map.put("deviceId", JPushInterface.getUdid(MainApplication.context));
|
|
|
17
|
}
|
|
|
18
|
|
|
|
19
|
map.put("deviceOs", "android");
|
|
|
20
|
map.put("appVer", BuildConfig.VERSION_NAME);
|
|
|
21
|
// map.put("appToken", "");
|
|
|
22
|
map.put("deviceOsVer", Build.VERSION.RELEASE);
|
|
|
23
|
map.put("deviceId", JPushInterface.getUdid(MainApplication.context));
|
|
21
|
24
|
// map.put("tpToken", "");
|
|
22
|
|
map.put("jpushId", JPushInterface.getRegistrationID(MainApplication.context));
|
|
23
|
|
map.put("channel", BuildConfig.FLAVOR);
|
|
24
|
|
// 硬件设备
|
|
|
25
|
map.put("jpushId", JPushInterface.getRegistrationID(MainApplication.context));
|
|
|
26
|
map.put("channel", BuildConfig.FLAVOR);
|
|
|
27
|
// 硬件设备
|
|
25
|
28
|
// map.put("deviceSysVar", "");
|
|
26
|
29
|
// map.put("lng",);
|
|
27
|
30
|
// map.put("lat",);
|
|
28
|
|
// 2g 3g 4g wifi等
|
|
|
31
|
// 2g 3g 4g wifi等
|
|
29
|
32
|
// map.put("network",);
|
|
30
|
|
// 网络运营商 移动 联通等
|
|
|
33
|
// 网络运营商 移动 联通等
|
|
31
|
34
|
// map.put("networkOperator", "");
|
|
32
|
|
}
|
|
33
|
35
|
|
|
34
|
36
|
}
|
|
35
|
37
|
}
|
|
|
@ -55,6 +55,7 @@
|
|
55
|
55
|
<View
|
|
56
|
56
|
android:layout_width="match_parent"
|
|
57
|
57
|
android:layout_height="0.5dp"
|
|
|
58
|
android:visibility="gone"
|
|
58
|
59
|
android:background="@color/title_line"/>
|
|
59
|
60
|
</RelativeLayout>
|
|
60
|
61
|
|
|
|
@ -106,6 +107,7 @@
|
|
106
|
107
|
android:layout_height="0.5dp"
|
|
107
|
108
|
android:background="@color/Line"
|
|
108
|
109
|
android:layout_below="@+id/noScrollgridview"
|
|
|
110
|
android:visibility="gone"
|
|
109
|
111
|
android:layout_marginTop="12dp"/>
|
|
110
|
112
|
|
|
111
|
113
|
|