Browse Source

图文信息上传

huyuguo 6 years ago
parent
commit
97e99d6dbb

+ 2 - 0
app/src/main/java/com/electric/chargingpile/activity/LoginActivity.java

6
import android.os.Bundle;
6
import android.os.Bundle;
7
import android.text.Editable;
7
import android.text.Editable;
8
import android.text.TextWatcher;
8
import android.text.TextWatcher;
9
import android.util.Log;
9
import android.view.View;
10
import android.view.View;
10
import android.view.inputmethod.InputMethodManager;
11
import android.view.inputmethod.InputMethodManager;
11
import android.widget.Button;
12
import android.widget.Button;
464
        String userpic = JsonUtils.getKeyResult(info, "userpic");
465
        String userpic = JsonUtils.getKeyResult(info, "userpic");
465
        String chexing = JsonUtils.getKeyResult(info, "chexing");
466
        String chexing = JsonUtils.getKeyResult(info, "chexing");
466
        String myToken = JsonUtils.getKeyResult(info, "usertiken");
467
        String myToken = JsonUtils.getKeyResult(info, "usertiken");
468
        Log.d(TAG, "saveUserInfo: " + myToken);
467
        String userpassword = password.getText().toString();
469
        String userpassword = password.getText().toString();
468
        //保存用户id
470
        //保存用户id
469
        MainApplication.userId = userid;
471
        MainApplication.userId = userid;

+ 64 - 59
app/src/main/java/com/electric/chargingpile/activity/PublishPicTopicActivity.java

52
import com.electric.chargingpile.R;
52
import com.electric.chargingpile.R;
53
import com.electric.chargingpile.application.MainApplication;
53
import com.electric.chargingpile.application.MainApplication;
54
import com.electric.chargingpile.data.AuthSignBean;
54
import com.electric.chargingpile.data.AuthSignBean;
55
import com.electric.chargingpile.data.ChatRecommendBean;
55
import com.electric.chargingpile.data.HomePageBean;
56
import com.electric.chargingpile.data.HomePageBean;
56
import com.electric.chargingpile.data.TalkRecommendBean;
57
import com.electric.chargingpile.data.TalkRecommendBean;
57
import com.electric.chargingpile.data.UploadPic;
58
import com.electric.chargingpile.data.UploadPic;
58
import com.electric.chargingpile.manager.ProfileManager;
59
import com.electric.chargingpile.manager.ProfileManager;
59
import com.electric.chargingpile.util.BarColorUtil;
60
import com.electric.chargingpile.util.BarColorUtil;
60
import com.electric.chargingpile.util.Bimp;
61
import com.electric.chargingpile.util.Bimp;
62
import com.electric.chargingpile.util.CommonParams;
61
import com.electric.chargingpile.util.ImageItem;
63
import com.electric.chargingpile.util.ImageItem;
62
import com.electric.chargingpile.util.JsonUtils;
64
import com.electric.chargingpile.util.JsonUtils;
63
import com.electric.chargingpile.util.LoadingDialog;
65
import com.electric.chargingpile.util.LoadingDialog;
138
    private String OPERATER = "d1evvideo01";
140
    private String OPERATER = "d1evvideo01";
139
    @SuppressLint("SdCardPath")
141
    @SuppressLint("SdCardPath")
140
    private ParallelUploader parallelUploader;
142
    private ParallelUploader parallelUploader;
143
    private ProgressDialog uploadDialog;
144
141
145
142
    @Override
146
    @Override
143
    protected void onCreate(Bundle savedInstanceState) {
147
    protected void onCreate(Bundle savedInstanceState) {
175
    }
179
    }
176
180
177
    private void initView() {
181
    private void initView() {
182
        uploadDialog = new ProgressDialog(this);
183
        uploadDialog.setMessage("正在提交...");
184
        uploadDialog.setCanceledOnTouchOutside(false);
185
178
        mPublishTopicDe = (ImageView) findViewById(R.id.publishtopic_choose_topic_de);
186
        mPublishTopicDe = (ImageView) findViewById(R.id.publishtopic_choose_topic_de);
179
        mPublishTopicDe.setOnClickListener(this);
187
        mPublishTopicDe.setOnClickListener(this);
180
        mPublishtopicChooseTopic = (TextView) findViewById(R.id.publishtopic_choose_topic);
188
        mPublishtopicChooseTopic = (TextView) findViewById(R.id.publishtopic_choose_topic);
195
                    }
203
                    }
196
                }
204
                }
197
205
198
                dialog.show();
206
//                dialog.show();
207
                uploadDialog.show();
199
                //获取又拍云数据
208
                //获取又拍云数据
200
                getYouPaiData();
209
                getYouPaiData();
201
210
216
225
217
            @Override
226
            @Override
218
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
227
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
219
220
            }
228
            }
221
229
222
            @Override
230
            @Override
236
//                    ToastUtil.showToast(getApplicationContext(), "输入字数不能超过500", Toast.LENGTH_SHORT);
244
//                    ToastUtil.showToast(getApplicationContext(), "输入字数不能超过500", Toast.LENGTH_SHORT);
237
//                    return;
245
//                    return;
238
//                }
246
//                }
239
                if (!s.trim().isEmpty() && s.length() > 0 && null != Bimp.tempSelectBitmap && Bimp.tempSelectBitmap.size()>0) {
247
                if (!s.trim().isEmpty() && s.length() > 0 && null != Bimp.tempSelectBitmap && Bimp.tempSelectBitmap.size() > 0) {
240
                    tv_right.setEnabled(true);
248
                    tv_right.setEnabled(true);
241
//					tv_right.setTextColor(getResources().getColor(R.color.lvse));
249
//					tv_right.setTextColor(getResources().getColor(R.color.lvse));
242
                    tv_right.setBackgroundColor(Color.parseColor("#02b637"));
250
                    tv_right.setBackgroundColor(Color.parseColor("#02b637"));
244
                    tv_right.setEnabled(false);
252
                    tv_right.setEnabled(false);
245
                    tv_right.setBackgroundColor(Color.parseColor("#9ed3ae"));
253
                    tv_right.setBackgroundColor(Color.parseColor("#9ed3ae"));
246
                }
254
                }
247
                if(TextUtils.isEmpty(s))
255
256
                if (TextUtils.isEmpty(s))
248
                    publishtopic_word_num.setText("0");
257
                    publishtopic_word_num.setText("0");
249
                else
258
                else
250
                    publishtopic_word_num.setText(s.length()+"");
259
                    publishtopic_word_num.setText(s.length() + "");
251
            }
260
            }
252
        });
261
        });
253
262
263
            return;
272
            return;
264
        String fileNames = "";
273
        String fileNames = "";
265
        for (int i = 0; i < Bimp.tempSelectBitmap.size(); i++) {
274
        for (int i = 0; i < Bimp.tempSelectBitmap.size(); i++) {
266
//            File tempFile = new File(Bimp.tempSelectBitmap.get(i).imagePath.trim());
267
            String fileNameDir = Bimp.tempSelectBitmap.get(i).getImagePath();
275
            String fileNameDir = Bimp.tempSelectBitmap.get(i).getImagePath();
268
269
            Log.e("fileNameDir", fileNameDir);
270
            String fileName = fileNameDir.substring(fileNameDir.lastIndexOf("/") + 1);
276
            String fileName = fileNameDir.substring(fileNameDir.lastIndexOf("/") + 1);
271
            Log.e("fileNameDir fileName", fileName);
272
            if (TextUtils.isEmpty(fileNames))
277
            if (TextUtils.isEmpty(fileNames)) {
273
                fileNames = fileName;
278
                fileNames = fileName;
274
            else
275
                fileNames = "," + fileName;
279
            } else {
280
                fileNames += "," + fileName;
281
            }
276
        }
282
        }
283
277
        String url = MainApplication.urlNew + "/topic/sign.do";
284
        String url = MainApplication.urlNew + "/topic/sign.do";
278
        Map<String, String> map = new HashMap<>();
285
        Map<String, String> map = new HashMap<>();
279
        map.put("fileNames", fileNames);
286
        map.put("fileNames", fileNames);
280
        Log.e("fileNameDir fileName", fileNames);
281
//        map.put("expiration", (System.currentTimeMillis() + 1800) + "");
282
        map.put("targetType", "24");//23视频/24图片
283
        String token = ProfileManager.getInstance().getKeyMessageToken(getApplicationContext());
284
        map.put("appToken", token+"");
285
        map.put("userId", MainApplication.userId);
287
        map.put("targetType", ChatRecommendBean.TARGET_TYPE_IMAGE_TEXT + "");
288
        map.put("appToken", ProfileManager.getInstance().getKeyMessageToken(getApplicationContext()));
289
        CommonParams.addCommonParams(map);
286
        OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
290
        OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
287
            @Override
291
            @Override
288
            public void onError(Call call, Exception e) {
292
            public void onError(Call call, Exception e) {
293
                uploadDialog.dismiss();
294
                ToastUtil.showToast(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT);
289
            }
295
            }
290
296
291
            @Override
297
            @Override
292
            public void onResponse(String response) {
298
            public void onResponse(String response) {
293
                Log.i(TAG, response);
294
                String rtnCode = JsonUtils.getKeyResult(response, "code");
295
                if ("1000".equals(rtnCode)) {
296
                    String rtnMsg = JsonUtils.getKeyResult(response, "data");
297
                    ArrayList<AuthSignBean> signBeans = (ArrayList<AuthSignBean>) JsonUtils.parseToObjectList(rtnMsg, AuthSignBean.class);
298
299
                String code = JsonUtils.getKeyResult(response, "code");
300
                String desc = JsonUtils.getKeyResult(response, "desc");
301
                if ("1000".equals(code)) {
302
                    String data = JsonUtils.getKeyResult(response, "data");
303
                    ArrayList<AuthSignBean> signBeans = (ArrayList<AuthSignBean>) JsonUtils.parseToObjectList(data, AuthSignBean.class);
299
                    if (null != signBeans && signBeans.size() > 0) {
304
                    if (null != signBeans && signBeans.size() > 0) {
300
301
                        publishCount = signBeans.size();
305
                        publishCount = signBeans.size();
302
                        for(int i=0;i<publishCount;i++){
306
                        for (int i = 0; i < publishCount; i++) {
303
                            String sign = signBeans.get(i).sign;
307
                            String sign = signBeans.get(i).sign;
304
                            String policy = signBeans.get(i).policy;
308
                            String policy = signBeans.get(i).policy;
305
                            formUpload(Bimp.tempSelectBitmap.get(i).getImagePath(), sign,  policy);
309
                            formUpload(Bimp.tempSelectBitmap.get(i).getImagePath(), sign, policy);
306
                        }
310
                        }
307
308
                    }
311
                    }
312
                } else if ("8010".equals(code)) {
313
                    uploadDialog.dismiss();
314
                    startActivity(new Intent(getApplicationContext(), LoginActivity.class));
315
                    ToastUtil.showToast(getApplicationContext(), desc, Toast.LENGTH_SHORT);
316
                } else {
317
                    uploadDialog.dismiss();
318
                    uploadDialog.cancel();
319
                    ToastUtil.showToast(getApplicationContext(), desc, Toast.LENGTH_SHORT);
309
                }
320
                }
310
            }
321
            }
311
        });
322
        });
314
325
315
    private ArrayList<String> publishArray = new ArrayList<>();
326
    private ArrayList<String> publishArray = new ArrayList<>();
316
    private int publishCount = 0;
327
    private int publishCount = 0;
317
318
    final int reqTopic = 100;
328
    final int reqTopic = 100;
319
329
320
    @Override
330
    @Override
424
                    photo();
434
                    photo();
425
                } else {
435
                } else {
426
                    ToastUtil.showToast(getApplicationContext(), "您当前关闭了调用摄像头权限", Toast.LENGTH_SHORT);
436
                    ToastUtil.showToast(getApplicationContext(), "您当前关闭了调用摄像头权限", Toast.LENGTH_SHORT);
427
              }
437
                }
428
            }
438
            }
429
        });
439
        });
430
        bt2.setOnClickListener(new OnClickListener() {
440
        bt2.setOnClickListener(new OnClickListener() {
480
                .setShowGif(true)//是否显示动态图
490
                .setShowGif(true)//是否显示动态图
481
                .setPreviewEnabled(true)//是否可以预览
491
                .setPreviewEnabled(true)//是否可以预览
482
                .start(this, PhotoPicker.REQUEST_CODE);
492
                .start(this, PhotoPicker.REQUEST_CODE);
483
484
485
    }
493
    }
486
494
487
    @Override
495
    @Override
491
            talkRecommendBean = (TalkRecommendBean) data.getSerializableExtra("topic");
499
            talkRecommendBean = (TalkRecommendBean) data.getSerializableExtra("topic");
492
            if (talkRecommendBean != null) {
500
            if (talkRecommendBean != null) {
493
                mPublishtopicChooseTopic.setText("# " + talkRecommendBean.topicName);
501
                mPublishtopicChooseTopic.setText("# " + talkRecommendBean.topicName);
494
                topicId = talkRecommendBean.topicId+"";
502
                topicId = talkRecommendBean.topicId + "";
495
                mPublishTopicDe.setVisibility(View.VISIBLE);
503
                mPublishTopicDe.setVisibility(View.VISIBLE);
496
            }
504
            }
497
        }
505
        }
518
        Observable.create(new ObservableOnSubscribe<String>() {
526
        Observable.create(new ObservableOnSubscribe<String>() {
519
            @Override
527
            @Override
520
            public void subscribe(ObservableEmitter<String> subscriber) throws Exception {
528
            public void subscribe(ObservableEmitter<String> subscriber) throws Exception {
521
522
                try {
529
                try {
523
                    ArrayList<String> photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS);
530
                    ArrayList<String> photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS);
524
                    //可以同时插入多张图片
531
                    //可以同时插入多张图片
687
        if (hasSdcard()) {
694
        if (hasSdcard()) {
688
            int currentapiVersion = Build.VERSION.SDK_INT;
695
            int currentapiVersion = Build.VERSION.SDK_INT;
689
            Log.e("currentapiVersion", "currentapiVersion====>" + currentapiVersion);
696
            Log.e("currentapiVersion", "currentapiVersion====>" + currentapiVersion);
690
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//���������
697
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
691
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
698
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
692
            startActivityForResult(intent, PHOTO_REQUEST_CAMERA);
699
            startActivityForResult(intent, PHOTO_REQUEST_CAMERA);
693
        }
700
        }
721
            double i = mid / maxSize;
728
            double i = mid / maxSize;
722
            // 开始压缩 此处用到平方根 将宽带和高度压缩掉对应的平方根倍
729
            // 开始压缩 此处用到平方根 将宽带和高度压缩掉对应的平方根倍
723
            // (1.保持刻度和高度和原bitmap比率一致,压缩后也达到了最大大小占用空间的大小)
730
            // (1.保持刻度和高度和原bitmap比率一致,压缩后也达到了最大大小占用空间的大小)
724
            bm = zoomImage(bm, bm.getWidth() / Math.sqrt(i), bm.getHeight()
725
                    / Math.sqrt(i));
731
            bm = zoomImage(bm, bm.getWidth() / Math.sqrt(i), bm.getHeight() / Math.sqrt(i));
726
        }
732
        }
727
733
728
        return bm;
734
        return bm;
823
//                tv_form.setText((100 * bytesWrite) / contentLength + "%");
829
//                tv_form.setText((100 * bytesWrite) / contentLength + "%");
824
                Log.e(TAG, (100 * bytesWrite) / contentLength + "%");
830
                Log.e(TAG, (100 * bytesWrite) / contentLength + "%");
825
                Log.e(TAG, bytesWrite + "::" + contentLength);
831
                Log.e(TAG, bytesWrite + "::" + contentLength);
832
                uploadDialog.setProgress((int) (100 * bytesWrite/contentLength));
826
            }
833
            }
827
        };
834
        };
828
835
832
            public void onComplete(boolean isSuccess, String result) {
839
            public void onComplete(boolean isSuccess, String result) {
833
//                tv_form.setText(isSuccess + ":" + result);
840
//                tv_form.setText(isSuccess + ":" + result);
834
                Log.e(TAG, isSuccess + ":" + result);
841
                Log.e(TAG, isSuccess + ":" + result);
835
                if(isSuccess)
842
                if (isSuccess)
836
                    publishArray.add(result);
843
                    publishArray.add(result);
837
                if(publishCount == publishArray.size()){
838
                    String urls= "";
839
                    for(int i=0;i<publishArray.size();i++){
840
                        if(TextUtils.isEmpty(urls))
844
                if (publishCount == publishArray.size()) {
845
                    String urls = "";
846
                    for (int i = 0; i < publishArray.size(); i++) {
847
                        if (TextUtils.isEmpty(urls))
841
                            urls = publishArray.get(i);
848
                            urls = publishArray.get(i);
842
                        else
849
                        else
843
                            urls = urls+","+publishArray.get(i);
850
                            urls = urls + "," + publishArray.get(i);
844
                    }
851
                    }
845
                    requestPublishServer("["+urls+"]");
852
                    requestPublishServer("[" + urls + "]");
846
                }
853
                }
847
            }
854
            }
848
        };
855
        };
854
    }
861
    }
855
862
856
863
857
    private void requestPublishServer(String urls){
864
    private void requestPublishServer(String urls) {
858
        String url = MainApplication.urlNew + "/topic/publish.do";
865
        String url = MainApplication.urlNew + "/topic/publish.do";
859
        Map<String, String> map = new HashMap<>();
866
        Map<String, String> map = new HashMap<>();
860
        map.put("content", et_context.getText().toString());
867
        map.put("content", et_context.getText().toString());
862
        map.put("topicId", topicId);
869
        map.put("topicId", topicId);
863
        map.put("targetType", "24");
870
        map.put("targetType", "24");
864
        map.put("coverImgUrl", "");
871
        map.put("coverImgUrl", "");
865
        if (MainApplication.isLogin()) {
866
            map.put("userId", MainApplication.userId);
867
            String token = ProfileManager.getInstance().getKeyMessageToken(getApplicationContext());
868
            map.put("appToken", token+"");
869
        }
870
        Log.e(TAG, map.toString());
872
        map.put("appToken", ProfileManager.getInstance().getKeyMessageToken(getApplicationContext()));
873
        CommonParams.addCommonParams(map);
874
871
        OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
875
        OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
872
            @Override
876
            @Override
873
            public void onError(Call call, Exception e) {
877
            public void onError(Call call, Exception e) {
878
                uploadDialog.dismiss();
874
                dialog.cancel();
879
                dialog.cancel();
875
                publishArray.clear();
880
                publishArray.clear();
876
                publishCount = 0;
881
                publishCount = 0;
879
884
880
            @Override
885
            @Override
881
            public void onResponse(String response) {
886
            public void onResponse(String response) {
882
                Log.e(TAG, "response:" + response);
883
                LogUtils.e(response);
887
                uploadDialog.dismiss();
884
                dialog.cancel();
888
                dialog.cancel();
885
                publishArray.clear();
889
                publishArray.clear();
886
                publishCount = 0;
890
                publishCount = 0;
887
                String rtnCode = JsonUtils.getKeyResult(response, "code");
888
                if ("1000".equals(rtnCode)) {
891
                String code = JsonUtils.getKeyResult(response, "code");
892
                String desc = JsonUtils.getKeyResult(response, "desc");
893
                if ("1000".equals(code)) {
889
                    ToastUtil.showToast(getApplicationContext(), "发布成功", Toast.LENGTH_SHORT);
894
                    ToastUtil.showToast(getApplicationContext(), "发布成功", Toast.LENGTH_SHORT);
890
                }else {
891
                    String message = JsonUtils.getKeyResult(response, "desc");
892
                    ToastUtil.showToast(getApplicationContext(), message, Toast.LENGTH_SHORT);
895
                } else {
896
897
                    ToastUtil.showToast(getApplicationContext(), desc, Toast.LENGTH_SHORT);
893
                }
898
                }
894
            }
899
            }
895
        });
900
        });
896
    }
901
    }
897
902
898
    private void showDialogToExit(){
903
    private void showDialogToExit() {
899
        AlertDialog.Builder builder = new AlertDialog.Builder(PublishPicTopicActivity.this);
904
        AlertDialog.Builder builder = new AlertDialog.Builder(PublishPicTopicActivity.this);
900
        builder.setTitle("提示");
905
        builder.setTitle("提示");
901
        builder.setMessage("是否离开发布页?");
906
        builder.setMessage("是否离开发布页?");

+ 2 - 2
app/src/main/java/com/electric/chargingpile/application/MainApplication.java

74
    public static Boolean firstSsyd;
74
    public static Boolean firstSsyd;
75
    public static String password = "";
75
    public static String password = "";
76
    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
76
    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
77
//    public static String urlNew = "http://123.56.67.7:83/api/0200";// 一电测试环境
78
    public static String urlNew = "https://api.touchev.com:83/api/0200";// 一电正式环境
77
    public static String urlNew = "http://123.56.67.7:83/api/0200";// 一电测试环境
78
//    public static String urlNew = "https://api.touchev.com:83/api/0200";// 一电正式环境
79
    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
79
    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
80
    //	public static String url = "https://cdz.d1ev.com";
80
    //	public static String url = "https://cdz.d1ev.com";
81
    public static String build_flag = "0";
81
    public static String build_flag = "0";

+ 65 - 28
app/src/main/java/com/electric/chargingpile/fragment/ChatRecommendFragment.java

11
import android.view.View;
11
import android.view.View;
12
import android.view.ViewGroup;
12
import android.view.ViewGroup;
13
import android.widget.ImageView;
13
import android.widget.ImageView;
14
import android.widget.LinearLayout;
15
import android.widget.Toast;
14
import android.widget.Toast;
16
15
17
import com.andview.refreshview.XRefreshView;
16
import com.andview.refreshview.XRefreshView;
21
import com.electric.chargingpile.adapter.ChatRecommendAdapter;
20
import com.electric.chargingpile.adapter.ChatRecommendAdapter;
22
import com.electric.chargingpile.adapter.ChatRecommendItemDecoration;
21
import com.electric.chargingpile.adapter.ChatRecommendItemDecoration;
23
import com.electric.chargingpile.application.MainApplication;
22
import com.electric.chargingpile.application.MainApplication;
23
import com.electric.chargingpile.data.AuthSignBean;
24
import com.electric.chargingpile.data.ChatRecommendBean;
24
import com.electric.chargingpile.data.ChatRecommendBean;
25
import com.electric.chargingpile.iview.RecyclerItemTypeClickListener;
25
import com.electric.chargingpile.iview.RecyclerItemTypeClickListener;
26
import com.electric.chargingpile.manager.ProfileManager;
26
import com.electric.chargingpile.manager.ProfileManager;
27
import com.electric.chargingpile.util.Bimp;
28
import com.electric.chargingpile.util.CommonParams;
27
import com.electric.chargingpile.util.JsonUtils;
29
import com.electric.chargingpile.util.JsonUtils;
30
import com.electric.chargingpile.util.LoadingDialog;
28
import com.electric.chargingpile.util.NetUtil;
31
import com.electric.chargingpile.util.NetUtil;
29
import com.electric.chargingpile.util.ToastUtil;
32
import com.electric.chargingpile.util.ToastUtil;
30
import com.zhy.http.okhttp.OkHttpUtils;
33
import com.zhy.http.okhttp.OkHttpUtils;
47
    private ImageView chat_share_info_remind;
50
    private ImageView chat_share_info_remind;
48
    private boolean isFirst = false;
51
    private boolean isFirst = false;
49
    private int page = 1;
52
    private int page = 1;
53
    private LoadingDialog loadingDialog;
50
54
51
    @Override
55
    @Override
52
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
56
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
57
    }
61
    }
58
62
59
    private void initViews() {
63
    private void initViews() {
64
        loadingDialog = new LoadingDialog(getContext());
65
        loadingDialog.setCanceledOnTouchOutside(false);
60
        refreshView = view.findViewById(R.id.chat_x_refresh_view);
66
        refreshView = view.findViewById(R.id.chat_x_refresh_view);
61
        refreshView.setPullLoadEnable(true);
67
        refreshView.setPullLoadEnable(true);
62
        recyclerView = view.findViewById(R.id.recycler_view_test_rv);
68
        recyclerView = view.findViewById(R.id.recycler_view_test_rv);
116
                if (type == 2) {
122
                if (type == 2) {
117
123
118
                }
124
                }
125
                // TODO
119
126
120
                Log.d(TAG, "onItemClickListener: position:" + position + ",type:" + type);
127
                Log.d(TAG, "onItemClickListener: position:" + position + ",type:" + type);
121
            }
128
            }
151
    public void onClick(View view) {
158
    public void onClick(View view) {
152
        switch (view.getId()) {
159
        switch (view.getId()) {
153
            case R.id.iv_ask: // 推荐分享
160
            case R.id.iv_ask: // 推荐分享
154
                if (MainApplication.isLogin()){
155
                    chat_share_info_remind.setVisibility(View.GONE);
156
                    ProfileManager.getInstance().setFirstComeIn(getActivity(), "label");
157
                    startActivity(new Intent(getActivity(), PublishItemsActivity.class));
161
                if (MainApplication.isLogin()) {
162
                    loginSign();
158
                } else {
163
                } else {
159
                    startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
164
                    startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
160
                    ToastUtil.showToast(getActivity().getApplicationContext(),"请先登录", Toast.LENGTH_SHORT);
165
                    ToastUtil.showToast(getActivity().getApplicationContext(), "请先登录", Toast.LENGTH_SHORT);
161
                }
166
                }
162
                break;
167
                break;
163
        }
168
        }
164
    }
169
    }
165
170
171
    // 服务器签名验证
172
    private void loginSign() {
173
        String url = MainApplication.urlNew + "/topic/sign.do";
174
        final Map<String, String> map = new HashMap<>();
175
        map.put("fileNames", "xxx");
176
        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
    public void refreshList() {
208
    public void refreshList() {
167
        if (view == null)
209
        if (view == null)
168
            return;
210
            return;
176
218
177
        Map<String, String> map = new HashMap<>();
219
        Map<String, String> map = new HashMap<>();
178
        map.put("selected", "1");
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
        OkHttpUtils.get().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
224
        OkHttpUtils.get().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
183
            @Override
225
            @Override
184
            public void onError(Call call, Exception e) {
226
            public void onError(Call call, Exception e) {
188
                    refreshView.stopLoadMore();
230
                    refreshView.stopLoadMore();
189
                }
231
                }
190
                if (getActivity() != null) {
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
            @Override
237
            @Override
196
            public void onResponse(String response) {
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
                    chatRecommendAdapter.setHeaderData(topicData);
244
                    chatRecommendAdapter.setHeaderData(topicData);
203
                    requestData();
245
                    requestData();
204
                } else {
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
    private void requestData() {
253
    private void requestData() {
212
        String url = MainApplication.urlNew + "/topic/info/list.do";
254
        String url = MainApplication.urlNew + "/topic/info/list.do";
213
        Map<String, String> map = new HashMap<>();
255
        Map<String, String> map = new HashMap<>();
214
        if (MainApplication.isLogin()) {
215
            map.put("userId", MainApplication.userId);
216
        }
217
        map.put("page", page + "");
256
        map.put("page", page + "");
218
        map.put("limit", "20");
257
        map.put("limit", "20");
258
        CommonParams.addCommonParams(map);
219
259
220
        if (MainApplication.isLogin()) {
221
            map.put("user_id", MainApplication.userId);
222
        }
223
        OkHttpUtils.get().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
260
        OkHttpUtils.get().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
224
            @Override
261
            @Override
225
            public void onError(Call call, Exception e) {
262
            public void onError(Call call, Exception e) {
238
                } else {
275
                } else {
239
                    refreshView.stopLoadMore();
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
                    if (page == 1) {
283
                    if (page == 1) {
247
                        refreshView.setLoadComplete(false);
284
                        refreshView.setLoadComplete(false);
248
                        chatRecommendAdapter.setData(chatRecommendBeans);
285
                        chatRecommendAdapter.setData(chatRecommendBeans);
254
                        refreshView.setLoadComplete(true);
291
                        refreshView.setLoadComplete(true);
255
                    }
292
                    }
256
                } else {
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
        });

+ 13 - 11
app/src/main/java/com/electric/chargingpile/util/CommonParams.java

4
4
5
import com.electric.chargingpile.BuildConfig;
5
import com.electric.chargingpile.BuildConfig;
6
import com.electric.chargingpile.application.MainApplication;
6
import com.electric.chargingpile.application.MainApplication;
7
import com.electric.chargingpile.manager.ProfileManager;
7
8
8
import java.util.Map;
9
import java.util.Map;
9
10
13
    public static void addCommonParams(Map<String, String> map) {
14
    public static void addCommonParams(Map<String, String> map) {
14
        if (MainApplication.isLogin()) {
15
        if (MainApplication.isLogin()) {
15
            map.put("userId", MainApplication.userId);
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
//            map.put("tpToken", "");
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
//            map.put("deviceSysVar", "");
28
//            map.put("deviceSysVar", "");
26
//            map.put("lng",);
29
//            map.put("lng",);
27
//            map.put("lat",);
30
//            map.put("lat",);
28
            // 2g 3g 4g wifi等
31
        // 2g 3g 4g wifi等
29
//            map.put("network",);
32
//            map.put("network",);
30
            // 网络运营商  移动  联通等
33
        // 网络运营商  移动  联通等
31
//            map.put("networkOperator", "");
34
//            map.put("networkOperator", "");
32
        }
33
35
34
    }
36
    }
35
}
37
}

+ 2 - 0
app/src/main/res/layout/activity_publish_picture_content.xml

55
        <View
55
        <View
56
            android:layout_width="match_parent"
56
            android:layout_width="match_parent"
57
            android:layout_height="0.5dp"
57
            android:layout_height="0.5dp"
58
            android:visibility="gone"
58
            android:background="@color/title_line"/>
59
            android:background="@color/title_line"/>
59
    </RelativeLayout>
60
    </RelativeLayout>
60
    
61
    
106
        android:layout_height="0.5dp"
107
        android:layout_height="0.5dp"
107
        android:background="@color/Line"
108
        android:background="@color/Line"
108
        android:layout_below="@+id/noScrollgridview"
109
        android:layout_below="@+id/noScrollgridview"
110
        android:visibility="gone"
109
        android:layout_marginTop="12dp"/>
111
        android:layout_marginTop="12dp"/>
110

112

111

113