浏览代码

完成话题选择页无数据状态,完成充电完成后的评论流程

hy 2 年之前
父节点
当前提交
48eb07bf98

+ 467 - 405
app/src/main/java/com/electric/chargingpile/activity/ChargingCommentActivity.java

@ -11,11 +11,14 @@ import android.graphics.Color;
11 11
import android.graphics.Matrix;
12 12
import android.graphics.drawable.BitmapDrawable;
13 13
import android.graphics.drawable.ColorDrawable;
14
import android.graphics.drawable.Drawable;
14 15
import android.os.Build;
15 16
import android.os.Bundle;
16 17
import android.os.Handler;
17 18
import android.os.Message;
18 19
import android.text.Editable;
20
import android.text.Html;
21
import android.text.TextUtils;
19 22
import android.text.TextWatcher;
20 23
import android.util.Base64;
21 24
import android.util.Log;
@ -29,44 +32,68 @@ import android.widget.AdapterView;
29 32
import android.widget.BaseAdapter;
30 33
import android.widget.GridView;
31 34
import android.widget.ImageView;
35
import android.widget.LinearLayout;
32 36
import android.widget.PopupWindow;
33 37
import android.widget.RelativeLayout;
34 38
import android.widget.ScrollView;
35 39
import android.widget.TextView;
36 40
import android.widget.Toast;
37 41
42
import androidx.annotation.Nullable;
43
import androidx.appcompat.app.AppCompatActivity;
44
import androidx.recyclerview.widget.GridLayoutManager;
45
import androidx.recyclerview.widget.RecyclerView;
46
38 47
import com.blankj.utilcode.util.CacheUtils;
39 48
import com.blankj.utilcode.util.EmptyUtils;
40 49
import com.blankj.utilcode.util.LogUtils;
50
import com.bumptech.glide.Glide;
51
import com.bumptech.glide.load.DataSource;
52
import com.bumptech.glide.load.engine.GlideException;
53
import com.bumptech.glide.request.RequestListener;
54
import com.bumptech.glide.request.target.Target;
41 55
import com.electric.chargingpile.R;
56
import com.electric.chargingpile.adapter.GridImageAdapter;
42 57
import com.electric.chargingpile.application.MainApplication;
58
import com.electric.chargingpile.data.AuthSignBean;
43 59
import com.electric.chargingpile.data.ChargingShareBean;
60
import com.electric.chargingpile.data.ChatRecommendBean;
44 61
import com.electric.chargingpile.data.CommentsBean;
45 62
import com.electric.chargingpile.data.RObject;
63
import com.electric.chargingpile.data.TopicBean;
46 64
import com.electric.chargingpile.engine.GlideEngine;
47 65
import com.electric.chargingpile.util.BarColorUtil;
48 66
import com.electric.chargingpile.util.Bimp;
67
import com.electric.chargingpile.util.CommonParams;
49 68
import com.electric.chargingpile.util.DES3;
69
import com.electric.chargingpile.util.DateUtils;
70
import com.electric.chargingpile.util.DensityUtil;
50 71
import com.electric.chargingpile.util.ImageItem;
51 72
import com.electric.chargingpile.util.JsonUtils;
52 73
import com.electric.chargingpile.util.LoadingDialog;
53 74
import com.electric.chargingpile.util.Md5Util;
54 75
import com.electric.chargingpile.util.PublicWayONE;
55 76
import com.electric.chargingpile.util.Res;
77
import com.electric.chargingpile.util.ScreenUtils;
56 78
import com.electric.chargingpile.util.StatusConstants;
57 79
import com.electric.chargingpile.util.ToastUtil;
58 80
import com.electric.chargingpile.util.UploadUtil;
59 81
import com.electric.chargingpile.util.Util;
82
import com.electric.chargingpile.view.CommentHintDialog;
60 83
import com.electric.chargingpile.view.HongBaoDialog;
61 84
import com.electric.chargingpile.view.HongBaoResultDialog;
62 85
import com.electric.chargingpile.view.REditText;
63 86
import com.electric.chargingpile.view.RatingBarView;
87
import com.google.gson.Gson;
88
import com.google.gson.reflect.TypeToken;
64 89
import com.luck.picture.lib.PictureSelector;
65 90
import com.luck.picture.lib.animators.AnimationType;
66 91
import com.luck.picture.lib.config.PictureConfig;
67 92
import com.luck.picture.lib.config.PictureMimeType;
68 93
import com.luck.picture.lib.entity.LocalMedia;
69 94
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
95
import com.upyun.library.common.SerialUploader;
96
import com.upyun.library.listener.UpCompleteListener;
70 97
import com.zhy.http.okhttp.OkHttpUtils;
71 98
import com.zhy.http.okhttp.callback.StringCallback;
72 99
import com.zhy.view.flowlayout.FlowLayout;
@ -78,6 +105,7 @@ import org.json.JSONObject;
78 105
79 106
import java.io.ByteArrayOutputStream;
80 107
import java.io.File;
108
import java.io.FileInputStream;
81 109
import java.io.IOException;
82 110
import java.net.URLEncoder;
83 111
import java.util.ArrayList;
@ -88,6 +116,7 @@ import java.util.Set;
88 116
import java.util.regex.Matcher;
89 117
import java.util.regex.Pattern;
90 118
119
import cn.jpush.android.api.JPushInterface;
91 120
import cn.sharesdk.framework.Platform;
92 121
import cn.sharesdk.framework.PlatformActionListener;
93 122
import cn.sharesdk.framework.ShareSDK;
@ -105,9 +134,11 @@ import okhttp3.Call;
105 134
import pub.devrel.easypermissions.AfterPermissionGranted;
106 135
import pub.devrel.easypermissions.EasyPermissions;
107 136
108
public class ChargingCommentActivity extends Activity implements View.OnClickListener, PlatformActionListener, EasyPermissions.PermissionCallbacks {
137
import static android.text.Html.FROM_HTML_MODE_LEGACY;
138
139
public class ChargingCommentActivity extends AppCompatActivity implements View.OnClickListener, PlatformActionListener, EasyPermissions.PermissionCallbacks, GridImageAdapter.GridImgListener {
109 140
    private static final String TAG = "ChargingCommentActivity";
110
    private static final int PIC_NUM = 1;
141
    private static final int PIC_NUM = 3;
111 142
    private ProgressDialog insertDialog;
112 143
    public static CommentsBean commentsBean;
113 144
    public static int commentType = 1;
@ -121,7 +152,7 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
121 152
    private String show_txt = "";
122 153
    private RelativeLayout rl_huodong, rl_comment;
123 154
    private RatingBarView ratingBarView;
124
    private ImageView iv_back;
155
    private ImageView iv_back,imgAd;
125 156
    private LoadingDialog dialog;
126 157
    private String[] stringArr;
127 158
    private String[] mValss = new String[]{MainApplication.huodonglabel};
@ -129,52 +160,51 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
129 160
    List<String> list;
130 161
    private String select_s = "";
131 162
    private String select_ss = "";
132
    private TextView tv_grade;
163
    private TextView tv_grade, topicText, commentHint;
133 164
134 165
    public static Bitmap bimap;
135
136
    private GridView noScrollgridview;
166
    private GridImageAdapter mAdapter;
167
    private RecyclerView noScrollgridview;
137 168
    private ScrollView sv;
138
    private GridAdapter adapter;
169
139 170
    private static final int PHOTO_REQUEST_CAMERA = 1;
140 171
    private static final int PHOTO_REQUEST_GALLERY = 2;
141 172
    private static final int PHOTO_REQUEST_CUT = 3;
173
    private static final int REQUEST_TOPIC_CODE = 102;
142 174
    private InputMethodManager imm = null;
143 175
    private String url = "1", icon = "", title = "", text = " ";
144 176
    private String money = "";
145 177
    private TextView tv_point;
146 178
    private RelativeLayout rl_point;
179
    private LinearLayout layoutHint;
147 180
    private android.view.animation.Animation animation;
148 181
    private ChargingShareBean chargingShareBean;
149 182
    private String isShow = "0";
150 183
    private HongBaoDialog hongBaoDialog;
151 184
    private static final int RC_ALBUM_PERM = 123;
152 185
    public static final int REQUEST_CODE_CHOOSE = 335;
186
    public static final int REQUEST_VIDEO_CODE_CHOOSE = 337;
187
    public static final int IMG_ERROR = 12;
188
    public static final int IMGRESLUT = 2;
189
    private final Gson mGson = new Gson();
153 190
    //输入表情前EditText中的文本
154 191
//    private String inputAfterText;
155 192
    Handler handler = new Handler() {
156 193
        public void handleMessage(Message msg) {
157 194
            switch (msg.what) {
158
                case 2:
195
                case IMGRESLUT:
196
                    ArrayList<String> fileList =
197
                            mGson.fromJson(msg.obj.toString(),new TypeToken<ArrayList<String>>() {
198
                            }.getType());
159 199
                    try {
160
                        JSONObject jsonObject = new JSONObject(msg.obj.toString());
161
                        String code = jsonObject.getString("code");
162
                        if (code.equals("200")) {
163
                            Log.e("200==", "图片成功");
164
                            String fileUrl = jsonObject.getString("fileUrl");
165
                            String thumUrl = jsonObject.getString("thumUrl");
166
                            try {
167
                                addComments(fileUrl, thumUrl);
168
                            } catch (Exception e) {
169
                                e.printStackTrace();
170
                            }
171
                        } else {
172
                            Toast.makeText(ChargingCommentActivity.this, "评论失败", Toast.LENGTH_SHORT).show();
173
                        }
174
                    } catch (JSONException e) {
200
                        addComments(fileList, "");
201
                    } catch (Exception e) {
175 202
                        e.printStackTrace();
176 203
                    }
177 204
                    break;
205
                case IMG_ERROR:
206
                    ToastUtil.showToast(getApplicationContext(), "图片上传失败", Toast.LENGTH_SHORT);
207
                    break;
178 208
                case StatusConstants.REQUEST_WHAT_SUCCESS:
179 209
180 210
@ -184,6 +214,13 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
184 214
        }
185 215
    };
186 216
    private List<LocalMedia> mSelectionData =new ArrayList<LocalMedia>();
217
218
219
    private int mInsterType = -1; //1 插入图片 2 插入视频 -1 未插入数据
220
221
222
    private TopicBean mTopicbean;
223
187 224
    @Override
188 225
    protected void onCreate(Bundle savedInstanceState) {
189 226
        super.onCreate(savedInstanceState);
@ -192,17 +229,13 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
192 229
        dialog = new LoadingDialog(this);
193 230
        dialog.setCanceledOnTouchOutside(false);
194 231
        Res.init(this);
195
        bimap = BitmapFactory.decodeResource(
196
                getResources(),
197
                R.drawable.addpic65);
198
        PublicWayONE.activityList.add(this);
232
199 233
        if (null == imm) {
200 234
            imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
201 235
        }
202 236
203 237
        initViews();
204 238
        getDatas();
205
206 239
        Init();
207 240
    }
208 241
@ -216,6 +249,16 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
216 249
        tv_zhan_name = (TextView) findViewById(R.id.tv_zhan_name);
217 250
//        iv_hongbao = (ImageView) findViewById(R.id.iv_hongbao);
218 251
//        iv_hongbao.setOnClickListener(this);
252
253
        layoutHint = (LinearLayout) findViewById(R.id.layoutHint);
254
        findViewById(R.id.imgUpload).setOnClickListener(this);
255
        findViewById(R.id.videoUpLoad).setOnClickListener(this);
256
        commentHint = (TextView) findViewById(R.id.commentHint);
257
        topicText = (TextView) findViewById(R.id.topicText);
258
        imgAd = (ImageView) findViewById(R.id.imgAd);
259
        commentHint.setText(Html.fromHtml("30字以上+图片或15s视频有机会被<font color='#3EC34C'>评为优质评论获得充电优惠券</font>", FROM_HTML_MODE_LEGACY));
260
261
219 262
        rl_comment = (RelativeLayout) findViewById(R.id.rl_comment);
220 263
        sv = (ScrollView) findViewById(R.id.sv);
221 264
        rl_huodong = (RelativeLayout) findViewById(R.id.rl_huodong);
@ -247,7 +290,17 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
247 290
248 291
            @Override
249 292
            public void afterTextChanged(Editable s) {
250
                if (containsEmoji(s.toString())) {
293
                String s1 = et_pinglun.getText().toString();
294
                s1= s1.replace(" " ,"");
295
                if (s1.length() > 0){
296
                    tv_make_sure.setTextColor(getResources().getColor(R.color.lvse));
297
                    tv_make_sure.setEnabled(true);
298
                }else{
299
                    tv_make_sure.setTextColor(getResources().getColor(R.color.huise));
300
                    tv_make_sure.setEnabled(false);
301
                }
302
303
                /*if (containsEmoji(s.toString())) {
251 304
                    Toast.makeText(MainApplication.context, "不支持输入表情", Toast.LENGTH_SHORT).show();
252 305
                }
253 306
                if (et_pinglun.getText().toString().equals("") && NewZhanDetailsActivity.replaceBlank(et_pinglun.getText().toString()).equals("")) {
@ -273,7 +326,7 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
273 326
                        tv_make_sure.setEnabled(true);
274 327
                    }
275 328
276
                }
329
                }*/
277 330
                if (!et_pinglun.getText().toString().contains("#" + MainApplication.huodonglabel + "#")) {
278 331
                    final LayoutInflater mInflater = LayoutInflater.from(getApplicationContext());
279 332
                    mFlowLayoutTwo.setAdapter(new TagAdapter<String>(mValss) {
@ -300,29 +353,7 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
300 353
                star_level = String.valueOf(RatingScore);
301 354
                mFlowLayout.setVisibility(View.VISIBLE);
302 355
                select_s = "";
303
                if (et_pinglun.getText().toString().equals("") && NewZhanDetailsActivity.replaceBlank(et_pinglun.getText().toString()).equals("")) {
304
                    if (!star_level.equals("") && !select_s.equals("")) {
305
                        tv_make_sure.setTextColor(getResources().getColor(R.color.lvse));
306
                        tv_make_sure.setEnabled(true);
307
                    } else {
308
                        tv_make_sure.setTextColor(getResources().getColor(R.color.huise));
309
                        tv_make_sure.setEnabled(false);
310
                    }
311
                } else {
312
                    if (et_pinglun.getText().toString().equals("#" + MainApplication.huodonglabel + "# ")) {
313
                        if (!star_level.equals("") && !select_s.equals("")) {
314
                            tv_make_sure.setTextColor(getResources().getColor(R.color.lvse));
315
                            tv_make_sure.setEnabled(true);
316
                        } else {
317
                            tv_make_sure.setTextColor(getResources().getColor(R.color.huise));
318
                            tv_make_sure.setEnabled(false);
319
                        }
320
                    } else {
321
                        tv_make_sure.setTextColor(getResources().getColor(R.color.lvse));
322
                        tv_make_sure.setEnabled(true);
323
                    }
324 356
325
                }
326 357
                switch (RatingScore) {
327 358
                    case 1:
328 359
                        if (!MainApplication.level_one.equals("")) {
@ -395,31 +426,6 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
395 426
                    select_ss = MainApplication.huodonglabel;
396 427
                    setTopic();
397 428
                }
398
                if (et_pinglun.getText().toString().equals("") && NewZhanDetailsActivity.replaceBlank(et_pinglun.getText().toString()).equals("")) {
399
                    if (!star_level.equals("") && !select_s.equals("")) {
400
                        tv_make_sure.setTextColor(getResources().getColor(R.color.lvse));
401
                        tv_make_sure.setEnabled(true);
402
                    } else {
403
                        tv_make_sure.setTextColor(getResources().getColor(R.color.huise));
404
                        tv_make_sure.setEnabled(false);
405
                    }
406
                } else {
407
                    if (et_pinglun.getText().toString().equals("#" + MainApplication.huodonglabel + "# ")) {
408
//                        tv_make_sure.setBackgroundResource(R.color.huise);
409
//                        tv_make_sure.setEnabled(false);
410
                        if (!star_level.equals("") && !select_s.equals("")) {
411
                            tv_make_sure.setTextColor(getResources().getColor(R.color.lvse));
412
                            tv_make_sure.setEnabled(true);
413
                        } else {
414
                            tv_make_sure.setTextColor(getResources().getColor(R.color.huise));
415
                            tv_make_sure.setEnabled(false);
416
                        }
417
                    } else {
418
                        tv_make_sure.setTextColor(getResources().getColor(R.color.lvse));
419
                        tv_make_sure.setEnabled(true);
420
                    }
421
422
                }
423 429
//                Toast.makeText(getApplicationContext(), mVals[position], Toast.LENGTH_SHORT).show();
424 430
                return true;
425 431
            }
@ -428,77 +434,54 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
428 434
            @Override
429 435
            public void onSelected(Set<Integer> selectPosSet) {
430 436
431
432 437
//                Toast.makeText(getApplicationContext(), "choose:" + selectPosSet.toString(), Toast.LENGTH_SHORT).show();
433 438
434 439
            }
435 440
        });
436 441
442
        tv_zhan_name.setOnClickListener(v -> {
443
            CommentHintDialog.newInstart().show(getSupportFragmentManager());
444
        });
445
        topicText.setOnClickListener(v -> {
446
            //跳转至话题页
447
            SelectTopicActivity.actionStart(this, REQUEST_TOPIC_CODE);
448
        });
437 449
438
    }
439
440
    public void Init() {
441
442
        noScrollgridview = (GridView) findViewById(R.id.noScrollgridview);
443
        noScrollgridview.setSelector(new ColorDrawable(Color.TRANSPARENT));
444
        adapter = new GridAdapter(this);
445
        adapter.update();
446
        noScrollgridview.setAdapter(adapter);
447
        noScrollgridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
448
449
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
450
                                    long arg3) {
451
                imm.hideSoftInputFromWindow(arg1.getWindowToken(), 0);
452
                if (arg2 == Bimp.tempSelectBitmap.size()) {
453
                    permissionTask();
454
                } else {
455
                    Intent intent = new Intent(ChargingCommentActivity.this,
456
                            GalleryActivityCharging.class);
457
                    intent.putExtra("position", "1");
458
                    intent.putExtra("ID", arg2);
459
                    startActivity(intent);
450
        if (MainApplication.mAdComment!=null){
451
            String icon = MainApplication.mAdComment.getIcon();
452
            String adUrl = MainApplication.mAdComment.getUrl();
453
            Glide.with(this).load(MainApplication.url + "/zhannew/uploadfile/" + icon).listener(new RequestListener<Drawable>() {
454
                @Override
455
                public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
456
                    imgAd.setVisibility(View.GONE);
457
                    return false;
460 458
                }
461
            }
462
        });
463
    }
464 459
465
    /**
466
     * 调用图库选择
467
     */
468
    private void callGallery() {
469
/*
470
        Matisse.from(ChargingCommentActivity.this)
471
                .choose(MimeType.of(MimeType.JPEG, MimeType.PNG, MimeType.GIF))
472
                .showSingleMediaType(true)
473
                .countable(true)
474
                .maxSelectable(PIC_NUM - Bimp.tempSelectBitmap.size())
475
                .capture(true)
476
                .captureStrategy(new CaptureStrategy(true, "com.electric.chargingpile.provider"))
477
                .imageEngine(new GlideEngine())
478
                .forResult(REQUEST_CODE_CHOOSE);
479
*/
460
                @Override
461
                public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
462
                    imgAd.setVisibility(View.VISIBLE);
463
                    return false;
464
                }
465
            }).into(imgAd);
466
            imgAd.setOnClickListener(v->{
467
                Intent adfloatIntent = new Intent(this, MyWebViewActivity.class);
468
                adfloatIntent.putExtra("url", adUrl);
469
                startActivity(adfloatIntent);
470
            });
480 471
481
        PictureSelector.create(this)
482
                .openGallery(PictureMimeType.ofImage())
483
                .maxSelectNum(PIC_NUM)
484
                .selectionMode(PictureConfig.MULTIPLE)
485
                .selectionData(mSelectionData)//是否传入已选图片
486
                .isCompress(true)//是否压缩
487
                .isPreviewEggs(true)//预览图片时是否增强左右滑动图片体验
488
                .isGif(true)//是否显示gif
489
                .isAndroidQTransform(true)
490
                .imageEngine(GlideEngine.createGlideEngine())
491
                .isWeChatStyle(false)// 是否开启微信图片选择风格
492
                .isUseCustomCamera(false)// 是否使用自定义相机
493
                .isPageStrategy(true)// 是否开启分页策略 & 每页多少条;默认开启
494
                .setPictureStyle(Util.getWhiteStyle(this))// 动态自定义相册主题
495
                .setRecyclerAnimationMode(AnimationType.SLIDE_IN_BOTTOM_ANIMATION)// 列表动画效果
496
                .isMaxSelectEnabledMask(true)// 选择数到了最大阀值列表是否启用蒙层效果
497
                .imageSpanCount(4)// 每行显示个数
498
                .isReturnEmpty(false)// 未选择数据时点击按钮是否可以返回
499
                .isAutomaticTitleRecyclerTop(true)//图片列表超过一屏连续点击顶部标题栏快速回滚至顶部
500
                .forResult(REQUEST_CODE_CHOOSE);
472
        }
473
    }
501 474
475
    public void Init() {
476
        noScrollgridview = (RecyclerView) findViewById(R.id.noScrollgridview);
477
        noScrollgridview.setLayoutManager(new GridLayoutManager(this, 4));
478
        int screenWidth = ScreenUtils.getScreenWidth(this);
479
        int rvMargin = (DensityUtil.dip2px(this, 15) * 2);//rv左右间距
480
        int itemMargin = (DensityUtil.dip2px(this, 15) * 3);//item之间的间隙
481
        int itemWidth = (screenWidth - rvMargin - itemMargin) / 4;
482
        mAdapter = new GridImageAdapter(this, 3, itemWidth, 0);
483
        mAdapter.setListener(this);
484
        noScrollgridview.setAdapter(mAdapter);
502 485
    }
503 486
504 487
    @Override
@ -509,115 +492,86 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
509 492
                if (requestCode == 1) {
510 493
                    //处理调用系统图库
511 494
                } else if (requestCode == REQUEST_CODE_CHOOSE) {
495
                    setLayoutHintVisible(1);
512 496
                    //异步方式插入图片
513
                    insertImagesSync(data);
497
//                    insertImagesSync(data);
498
                    Bimp.tempSelectMedia = PictureSelector.obtainMultipleResult(data);
499
                    mAdapter.setMaxCount(3);
500
                    mInsterType = 1;
501
502
                    mAdapter.setDatas(Bimp.tempSelectMedia);
503
504
505
                } else if (requestCode == REQUEST_VIDEO_CODE_CHOOSE) {
506
                    //异步方式插入视频
507
                    setLayoutHintVisible(2);
508
                    mInsterType = 2;
509
                    mAdapter.setMaxCount(1);
510
                    Bimp.tempSelectMedia = PictureSelector.obtainMultipleResult(data);
511
                    mAdapter.setDatas(Bimp.tempSelectMedia);
514 512
                }
515 513
            }
514
        } else if (requestCode == REQUEST_TOPIC_CODE && resultCode == SelectTopicActivity.REESULT_CODE) {
515
            String name = data.getStringExtra("topicBean");
516
            mTopicbean = mGson.fromJson(name, TopicBean.class);
517
            topicText.setText(mTopicbean.getMeg());
516 518
        }
517 519
    }
518 520
519 521
    /**
520
     * 异步方式插入图片
521
     *
522
     * @param data
522
     * @param type 1表示插入图片成功 2表示插入视频成功 -1表示 插入数据为null
523 523
     */
524
    private void insertImagesSync(final Intent data) {
525
        insertDialog.show();
526
        Observable.create(new ObservableOnSubscribe<String>() {
527
            @Override
528
            public void subscribe(ObservableEmitter<String> subscriber) throws Exception {
529
                try {
530
                    mSelectionData= PictureSelector.obtainMultipleResult(data);
531
532
//                    List<Uri> uriList = Matisse.obtainResult(data);
533
                    for (LocalMedia media : mSelectionData) {
534
//                        Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
535
//                        File file = FileUtils.from(ChargingCommentActivity.this, uri);
536
//
537
//                        bitmap = FileUtils.rotateIfRequired(file, bitmap);
538
//                        bitmap = imageZoom(bitmap);
539
                        String path="";
540
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
541
                            path= media.getAndroidQToPath();
542
                        }else{
543
                            path=media.getPath();
544
                        }
545
                        ImageItem takePhoto = new ImageItem();
546
                        takePhoto.setBitmap(imageZoom(BitmapFactory.decodeFile(path)));
547
                        Bimp.tempSelectBitmap.add(takePhoto);
548
                        subscriber.onNext("");
549
                    }
550
                    subscriber.onComplete();
551
                } catch (Exception e) {
552
                    e.printStackTrace();
553
                    subscriber.onError(e);
554
                }
555
            }
556
        })
557
                .subscribeOn(Schedulers.io())//生产事件在io
558
                .observeOn(AndroidSchedulers.mainThread())//消费事件在UI线程
559
                .subscribe(new Observer<String>() {
560
                    @Override
561
                    public void onSubscribe(Disposable d) {
562
563
                    }
564
565
                    @Override
566
                    public void onNext(String s) {
567
568
                    }
569
570
                    @Override
571
                    public void onError(Throwable e) {
572
                        insertDialog.dismiss();
573
                        Log.e(TAG, "onError: " + "图片插入失败:" + e.getMessage());
574
                        ToastUtil.showToast(getApplicationContext(), "图片插入失败", Toast.LENGTH_SHORT);
575
                    }
576
577
                    @Override
578
                    public void onComplete() {
579
                        Log.e(TAG, "onCompleted: -------------");
580
                        insertDialog.dismiss();
581
                        adapter.update();
582
583
                    }
584
                });
524
    public void setLayoutHintVisible(int type) {
525
        if (type == 1) {
526
            noScrollgridview.setVisibility(View.VISIBLE);
527
            layoutHint.setVisibility(View.GONE);
528
        } else if (type == 2) {
529
            noScrollgridview.setVisibility(View.VISIBLE);
530
            layoutHint.setVisibility(View.GONE);
531
        } else if (type == -1) {
532
            layoutHint.setVisibility(View.VISIBLE);
533
            noScrollgridview.setVisibility(View.GONE);
534
        }
585 535
    }
586 536
537
587 538
    public void shite(String s) throws Exception {
588
        Map<String, String> par = new HashMap<String, String>();
589
        String file;
590
        long appTime1 = System.currentTimeMillis() / 1000;
591
        Log.i("appTime(long)---", appTime1 + "");
592
        long updatetime = appTime1 - MainMapActivity.cha - 1;
593
        Log.i("updatetime(long)---", updatetime + "");
594
        Log.i("cha---", MainMapActivity.cha + "");
595
        String token = String.valueOf(updatetime);
596
        Log.i("token---", token);
597
        for (int i = 0; i < Bimp.tempSelectBitmap.size(); i++) {
598
            try {
599
                bm = imageZoom(Bimp.tempSelectBitmap.get(i).getBitmap());
600
                file = bitmapToBase64(bm);
601
                par.put("file", file);
602
                Log.i("file--------" + (i + 1), file);
603
                par.put("filename", "androidapp.jpg");
604
            } catch (Exception e) {
605
                e.printStackTrace();
539
        ArrayList<String> fileList=new ArrayList<>();
540
541
        for (int i = 0; i < Bimp.tempSelectMedia.size(); i++) {
542
            LocalMedia media = Bimp.tempSelectMedia.get(i);
543
            String path = "";
544
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q)
545
                path = media.getAndroidQToPath();
546
            else {
547
                path = media.getPath();
548
            }
549
            bm = imageZoom(BitmapFactory.decodeFile(path));
550
            String file = bitmapToBase64(bm);
551
            Map<String, String> par = new HashMap<String, String>();
552
553
            par.put("file", file);
554
            par.put("filename", "androidapp" + i + ".jpg");
555
            String u = UploadUtil.post(MainApplication.url + "/zhannew/basic/web/index.php/fileupload/upload", par, null);
556
            JSONObject jsonObject = new JSONObject(u);
557
558
            String code = jsonObject.getString("code");
559
            if (code.equals("200")) {
560
                String fileUrl = jsonObject.getString("fileUrl");
561
                fileList.add(fileUrl);
562
            }else{
563
                Message msg = new Message();
564
                msg.what = IMG_ERROR;
565
                handler.sendMessage(msg);
566
                return;
606 567
            }
607
608
        }
609
        try {
610
            String u = UploadUtil.post(MainApplication.url + "/zhannew/basic/web/index.php/fileupload/upload",
611
                    par, null);
612
            System.err.println(u);
613
            // submit(u);
614
            Message msg = new Message();
615
            msg.obj = u;
616
            msg.what = 2;
617
            handler.sendMessage(msg);
618
        } catch (IOException e) {
619
            e.printStackTrace();
620 568
        }
569
570
        Message msg = new Message();
571
        msg.obj = mGson.toJson(fileList);
572
573
        msg.what = IMGRESLUT;
574
        handler.sendMessage(msg);
621 575
    }
622 576
623 577
    private void initData() {
@ -695,28 +649,6 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
695 649
                Log.e("select===", select_s);
696 650
697 651
698
                if (et_pinglun.getText().toString().equals("") && NewZhanDetailsActivity.replaceBlank(et_pinglun.getText().toString()).equals("")) {
699
                    if (!star_level.equals("") && !select_s.equals("")) {
700
                        tv_make_sure.setTextColor(getResources().getColor(R.color.lvse));
701
                        tv_make_sure.setEnabled(true);
702
                    } else {
703
                        tv_make_sure.setTextColor(getResources().getColor(R.color.huise));
704
                        tv_make_sure.setEnabled(false);
705
                    }
706
                } else {
707
                    if (et_pinglun.getText().toString().equals("#" + MainApplication.huodonglabel + "# ")) {
708
                        if (!star_level.equals("") && !select_s.equals("")) {
709
                            tv_make_sure.setTextColor(getResources().getColor(R.color.lvse));
710
                            tv_make_sure.setEnabled(true);
711
                        } else {
712
                            tv_make_sure.setTextColor(getResources().getColor(R.color.huise));
713
                            tv_make_sure.setEnabled(false);
714
                        }
715
                    } else {
716
                        tv_make_sure.setTextColor(getResources().getColor(R.color.lvse));
717
                        tv_make_sure.setEnabled(true);
718
                    }
719
                }
720 652
                return true;
721 653
            }
722 654
        });
@ -731,20 +663,41 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
731 663
        }
732 664
    }
733 665
734
    private void addComments(String fileUrl, String thumUrl) throws Exception {
666
    private void addComments(ArrayList<String> fileUrlList, String thumUrl) throws Exception {
735 667
        long appTime1 = System.currentTimeMillis() / 1000;
736
        Log.i("appTime(long)---", appTime1 + "");
737 668
        long updatetime = appTime1 - MainMapActivity.cha - 2;
738
        Log.i("updatetime(long)---", updatetime + "");
739
        Log.i("cha---", MainMapActivity.cha + "");
669
        Log.e(TAG, "addComments: ");
740 670
        String token = String.valueOf(updatetime);
671
        String url = MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/add";
672
        Map<String,String> map=new HashMap<>();
673
        map.put("userid",MainApplication.userId);
674
        map.put("zhanid",zhan_id);
675
        map.put("order_id",order_id);
676
        map.put("comment",URLEncoder.encode(et_pinglun.getText().toString()));
677
        map.put("tel",MainApplication.userPhone);
678
        map.put("token",URLEncoder.encode(DES3.encode(token)));
679
        if (mTopicbean!=null){
680
            map.put("theme",mTopicbean.getMeg());
681
        }
682
        if (commentType == 1){
683
            if (fileUrlList.size()>0){
684
                for (int i = 0; i < fileUrlList.size(); i++) {
685
                    String value = fileUrlList.get(i);
686
                    if (i == 0){
687
                        map.put("fileUrl",value);
688
                    }else{
689
                        map.put("file"+(i+1)+"Url", value);
690
                    }
691
                }
692
                if (mInsterType == 1 && mInsterType == -1){
693
                    map.put("type", ChatRecommendBean.TARGET_TYPE_IMAGE_TEXT + "");
694
                    map.put("thumUrl",fileUrlList.get(0));
695
                }else if (mInsterType == 2) {
696
                    map.put("type", ChatRecommendBean.TARGET_TYPE_VIDEO + "");
697
                }
698
            }
741 699
742
743
        String url = MainApplication.url +
744
                "/zhannew/basic/web/index.php/tpappcomments/add?userid=" +
745
                MainApplication.userId + "&zhanid=" + zhan_id + "&order_id=" + order_id +
746
                "&comment=" + URLEncoder.encode(et_pinglun.getText().toString()) +
747
                "&tel=" + MainApplication.userPhone + "&token=" + URLEncoder.encode(DES3.encode(token)) + "&fileUrl=" + fileUrl + "&thumUrl=" + thumUrl;
700
        }
748 701
749 702
        OkHttpUtils.get()
750 703
                .url(url)
@ -752,15 +705,17 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
752 705
                .execute(new StringCallback() {
753 706
                    @Override
754 707
                    public void onError(Call call, Exception e) {
755
708
                        dialog.cancel();
709
                        Toast.makeText(ChargingCommentActivity.this, "网络错误:"+e.getMessage(), Toast.LENGTH_SHORT).show();
756 710
                    }
757 711
758 712
                    @Override
759 713
                    public void onResponse(String response) {
714
                        dialog.cancel();
760 715
                        String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
761 716
                        String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
762 717
                        if (rtnCode.equals("01")) {
763
                            dialog.cancel();
718
764 719
                            final String data = JsonUtils.getKeyResult(response, "data");
765 720
                            String plusScore = JsonUtils.getKeyResult(response, "plusScore");
766 721
                            if (!plusScore.equals("")) {
@ -775,6 +730,8 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
775 730
                            }
776 731
777 732
                            submitPF(data);
733
                        }else{
734
                            Toast.makeText(ChargingCommentActivity.this, rtnMsg+"", Toast.LENGTH_SHORT).show();
778 735
                        }
779 736
780 737
                    }
@ -904,26 +861,37 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
904 861
            case R.id.tv_make_sure:
905 862
                if (MainApplication.isLogin()) {
906 863
                    try {
907
908
                        if (Bimp.tempSelectBitmap.size() > 0) {
864
                        if (Bimp.tempSelectMedia.size() > 0 && mInsterType == 1) {
909 865
                            dialog.show();
910
                            new Thread(new Runnable() {
911
                                @Override
912
                                public void run() {
913
                                    try {
914
                                        shite("");
915
                                    } catch (Exception e) {
916
                                        e.printStackTrace();
917
                                    }
866
                            new Thread(() -> {
867
                                try {
868
                                    shite("");
869
                                } catch (Exception e) {
870
                                    Message msg = new Message();
871
                                    msg.what = IMG_ERROR;
872
                                    handler.sendMessage(msg);
873
                                    e.printStackTrace();
918 874
                                }
919 875
                            }).start();
920 876
877
                        } else if (Bimp.tempSelectMedia.size() > 0 && mInsterType == 2) {
878
                            //进行视频验证
879
                            LocalMedia media = Bimp.tempSelectMedia.get(0);
880
                            String path = "";
881
                            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q)
882
                                path = media.getAndroidQToPath();
883
                            else {
884
                                path = media.getPath();
885
                            }
886
887
888
                            getYouPaiData(path);
921 889
                        } else {
922 890
                            if (containsEmoji(et_pinglun.getText().toString())) {
923 891
                                ToastUtil.showToast(MainApplication.context, "不支持输入表情", Toast.LENGTH_SHORT);
924 892
                            } else {
925 893
                                dialog.show();
926
                                addComments("", "");
894
                                addComments(new ArrayList<>(), "");
927 895
                            }
928 896
                        }
929 897
                    } catch (Exception e) {
@ -938,7 +906,187 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
938 906
            case R.id.iv_back:
939 907
                finish();
940 908
                break;
909
            case R.id.videoUpLoad:
910
                addVideo();
911
                break;
912
913
            case R.id.imgUpload:
914
                addImg();
915
                break;
916
        }
917
    }
918
    private void getYouPaiData(String filePath) {
919
        dialog.show();
920
921
//        String url = MainApplication.urlNew + "/get-sign-rest";
922
        String url = MainApplication.d1evTestUrl + "/api/topic/get-sign-rest2cdz";
923
        if (TextUtils.isEmpty(filePath)) {
924
            ToastUtil.showToast(getApplicationContext(), "请重新选择视频", Toast.LENGTH_SHORT);
925
            return;
926
        }
927
928
        String deviceId = JPushInterface.getUdid(MainApplication.context);
929
        String fileName = DateUtils.getSimpleCurrentDate();
930
        if (TextUtils.isEmpty(deviceId)) {
931
            fileName += "_" + Util.getRandom(15);
932
        } else {
933
            fileName += "_" + deviceId;
934
        }
935
936
        if (TextUtils.isEmpty(filePath)) {
937
            fileName = "";
938
        } else {
939
            String suffix = filePath.substring(filePath.lastIndexOf(".") + 1);
940
            fileName += "." + suffix;
941
        }
942
943
944
        Map<String, String> map = new HashMap<>();
945
        map.put("fileName", fileName);
946
        try {
947
            FileInputStream fileInputStream = new FileInputStream(new File(filePath));
948
            map.put("contentLength", String.valueOf(fileInputStream.available()));
949
        } catch (Exception e) {
950
            e.printStackTrace();
951
        }
952
        map.put("targetType", ChatRecommendBean.TARGET_TYPE_VIDEO + "");
953
        CommonParams.addCommonParams(map);
954
955
        String finalFileName = fileName;
956
        OkHttpUtils.get()
957
                .params(map)
958
                .url(url)
959
                .build()
960
                .connTimeOut(6000)
961
                .readTimeOut(6000)
962
                .execute(new StringCallback() {
963
                    @Override
964
                    public void onError(Call call, Exception e) {
965
                        ToastUtil.showToast(getApplicationContext(), "发布失败,请重试", Toast.LENGTH_SHORT);
966
                        dialog.dismiss();
967
                    }
968
969
                    @Override
970
                    public void onResponse(String response) {
971
                        Log.e("hyc--", response);
972
                        String code = JsonUtils.getKeyResult(response, "code");
973
                        String desc = JsonUtils.getKeyResult(response, "desc");
974
                        if ("1000".equals(code)) {
975
                            String data = JsonUtils.getKeyResult(response, "data");
976
                            AuthSignBean signBeans = (AuthSignBean) JsonUtils.parseToObjectBean(data, AuthSignBean.class);
977
                            if (null != signBeans) {
978
                                String sign = signBeans.sign;
979
                                String policy = signBeans.policy;
980
                                formUpload(filePath, sign, policy, finalFileName);
981
                            } else {
982
                                ToastUtil.showToast(getApplicationContext(), desc, Toast.LENGTH_SHORT);
983
                            }
984
                        } else {
985
                            ToastUtil.showToast(getApplicationContext(), desc, Toast.LENGTH_SHORT);
986
                            dialog.dismiss();
987
                        }
988
                    }
989
                });
990
991
    }
992
993
    /**
994
     * 表单上传
995
     *
996
     * @param SAMPLE_PIC_FILE
997
     * @param sign
998
     * @param policyServer
999
     */
1000
    private void formUpload(String SAMPLE_PIC_FILE, String sign, String policyServer, String fileName) {
1001
1002
        SerialUploader serialUploader = new SerialUploader();
1003
1004
        serialUploader.setCheckMD5(false);
1005
1006
        File temp = new File(SAMPLE_PIC_FILE);
1007
1008
        serialUploader.setOnProgressListener((bytesWrite, contentLength) -> {
1009
1010
        });
1011
        String decoder = new String(Base64.decode((policyServer), Base64.DEFAULT));
1012
1013
        JSONObject jsonObject = null;
1014
        try {
1015
            jsonObject = new JSONObject(decoder);
1016
        } catch (JSONException e) {
1017
            e.printStackTrace();
941 1018
        }
1019
        String uri = jsonObject.optString("URI");
1020
        String date = jsonObject.optString("Date");
1021
        String operator = jsonObject.optString("Operator");
1022
        String saveKey = jsonObject.optString("save-key");
1023
1024
        serialUploader.upload(
1025
                temp, uri, date, "UPYUN " + operator + ":" + sign, null, new UpCompleteListener() {
1026
                    @Override
1027
                    public void onComplete(boolean isSuccess, String result) {
1028
                        if (isSuccess) {
1029
                            try {
1030
                                ArrayList<String> list = new ArrayList<>();
1031
                                list.add(saveKey);
1032
                                addComments(list, saveKey);
1033
                            } catch (Exception e) {
1034
                                e.printStackTrace();
1035
                            }
1036
                        } else {
1037
                            ToastUtil.showToast(getApplicationContext(), "发布失败,请重试", Toast.LENGTH_SHORT);
1038
                            dialog.dismiss();
1039
                        }
1040
1041
                    }
1042
                });
1043
    }
1044
    private void addImg() {
1045
        PictureSelector.create(this)
1046
                .openGallery(PictureMimeType.ofImage())
1047
                .maxSelectNum(PIC_NUM)
1048
                .selectionMode(PictureConfig.MULTIPLE)
1049
                .selectionData(Bimp.tempSelectMedia)//是否传入已选图片
1050
                .isCompress(true)//是否压缩
1051
                .isPreviewEggs(true)//预览图片时是否增强左右滑动图片体验
1052
                .isGif(true)//是否显示gif
1053
                .isAndroidQTransform(true)
1054
                .imageEngine(GlideEngine.createGlideEngine())
1055
                .isWeChatStyle(false)// 是否开启微信图片选择风格
1056
                .isUseCustomCamera(false)// 是否使用自定义相机
1057
                .isPageStrategy(true)// 是否开启分页策略 & 每页多少条;默认开启
1058
                .setPictureStyle(Util.getWhiteStyle(this))// 动态自定义相册主题
1059
                .setRecyclerAnimationMode(AnimationType.SLIDE_IN_BOTTOM_ANIMATION)// 列表动画效果
1060
                .isMaxSelectEnabledMask(true)// 选择数到了最大阀值列表是否启用蒙层效果
1061
                .imageSpanCount(4)// 每行显示个数
1062
                .isReturnEmpty(false)// 未选择数据时点击按钮是否可以返回
1063
                .isAutomaticTitleRecyclerTop(true)//图片列表超过一屏连续点击顶部标题栏快速回滚至顶部
1064
                .forResult(REQUEST_CODE_CHOOSE);
1065
    }
1066
    private void addVideo() {
1067
        PictureSelector.create(this)
1068
                .openGallery(PictureMimeType.ofVideo())
1069
                .selectionMode(PictureConfig.SINGLE)
1070
                .isCompress(true)//是否压缩
1071
                .isPreviewEggs(true)//预览图片时是否增强左右滑动图片体验
1072
                .isAndroidQTransform(true)
1073
                .imageEngine(GlideEngine.createGlideEngine())
1074
                .isWeChatStyle(false)// 是否开启微信图片选择风格
1075
                .isUseCustomCamera(false)// 是否使用自定义相机
1076
                .isPageStrategy(true)// 是否开启分页策略 & 每页多少条;默认开启
1077
                .setPictureStyle(Util.getWhiteStyle(this))// 动态自定义相册主题
1078
                .setRecyclerAnimationMode(AnimationType.SLIDE_IN_BOTTOM_ANIMATION)// 列表动画效果
1079
                .isMaxSelectEnabledMask(true)// 选择数到了最大阀值列表是否启用蒙层效果
1080
                .imageSpanCount(4)// 每行显示个数
1081
                .isReturnEmpty(false)// 未选择数据时点击按钮是否可以返回
1082
                .isAutomaticTitleRecyclerTop(true)//图片列表超过一屏连续点击顶部标题栏快速回滚至顶部
1083
                .videoMaxSecond(16)   // 查询多少秒以内的视频
1084
                .videoMinSecond(2)   // 查询多少秒以内的视频
1085
                .recordVideoSecond(15)//录制视频秒数 默认60s
1086
                .isPreviewVideo(true)//是否预览视频
1087
                .isSingleDirectReturn(true)//PictureConfig.SINGLE模式下是否直接返回
1088
                .filterMaxFileSize( 100 * 1024 )//查询指定大小内的图片、视频、音频大小,单位 KB
1089
                .forResult(REQUEST_VIDEO_CODE_CHOOSE);
942 1090
    }
943 1091
944 1092
    public boolean isEmoji(String string) {
@ -976,7 +1124,7 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
976 1124
    @AfterPermissionGranted(RC_ALBUM_PERM)
977 1125
    public void permissionTask() {
978 1126
        if (isPermissionOK()) {
979
            callGallery();
1127
            addImg();
980 1128
            // Have permission, do the thing!
981 1129
//            Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
982 1130
//            ifTimeout();
@ -1011,136 +1159,21 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
1011 1159
        }
1012 1160
    }
1013 1161
1014
    private File getFile(String path) {
1015
        File f = new File(path);
1016
        if (!f.exists()) {
1017
            try {
1018
                f.createNewFile();
1019
            } catch (IOException e) {
1020
                e.printStackTrace();
1021
            }
1022
        }
1023
        return f;
1024
    }
1025
1026
    private static String getPath(String path) {
1027
        File f = new File(path);
1028
        if (!f.exists()) {
1029
            f.mkdirs();
1030
        }
1031
        return f.getAbsolutePath();
1032
    }
1033
1034
    public class GridAdapter extends BaseAdapter {
1035
        private LayoutInflater inflater;
1036
        private int selectedPosition = -1;
1037
        private boolean shape;
1038
1039
        public boolean isShape() {
1040
            return shape;
1041
        }
1042
1043
        public void setShape(boolean shape) {
1044
            this.shape = shape;
1045
        }
1046
1047
        public GridAdapter(Context context) {
1048
            inflater = LayoutInflater.from(context);
1049
        }
1050
1051
        public void update() {
1052
            loading();
1053
        }
1054
1055
        public int getCount() {
1056
            if (Bimp.tempSelectBitmap.size() == 1) {
1057
                return 1;
1058
            }
1059
            return (Bimp.tempSelectBitmap.size() + 1);
1060
        }
1061
1062
        public Object getItem(int arg0) {
1063
            return null;
1064
        }
1065
1066
        public long getItemId(int arg0) {
1067
            return 0;
1068
        }
1069
1070
        public void setSelectedPosition(int position) {
1071
            selectedPosition = position;
1072
        }
1073
1074
        public int getSelectedPosition() {
1075
            return selectedPosition;
1076
        }
1077
1078
        public View getView(int position, View convertView, ViewGroup parent) {
1079
            GridAdapter.ViewHolder holder = null;
1080
            if (convertView == null) {
1081
                convertView = inflater.inflate(R.layout.item_published_grida,
1082
                        parent, false);
1083
                holder = new GridAdapter.ViewHolder();
1084
                holder.image = (ImageView) convertView
1085
                        .findViewById(R.id.item_grida_image);
1086
                convertView.setTag(holder);
1087
            } else {
1088
                holder = (GridAdapter.ViewHolder) convertView.getTag();
1089
            }
1090
1091
            if (position == Bimp.tempSelectBitmap.size()) {
1092
                holder.image.setImageBitmap(BitmapFactory.decodeResource(
1093
                        getResources(), R.drawable.icon_comment_upload));
1094
                if (position == 1) {
1095
                    holder.image.setVisibility(View.GONE);
1096
                }
1097
            } else {
1098
                holder.image.setImageBitmap(Bimp.tempSelectBitmap.get(position).getBitmap());
1099
            }
1100 1162
1101
            return convertView;
1102
        }
1103
1104
        public class ViewHolder {
1105
            public ImageView image;
1106
        }
1107
1108
        Handler handler = new Handler() {
1109
            public void handleMessage(Message msg) {
1110
                switch (msg.what) {
1111
                    case 1:
1112
                        adapter.notifyDataSetChanged();
1113
                        break;
1114
                }
1115
                super.handleMessage(msg);
1116
            }
1117
        };
1118
1119
        public void loading() {
1120
            new Thread(new Runnable() {
1121
                public void run() {
1122
                    while (true) {
1123
                        if (Bimp.max == Bimp.tempSelectBitmap.size()) {
1124
                            Message message = new Message();
1125
                            message.what = 1;
1126
                            handler.sendMessage(message);
1127
                            break;
1128
                        } else {
1129
                            Bimp.max += 1;
1130
                            Message message = new Message();
1131
                            message.what = 1;
1132
                            handler.sendMessage(message);
1133
                        }
1134
                    }
1135
                }
1136
            }).start();
1163
    @Override
1164
    protected void onResume() {
1165
        super.onResume();
1166
        mAdapter.notifyDataSetChanged();
1167
        if (mInsterType == 1 && mAdapter.getItemCount() == 1) {
1168
            setLayoutHintVisible(-1);
1169
            mInsterType = -1;
1170
        } else if (mInsterType == 2 && mAdapter.getItemCount() == 0) {
1171
            setLayoutHintVisible(-1);
1172
            mInsterType = -1;
1137 1173
        }
1138 1174
    }
1139 1175
1140
1141
1142 1176
    protected void onRestart() {
1143
        adapter.update();
1144 1177
        super.onRestart();
1145 1178
    }
1146 1179
@ -1149,6 +1182,7 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
1149 1182
        super.onDestroy();
1150 1183
        Bimp.tempSelectBitmap.clear();
1151 1184
        Bimp.max = 0;
1185
        Bimp.tempSelectMedia.clear();
1152 1186
    }
1153 1187
1154 1188
    private String bitmapToBase64(Bitmap bitmap) {
@ -1345,5 +1379,33 @@ public class ChargingCommentActivity extends Activity implements View.OnClickLis
1345 1379
        });
1346 1380
    }
1347 1381
1382
    @Override
1383
    public void add() {
1384
        if (mInsterType == 1) {
1385
            addImg();
1386
        } else if (mInsterType == 2) {
1387
            addVideo();
1388
        }
1389
    }
1390
1391
    @Override
1392
    public void remove(int position) {
1393
        if (mAdapter.getItemCount() == 1) {
1394
            setLayoutHintVisible(-1);
1395
            mInsterType = -1;
1396
        }
1348 1397
1398
    }
1399
1400
    @Override
1401
    public void open(int position, LocalMedia mLocalMedia) {
1402
        if (mInsterType == 1) {
1403
            ImageDisplayActivity.actionStart(this, position);
1404
        } else if (mInsterType == 2) {
1405
            PictureSelector.create(ChargingCommentActivity.this)
1406
                    .themeStyle(R.style.picture_default_style)
1407
                    .setPictureStyle(Util.getWhiteStyle(ChargingCommentActivity.this))// 动态自定义相册主题
1408
                    .externalPictureVideo(TextUtils.isEmpty(mLocalMedia.getAndroidQToPath()) ? mLocalMedia.getPath() : mLocalMedia.getAndroidQToPath());
1409
        }
1410
    }
1349 1411
}

+ 6 - 2
app/src/main/java/com/electric/chargingpile/activity/SelectTopicActivity.java

@ -5,6 +5,7 @@ import android.content.Intent;
5 5
import android.os.Bundle;
6 6
import android.util.Log;
7 7
import android.view.View;
8
import android.widget.ImageView;
8 9
import android.widget.TextView;
9 10
import android.widget.Toast;
10 11
@ -34,6 +35,7 @@ public class SelectTopicActivity  extends AppCompatActivity {
34 35
35 36
    private RecyclerView mRecyclerView;
36 37
    private TextView noDataText;
38
    private ImageView imgNoData;
37 39
    private CommentTopicAdapter mAdapter;
38 40
    private LoadingDialog dialog = null;
39 41
    private final Gson mGson =new Gson();
@ -58,6 +60,7 @@ public class SelectTopicActivity  extends AppCompatActivity {
58 60
59 61
        mRecyclerView = findViewById(R.id.topicRecycelrView);
60 62
        noDataText = findViewById(R.id.noDataText);
63
        imgNoData = findViewById(R.id.imgNoData);
61 64
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
62 65
        mAdapter = new CommentTopicAdapter();
63 66
        mAdapter.setListener(pos -> {
@ -69,8 +72,6 @@ public class SelectTopicActivity  extends AppCompatActivity {
69 72
            finish();
70 73
        });
71 74
        mRecyclerView.setAdapter(mAdapter);
72
73
        noDataText.setVisibility(View.GONE);
74 75
        mRecyclerView.setVisibility(View.VISIBLE);
75 76
    }
76 77
@ -99,13 +100,16 @@ public class SelectTopicActivity  extends AppCompatActivity {
99 100
                        String data = JsonUtils.getKeyResult(response, "data");
100 101
                        ArrayList<TopicBean> list = mGson.fromJson(data, new TypeToken<ArrayList<TopicBean>>() {
101 102
                        }.getType());
103
                        list.clear();
102 104
                        if (list != null && list.size()>0){
103 105
                            mAdapter.setDatas(list);
104 106
                            mRecyclerView.setVisibility(View.VISIBLE);
105 107
                            noDataText.setVisibility(View.GONE);
108
                            imgNoData.setVisibility(View.GONE);
106 109
                        }else{
107 110
                            mRecyclerView.setVisibility(View.GONE);
108 111
                            noDataText.setVisibility(View.VISIBLE);
112
                            imgNoData.setVisibility(View.VISIBLE);
109 113
                        }
110 114
                    }
111 115
                }

+ 33 - 78
app/src/main/java/com/electric/chargingpile/activity/ZhanCommentActivity.java

@ -112,7 +112,10 @@ import pub.devrel.easypermissions.AfterPermissionGranted;
112 112
import pub.devrel.easypermissions.EasyPermissions;
113 113
114 114
import static android.text.Html.FROM_HTML_MODE_LEGACY;
115
115
/**
116
 * 如果更改此页面,则需要同步更改 ChargingCommentActivity,
117
 * ChargingCommentActivity 该页面为从我的->充电记录->去评论
118
 * */
116 119
public class ZhanCommentActivity extends AppCompatActivity implements View.OnClickListener, EasyPermissions.PermissionCallbacks, GridImageAdapter.GridImgListener {
117 120
    private static final String TAG = "ZhanCommentActivity";
118 121
    private static final int PIC_NUM = 3;
@ -475,38 +478,34 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
475 478
476 479
        String thumUrl="";
477 480
        for (int i = 0; i < Bimp.tempSelectMedia.size(); i++) {
478
            try {
479
                LocalMedia media = Bimp.tempSelectMedia.get(i);
480
                String path = "";
481
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q)
482
                    path = media.getAndroidQToPath();
483
                else {
484
                    path = media.getPath();
485
                }
486
                bm = imageZoom(BitmapFactory.decodeFile(path));
487
                String file = bitmapToBase64(bm);
488
                Map<String, String> par = new HashMap<String, String>();
489
490
                par.put("file", file);
491
                par.put("filename", "androidapp" + i + ".jpg");
492
                String u = UploadUtil.post(MainApplication.url + "/zhannew/basic/web/index.php/fileupload/upload",
493
                        par, null);
494
                JSONObject jsonObject = new JSONObject(u);
495
496
                String code = jsonObject.getString("code");
497
                if (code.equals("200")) {
498
                    String fileUrl = jsonObject.getString("fileUrl");
499
                    fileList.add(fileUrl);
500
                }else{
501
                    Message msg = new Message();
502
                    msg.what = IMG_ERROR;
503
                    handler.sendMessage(msg);
504
                    return;
505
                }
506 481
507
            } catch (Exception e) {
508
                e.printStackTrace();
482
            LocalMedia media = Bimp.tempSelectMedia.get(i);
483
            String path = "";
484
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q)
485
                path = media.getAndroidQToPath();
486
            else {
487
                path = media.getPath();
488
            }
489
            bm = imageZoom(BitmapFactory.decodeFile(path));
490
            String file = bitmapToBase64(bm);
491
            Map<String, String> par = new HashMap<String, String>();
492
493
            par.put("file", file);
494
            par.put("filename", "androidapp" + i + ".jpg");
495
            String u = UploadUtil.post(MainApplication.url + "/zhannew/basic/web/index.php/fileupload/upload", par, null);
496
            JSONObject jsonObject = new JSONObject(u);
497
498
            String code = jsonObject.getString("code");
499
            if (code.equals("200")) {
500
                String fileUrl = jsonObject.getString("fileUrl");
501
                fileList.add(fileUrl);
502
            }else{
503
                Message msg = new Message();
504
                msg.what = IMG_ERROR;
505
                handler.sendMessage(msg);
506
                return;
509 507
            }
508
510 509
        }
511 510
512 511
        Message msg = new Message();
@ -768,6 +767,9 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
768 767
                                try {
769 768
                                    shite("");
770 769
                                } catch (Exception e) {
770
                                    Message msg = new Message();
771
                                    msg.what = IMG_ERROR;
772
                                    handler.sendMessage(msg);
771 773
                                    e.printStackTrace();
772 774
                                }
773 775
                            }).start();
@ -1222,51 +1224,4 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
1222 1224
                ((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) || ((codePoint >= 0x10000)
1223 1225
                && (codePoint <= 0x10FFFF));
1224 1226
    }
1225
1226
    /**
1227
     * 将json 数组转换为Map 对象
1228
     *
1229
     * @param jsonString
1230
     * @return
1231
     */
1232
1233
    public static Map<String, Object> getMap(String jsonString) {
1234
        JSONObject jsonObject;
1235
        Map<String, Object> valueMap = new HashMap<String, Object>();
1236
        if (TextUtils.isEmpty(jsonString)) {
1237
            return valueMap;
1238
        }
1239
        try {
1240
            jsonObject = new JSONObject(jsonString);
1241
            @SuppressWarnings("unchecked")
1242
            Iterator<String> keyIter = jsonObject.keys();
1243
            String key;
1244
            Object value;
1245
1246
            while (keyIter.hasNext()) {
1247
                key = (String) keyIter.next();
1248
                value = jsonObject.get(key);
1249
                valueMap.put(key, value);
1250
            }
1251
            return valueMap;
1252
        } catch (JSONException e) {
1253
            e.printStackTrace();
1254
        }
1255
1256
        return valueMap;
1257
1258
    }
1259
    public String getFileExtension(String path) {
1260
        String extension = "";
1261
        File file = new File(path);
1262
        try {
1263
            if (file != null && file.exists()) {
1264
                String name = file.getName();
1265
                extension = name.substring(name.lastIndexOf("."));
1266
            }
1267
        } catch (Exception e) {
1268
            extension = "";
1269
        }
1270
        return extension;
1271
    }
1272 1227
}

+ 1 - 1
app/src/main/java/com/electric/chargingpile/adapter/GridImageAdapter.java

@ -107,7 +107,7 @@ public class GridImageAdapter extends RecyclerView.Adapter<GridImageAdapter.View
107 107
            holder.remove.setOnClickListener(v->{
108 108
                //删除
109 109
                mDatas.remove(position);
110
                notifyItemRemoved(position);
110
                notifyDataSetChanged();
111 111
                if (mListener!=null){
112 112
                    mListener.remove(position);
113 113
                }

二进制
app/src/main/res/drawable-xxhdpi/ic_topic_no_data.webp


+ 61 - 14
app/src/main/res/layout/activity_charging_comment.xml

@ -66,8 +66,9 @@
66 66
67 67
    <com.electric.chargingpile.view.ObservableScrollView
68 68
        android:id="@+id/sv"
69
        android:background="@color/white"
69 70
        android:layout_width="match_parent"
70
        android:layout_height="wrap_content"
71
        android:layout_height="match_parent"
71 72
        android:layout_below="@+id/view_title"
72 73
        android:layout_alignParentLeft="true"
73 74
        android:layout_alignParentStart="true">
@ -75,11 +76,11 @@
75 76
        <com.zhy.autolayout.AutoLinearLayout
76 77
            android:id="@+id/ll_pingfen"
77 78
            android:layout_width="match_parent"
78
            android:layout_height="wrap_content"
79
            android:layout_height="match_parent"
79 80
            android:focusable="true"
80 81
            android:focusableInTouchMode="true"
81 82
            android:orientation="vertical"
82
            android:background="@color/white"
83
83 84
            android:layout_alignParentLeft="true"
84 85
            android:layout_alignParentStart="true">
85 86
@ -190,25 +191,71 @@
190 191
                android:visibility="visible"
191 192
                android:layout_marginBottom="7dp"/>
192 193
193
            <GridView
194
            <TextView
195
                android:paddingEnd="11dp"
196
                android:paddingStart="11dp"
197
                android:paddingBottom="6dp"
198
                android:paddingTop="6dp"
199
                android:layout_marginBottom="13dp"
200
                android:id="@+id/topicText"
201
                android:background="@drawable/bg_topic_tab"
202
                android:layout_width="wrap_content"
203
                android:layout_height="wrap_content"
204
                android:layout_marginStart="15dp"
205
                android:gravity="center"
206
                android:text="╋  话题"
207
                android:textColor="#ff0e0e0e"
208
                android:textSize="13sp" />
209
            <LinearLayout
210
                android:id="@+id/layoutHint"
211
                android:layout_marginEnd="15dp"
212
                android:layout_marginStart="15dp"
213
                android:layout_width="wrap_content"
214
                android:layout_height="wrap_content">
215
216
                <ImageView
217
                    android:id="@+id/imgUpload"
218
                    android:src="@drawable/icon_comment_upload"
219
                    android:layout_width="wrap_content"
220
                    android:layout_height="wrap_content"/>
221
222
                <ImageView
223
                    android:id="@+id/videoUpLoad"
224
                    android:layout_marginStart="12dp"
225
                    android:src="@drawable/ic_comment_video_upload"
226
                    android:layout_width="wrap_content"
227
                    android:layout_height="wrap_content"/>
228
229
                <TextView
230
                    android:id="@+id/commentHint"
231
                    android:layout_marginStart="12dp"
232
                    android:gravity="bottom"
233
                    android:layout_width="wrap_content"
234
                    android:layout_height="match_parent"
235
                    tools:text="30字以上+图片或15s视频有机会被评为优质评论获得充电优惠券"
236
                    android:textColor="#ff7a7a7a"
237
                    android:textSize="12sp"
238
                    />
239
            </LinearLayout>
240
241
            <androidx.recyclerview.widget.RecyclerView
242
                android:visibility="gone"
194 243
                android:id="@+id/noScrollgridview"
195 244
                android:layout_width="match_parent"
196 245
                android:layout_height="wrap_content"
197 246
                android:layout_marginLeft="15dp"
198 247
                android:layout_marginRight="15dp"
199
                android:horizontalSpacing="3dp"
200
                android:numColumns="3"
201 248
                android:scrollbars="none"
202
                android:verticalSpacing="5dp" >
203
            </GridView>
204
205
            <View
206
                android:layout_width="match_parent"
207
                android:layout_height="0.5dp"
208
                android:background="@color/Line"
209
                android:layout_marginTop="15dp"
210 249
                />
211 250
251
            <ImageView
252
                android:visibility="gone"
253
                android:id="@+id/imgAd"
254
                android:layout_marginTop="30dp"
255
                android:layout_gravity="center"
256
                android:layout_width="wrap_content"
257
                android:layout_height="wrap_content"/>
258
212 259
        </com.zhy.autolayout.AutoLinearLayout>
213 260
214 261
    </com.electric.chargingpile.view.ObservableScrollView>

+ 2 - 1
app/src/main/res/layout/activity_main_map.xml

@ -1532,6 +1532,7 @@
1532 1532
            android:visibility="gone">
1533 1533
1534 1534
            <TextView
1535
                android:layout_centerInParent="true"
1535 1536
                android:paddingStart="20dp"
1536 1537
                android:id="@+id/tvNotification"
1537 1538
                android:paddingEnd="25dp"
@ -1540,7 +1541,7 @@
1540 1541
                android:layout_width="wrap_content"
1541 1542
                android:layout_height="34dp"
1542 1543
                android:gravity="center"
1543
                android:text="您有一笔订单正在进行中您有一笔订单正在进行中,点击查看详情..."
1544
                tools:text="您有一笔订,点击查看详情..."
1544 1545
                android:textColor="@color/huimain"
1545 1546
                android:textSize="13sp" />
1546 1547

+ 17 - 6
app/src/main/res/layout/activity_slelect_topic.xml

@ -51,17 +51,28 @@
51 51
        app:layout_constraintStart_toStartOf="parent"
52 52
        app:layout_constraintTop_toBottomOf="@+id/rl_title"
53 53
        tools:listitem="@layout/layout_item_topic" />
54
54
    <ImageView
55
        tools:visibility="visible"
56
        android:visibility="gone"
57
        android:id="@+id/imgNoData"
58
        android:src="@drawable/ic_topic_no_data"
59
        android:layout_width="wrap_content"
60
        android:layout_height="wrap_content"
61
        app:layout_constraintBottom_toBottomOf="parent"
62
        app:layout_constraintEnd_toEndOf="parent"
63
        app:layout_constraintStart_toStartOf="parent"
64
        app:layout_constraintTop_toBottomOf="@+id/rl_title" />
55 65
    <TextView
56
        android:visibility="visible"
66
        tools:visibility="visible"
67
        android:layout_marginTop="20dp"
68
        android:visibility="gone"
57 69
        android:id="@+id/noDataText"
58 70
        android:layout_width="wrap_content"
59 71
        android:layout_height="wrap_content"
60 72
        android:text="没有相关话题"
61 73
        android:textColor="#ff7b7b7b"
62 74
        android:textSize="14sp"
63
        app:layout_constraintBottom_toBottomOf="parent"
64
        app:layout_constraintEnd_toEndOf="parent"
65
        app:layout_constraintStart_toStartOf="parent"
66
        app:layout_constraintTop_toBottomOf="@+id/rl_title" />
75
        android:layout_marginEnd="12dp"
76
        app:layout_constraintEnd_toEndOf="@+id/imgNoData"
77
        app:layout_constraintTop_toBottomOf="@+id/imgNoData" />
67 78
</androidx.constraintlayout.widget.ConstraintLayout>