|
@ -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
|
}
|