582
        if (commentsBean != null) {
583
            childCommentUrl = "&parentid=" + commentsBean.getId() + "&puserid=" + commentsBean.getUserid();
651
        String url = MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/add";
652
        Map<String,String> map=new HashMap<>();
653
        map.put("userid",MainApplication.userId);
654
        map.put("zhanid",zhan_id);
655
        map.put("comment",URLEncoder.encode(et_pinglun.getText().toString()));
656
        map.put("tel",MainApplication.userPhone);
657
        map.put("token",URLEncoder.encode(DES3.encode(token)));
658
        if (topicText!=null){
659
            map.put("theme",topicText.getText().toString());
584 660
        }
585
        String url = "";
586
        if (commentType == 1) {
587 661
588
            url = MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/add?userid=" + MainApplication.userId + "&zhanid=" + zhan_id + "&comment=" + URLEncoder.encode(et_pinglun.getText().toString()) + "&tel=" + MainApplication.userPhone + "&token=" + URLEncoder.encode(DES3.encode(token)) + "&fileUrl=" + fileUrl + "&thumUrl=" + thumUrl;
589
            Log.d("url!!!", url);
590
        } else if (commentType == 2) {
591
            url = MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/add?userid=" + MainApplication.userId + "&zhanid=" + zhan_id + "&comment=" + URLEncoder.encode(et_pinglun.getText().toString()) + "&tel=" + MainApplication.userPhone + "&token=" + URLEncoder.encode(DES3.encode(token)) + childCommentUrl;
592
//            url = "http://59.110.68.162/zhannew/basic/web/index.php/tpappcomments/add?userid=" + MainApplication.userId + "&zhanid=" + zhan_id + "&comment=" + URLEncoder.encode(et_pinglun.getText().toString()) + "&tel=" + MainApplication.userPhone + "&token=" + URLEncoder.encode(DES3.encode(token)) + childCommentUrl;
593
            Log.d("url###", url);
662
        if (commentType == 1){
663
            if (fileUrlList.size()>0){
664
                for (int i = 0; i < fileUrlList.size(); i++) {
665
                    String value = fileUrlList.get(i);
666
                    if (i == 0){
667
                        map.put("fileUrl",value);
668
                    }else{
669
                        map.put("file"+(i+1)+"Url", value);
670
                    }
671
                }
672
                map.put("thumUrl",fileUrlList.get(0));
673
            }
674
675
        }else  if (commentType == 2) {
676
            if (commentsBean != null) {
677
                map.put("parentid",commentsBean.getId());
678
                map.put("puserid", commentsBean.getUserid());
679
            }
594 680
        }
595
        Log.d("url++++", url);
681
682
683
596 684
        OkHttpUtils.get()
685
                .params(map)
597 686
                .url(url)
598 687
                .build()
599 688
                .execute(new StringCallback() {
@ -604,7 +693,7 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
604 693
605 694
                    @Override
606 695
                    public void onResponse(String response) {
607
                        Log.e("comment", response);
696
//                        Log.e("comment", response);
608 697
                        String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
609 698
                        String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
610 699
                        dialog.cancel();
@ -688,25 +777,37 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
688 777
                }
689 778
                if (MainApplication.isLogin()) {
690 779
                    try {
691
                        if (Bimp.tempSelectBitmap.size() > 0) {
780
                        if (Bimp.tempSelectMedia.size() > 0 && mInsterType == 1) {
692 781
                            dialog.show();
693 782
                            new Thread(new Runnable() {
694 783
                                @Override
695 784
                                public void run() {
696 785
                                    try {
697
//                                        shite("");
786
                                        shite("");
698 787
                                    } catch (Exception e) {
699 788
                                        e.printStackTrace();
700 789
                                    }
701 790
                                }
702 791
                            }).start();
703 792
793
                        } else if (Bimp.tempSelectMedia.size() > 0 && mInsterType == 2) {
794
                            //进行视频验证
795
                            LocalMedia media = Bimp.tempSelectMedia.get(0);
796
                            String path = "";
797
                            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q)
798
                                path = media.getAndroidQToPath();
799
                            else {
800
                                path = media.getPath();
801
                            }
802
803
804
                            getYouPaiData(path);
704 805
                        } else {
705 806
                            if (containsEmoji(et_pinglun.getText().toString())) {
706 807
                                ToastUtil.showToast(MainApplication.context, "不支持输入表情", Toast.LENGTH_SHORT);
707 808
                            } else {
708 809
                                dialog.show();
709
                                addComment("", "");
810
                                addComment(new ArrayList<>(), "");
710 811
                            }
711 812
                        }
712 813
                    } catch (Exception e) {
@ -731,7 +832,136 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
731 832
        }
732 833
    }
733 834
734
    private void addImg(){
835
    private void getYouPaiData(String filePath) {
836
        dialog.show();
837
838
//        String url = MainApplication.urlNew + "/get-sign-rest";
839
        String url = MainApplication.d1evTestUrl + "/api/topic/get-sign-rest2cdz";
840
        if (TextUtils.isEmpty(filePath)) {
841
            ToastUtil.showToast(getApplicationContext(), "请重新选择视频", Toast.LENGTH_SHORT);
842
            return;
843
        }
844
845
        String deviceId = JPushInterface.getUdid(MainApplication.context);
846
        String fileName = DateUtils.getSimpleCurrentDate();
847
        if (TextUtils.isEmpty(deviceId)) {
848
            fileName += "_" + Util.getRandom(15);
849
        } else {
850
            fileName += "_" + deviceId;
851
        }
852
853
        if (TextUtils.isEmpty(filePath)) {
854
            fileName = "";
855
        } else {
856
            String suffix = filePath.substring(filePath.lastIndexOf(".") + 1);
857
            fileName += "." + suffix;
858
        }
859
860
861
        Map<String, String> map = new HashMap<>();
862
        map.put("fileName", fileName);
863
        try {
864
            FileInputStream fileInputStream = new FileInputStream(new File(filePath));
865
            map.put("contentLength", String.valueOf(fileInputStream.available()));
866
        } catch (Exception e) {
867
            e.printStackTrace();
868
        }
869
        map.put("targetType", ChatRecommendBean.TARGET_TYPE_VIDEO + "");
870
        CommonParams.addCommonParams(map);
871
872
        String finalFileName = fileName;
873
        OkHttpUtils.get()
874
                .params(map)
875
                .url(url)
876
                .build()
877
                .connTimeOut(6000)
878
                .readTimeOut(6000)
879
                .execute(new StringCallback() {
880
                    @Override
881
                    public void onError(Call call, Exception e) {
882
                        ToastUtil.showToast(getApplicationContext(), "发布失败,请重试", Toast.LENGTH_SHORT);
883
                        dialog.dismiss();
884
                    }
885
886
                    @Override
887
                    public void onResponse(String response) {
888
                        Log.e("hyc--", response);
889
                        String code = JsonUtils.getKeyResult(response, "code");
890
                        String desc = JsonUtils.getKeyResult(response, "desc");
891
                        if ("1000".equals(code)) {
892
                            String data = JsonUtils.getKeyResult(response, "data");
893
                            signBeans = (AuthSignBean) JsonUtils.parseToObjectBean(data, AuthSignBean.class);
894
                            if (null != signBeans) {
895
                                String sign = signBeans.sign;
896
                                String policy = signBeans.policy;
897
                                formUpload(filePath, sign, policy, finalFileName);
898
                            } else {
899
                                ToastUtil.showToast(getApplicationContext(), desc, Toast.LENGTH_SHORT);
900
                            }
901
                        } else {
902
                            ToastUtil.showToast(getApplicationContext(), desc, Toast.LENGTH_SHORT);
903
                            dialog.dismiss();
904
                        }
905
                    }
906
                });
907
908
    }
909
910
    /**
911
     * 表单上传
912
     *
913
     * @param SAMPLE_PIC_FILE
914
     * @param sign
915
     * @param policyServer
916
     */
917
    private void formUpload(String SAMPLE_PIC_FILE, String sign, String policyServer, String fileName) {
918
919
        if (serialUploader == null) {
920
            serialUploader = new SerialUploader();
921
        }
922
923
        serialUploader.setCheckMD5(false);
924
925
        File temp = new File(SAMPLE_PIC_FILE);
926
927
        serialUploader.setOnProgressListener((bytesWrite, contentLength) -> {
928
929
        });
930
        String decoder = new String(Base64.decode((policyServer), Base64.DEFAULT));
931
932
        JSONObject jsonObject = null;
933
        try {
934
            jsonObject = new JSONObject(decoder);
935
        } catch (JSONException e) {
936
            e.printStackTrace();
937
        }
938
        String uri = jsonObject.optString("URI");
939
        String date = jsonObject.optString("Date");
940
        String operator = jsonObject.optString("Operator");
941
        String saveKey = jsonObject.optString("save-key");
942
943
        serialUploader.upload(
944
                temp, uri, date, "UPYUN " + operator + ":" + sign, null, new UpCompleteListener() {
945
                    @Override
946
                    public void onComplete(boolean isSuccess, String result) {
947
                        if (isSuccess) {
948
                            try {
949
                                ArrayList<String> list = new ArrayList<>();
950
                                list.add(saveKey);
951
                                addComment(list, saveKey);
952
                            } catch (Exception e) {
953
                                e.printStackTrace();
954
                            }
955
                        } else {
956
                            ToastUtil.showToast(getApplicationContext(), "发布失败,请重试", Toast.LENGTH_SHORT);
957
                            dialog.dismiss();
958
                        }
959
960
                    }
961
                });
962
    }
963
964
    private void addImg() {
735 965
        PictureSelector.create(this)
736 966
                .openGallery(PictureMimeType.ofImage())
737 967
                .maxSelectNum(PIC_NUM)
@ -753,7 +983,8 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
753 983
                .isAutomaticTitleRecyclerTop(true)//图片列表超过一屏连续点击顶部标题栏快速回滚至顶部
754 984
                .forResult(REQUEST_CODE_CHOOSE);
755 985
    }
756
    private void addVideo(){
986
987
    private void addVideo() {
757 988
        PictureSelector.create(this)
758 989
                .openGallery(PictureMimeType.ofVideo())
759 990
                .selectionMode(PictureConfig.SINGLE)
@ -775,7 +1006,7 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
775 1006
                .recordVideoSecond(15)//录制视频秒数 默认60s
776 1007
                .isPreviewVideo(true)//是否预览视频
777 1008
                .isSingleDirectReturn(true)//PictureConfig.SINGLE模式下是否直接返回
778
              //  .filterMaxFileSize(100)//查询指定大小内的图片、视频、音频大小,单位M
1009
                //  .filterMaxFileSize(100)//查询指定大小内的图片、视频、音频大小,单位M
779 1010
                .forResult(REQUEST_VIDEO_CODE_CHOOSE);
780 1011
    }
781 1012
@ -820,27 +1051,27 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
820 1051
821 1052
    @Override
822 1053
    public void add() {
823
        if (mInsterType == 1){
1054
        if (mInsterType == 1) {
824 1055
            addImg();
825
        }else if (mInsterType == 2){
1056
        } else if (mInsterType == 2) {
826 1057
            addVideo();
827 1058
        }
828 1059
    }
829 1060
830 1061
    @Override
831 1062
    public void remove(int position) {
832
        if (mAdapter.getItemCount() == 1){
1063
        if (mAdapter.getItemCount() == 1) {
833 1064
            setLayoutHintVisible(-1);
834
            mInsterType=-1;
1065
            mInsterType = -1;
835 1066
        }
836 1067
837 1068
    }
838 1069
839 1070
    @Override
840 1071
    public void open(int position, LocalMedia mLocalMedia) {
841
        if (mInsterType == 1){
842
            ImageDisplayActivity.actionStart(this,position);
843
        }else if (mInsterType == 2){
1072
        if (mInsterType == 1) {
1073
            ImageDisplayActivity.actionStart(this, position);
1074
        } else if (mInsterType == 2) {
844 1075
            PictureSelector.create(ZhanCommentActivity.this)
845 1076
                    .themeStyle(R.style.picture_default_style)
846 1077
                    .setPictureStyle(Util.getWhiteStyle(ZhanCommentActivity.this))// 动态自定义相册主题
@ -848,6 +1079,7 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
848 1079
        }
849 1080
    }
850 1081
1082
851 1083
    public class MyTopic extends RObject {
852 1084
        private String id;
853 1085
@ -877,6 +1109,73 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
877 1109
        Bimp.tempSelectMedia.clear();
878 1110
    }
879 1111
1112
    private String bitmapToBase64(Bitmap bitmap) {
1113
1114
        String result = null;
1115
        ByteArrayOutputStream baos = null;
1116
        try {
1117
            if (bitmap != null) {
1118
                baos = new ByteArrayOutputStream();
1119
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
1120
                baos.flush();
1121
                baos.close();
1122
                byte[] bitmapBytes = baos.toByteArray();
1123
                result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT);
1124
            }
1125
        } catch (IOException e) {
1126
            e.printStackTrace();
1127
        } finally {
1128
            try {
1129
                if (baos != null) {
1130
                    baos.flush();
1131
                    baos.close();
1132
                }
1133
            } catch (IOException e) {
1134
                e.printStackTrace();
1135
            }
1136
        }
1137
        return result;
1138
    }
1139
1140
    private Bitmap imageZoom(Bitmap bm) {
1141
        // 图片允许最大空间 单位:KB
1142
        double maxSize = 200.00;
1143
        // 将bitmap放至数组中,意在bitmap的大小(与实际读取的原文件要大)
1144
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
1145
        bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
1146
        byte[] b = baos.toByteArray();
1147
        // 将字节换成KB
1148
        double mid = b.length / 1024;
1149
        // 判断bitmap占用空间是否大于允许最大空间 如果大于则压缩 小于则不压缩
1150
        if (mid > maxSize) {
1151
            // 获取bitmap大小 是允许最大大小的多少倍
1152
            double i = mid / maxSize;
1153
            // 开始压缩 此处用到平方根 将宽带和高度压缩掉对应的平方根倍
1154
            // (1.保持刻度和高度和原bitmap比率一致,压缩后也达到了最大大小占用空间的大小)
1155
            bm = zoomImage(bm, bm.getWidth() / Math.sqrt(i), bm.getHeight()
1156
                    / Math.sqrt(i));
1157
        }
1158
1159
        return bm;
1160
    }
1161
1162
    public Bitmap zoomImage(Bitmap bgimage, double newWidth, double newHeight) {
1163
        // 获取这个图片的宽和高
1164
        float width = bgimage.getWidth();
1165
        float height = bgimage.getHeight();
1166
        // 创建操作图片用的matrix对象
1167
        Matrix matrix = new Matrix();
1168
        // 计算宽高缩放率
1169
        float scaleWidth = ((float) newWidth) / width;
1170
        float scaleHeight = ((float) newHeight) / height;
1171
        // 缩放图片动作
1172
        matrix.postScale(scaleWidth, scaleHeight);
1173
        Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width,
1174
                (int) height, matrix, true);
1175
//        iv_2.setImageBitmap(bitmap);
1176
//        tv_2.setText(bitmap.getRowBytes() * bitmap.getHeight() + "");
1177
        return bitmap;
1178
    }
880 1179
881 1180
    class NetworkChangeReceiver extends BroadcastReceiver {
882 1181
@ -904,12 +1203,12 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
904 1203
        }
905 1204
        mAdapter.notifyDataSetChanged();
906 1205
907
        if (mInsterType == 1 && mAdapter.getItemCount() == 1){
1206
        if (mInsterType == 1 && mAdapter.getItemCount() == 1) {
908 1207
            setLayoutHintVisible(-1);
909
            mInsterType=-1;
910
        }else if (mInsterType == 2 && mAdapter.getItemCount() == 0){
1208
            mInsterType = -1;
1209
        } else if (mInsterType == 2 && mAdapter.getItemCount() == 0) {
911 1210
            setLayoutHintVisible(-1);
912
            mInsterType=-1;
1211
            mInsterType = -1;
913 1212
        }
914 1213
915 1214
    }
@ -944,4 +1243,38 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
944 1243
                && (codePoint <= 0x10FFFF));
945 1244
    }
946 1245
1246
    /**
1247
     * 将json 数组转换为Map 对象
1248
     *
1249
     * @param jsonString
1250
     * @return
1251
     */
1252
1253
    public static Map<String, Object> getMap(String jsonString) {
1254
        JSONObject jsonObject;
1255
        Map<String, Object> valueMap = new HashMap<String, Object>();
1256
        if (TextUtils.isEmpty(jsonString)) {
1257
            return valueMap;
1258
        }
1259
        try {
1260
            jsonObject = new JSONObject(jsonString);
1261
            @SuppressWarnings("unchecked")
1262
            Iterator<String> keyIter = jsonObject.keys();
1263
            String key;
1264
            Object value;
1265
1266
            while (keyIter.hasNext()) {
1267
                key = (String) keyIter.next();
1268
                value = jsonObject.get(key);
1269
                valueMap.put(key, value);
1270
            }
1271
            return valueMap;
1272
        } catch (JSONException e) {
1273
            e.printStackTrace();
1274
        }
1275
1276
        return valueMap;
1277
1278
    }
1279
947 1280
}

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

@ -97,6 +97,8 @@ public class MainApplication extends MultiDexApplication {
97 97
//    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
98 98

99 99
        public static String urlNew = "http://123.56.67.7:83/api/0300";// 一电测试环境
100
        public static String d1evTestUrl = "https://d1ev-new.yiduyongche.com";// 一电测试环境
101
        public static String CDN = "https://cdn-fs.d1ev.com";
100 102
//    public static String urlNew = "https://api.touchev.com:83/api/0300";// 一电正式环境
101 103

102 104


完成发现页面 · 4d3b61ff10 - Gogs: Go Git Service
Przeglądaj źródła

完成发现页面

hy 3 lat temu
rodzic
commit
4d3b61ff10

BIN
app/src/main/res/drawable-xxhdpi/icon_main_qa.png


BIN
app/src/main/res/drawable-xxhdpi/icon_main_qa_selected.png


BIN
app/src/main/res/drawable-xxhdpi/icon_main_qa_selected.webp


+ 1 - 1
app/src/main/res/layout/activity_chat.xml

@ -157,7 +157,7 @@
157 157
                android:layout_height="wrap_content"
158 158
                android:layout_gravity="center_horizontal"
159 159
                android:layout_marginTop="8dp"
160
                android:src="@drawable/app_tab_chat_icon1" />
160
                android:src="@drawable/icon_main_qa_selected" />
161 161
            <!--android:src="@drawable/icon_main_qa_selected" />-->
162 162
163 163
            <TextView

+ 1 - 1
app/src/main/res/layout/activity_find.xml

@ -18,7 +18,7 @@
18 18
    <com.electric.chargingpile.view.SlideFindView
19 19
        android:id="@+id/ll_ad"
20 20
        android:layout_width="match_parent"
21
        android:layout_height="436px"
21
        android:layout_height="170dp"
22 22
        android:layout_below="@+id/view_title"
23 23
        android:layout_gravity="center"
24 24
        android:background="@drawable/bg_find_banner"