|
@ -34,13 +34,17 @@ import com.electric.chargingpile.data.AuthSignBean;
|
34
|
34
|
import com.electric.chargingpile.data.ChatRecommendBean;
|
35
|
35
|
import com.electric.chargingpile.data.PublishItemSerializable;
|
36
|
36
|
import com.electric.chargingpile.data.TalkRecommendBean;
|
|
37
|
import com.electric.chargingpile.data.VideoUploadResult;
|
37
|
38
|
import com.electric.chargingpile.manager.ProfileManager;
|
38
|
39
|
import com.electric.chargingpile.util.BarColorUtil;
|
|
40
|
import com.electric.chargingpile.util.Base64;
|
39
|
41
|
import com.electric.chargingpile.util.Bimp;
|
40
|
42
|
import com.electric.chargingpile.util.CommonParams;
|
|
43
|
import com.electric.chargingpile.util.DateUtils;
|
41
|
44
|
import com.electric.chargingpile.util.JsonUtils;
|
42
|
45
|
import com.electric.chargingpile.util.LoadingDialog;
|
43
|
46
|
import com.electric.chargingpile.util.ToastUtil;
|
|
47
|
import com.electric.chargingpile.util.Util;
|
44
|
48
|
import com.luck.picture.lib.PictureSelector;
|
45
|
49
|
import com.luck.picture.lib.compress.Luban;
|
46
|
50
|
import com.luck.picture.lib.config.PictureConfig;
|
|
@ -59,6 +63,7 @@ import java.util.HashMap;
|
59
|
63
|
import java.util.List;
|
60
|
64
|
import java.util.Map;
|
61
|
65
|
|
|
66
|
import cn.jpush.android.api.JPushInterface;
|
62
|
67
|
import okhttp3.Call;
|
63
|
68
|
|
64
|
69
|
public class PublishVideoTopicActivity extends Activity implements OnClickListener {
|
|
@ -230,11 +235,13 @@ public class PublishVideoTopicActivity extends Activity implements OnClickListen
|
230
|
235
|
}
|
231
|
236
|
|
232
|
237
|
private void getYouPaiData() {
|
233
|
|
String fileNames = media.getPath().substring(media.getPath().lastIndexOf("/") + 1);
|
234
|
238
|
String url = MainApplication.urlNew + "/topic/sign.do";
|
|
239
|
if (TextUtils.isEmpty(media.fName)) {
|
|
240
|
ToastUtil.showToast(getApplicationContext(), "请重新选择视频", Toast.LENGTH_SHORT);
|
|
241
|
return;
|
|
242
|
}
|
235
|
243
|
Map<String, String> map = new HashMap<>();
|
236
|
|
map.put("fileNames", fileNames);
|
237
|
|
Log.e("fileNameDir fileName", fileNames);
|
|
244
|
map.put("fileNames", media.fName);
|
238
|
245
|
map.put("targetType", ChatRecommendBean.TARGET_TYPE_VIDEO + "");
|
239
|
246
|
CommonParams.addCommonParams(map);
|
240
|
247
|
|
|
@ -287,7 +294,8 @@ public class PublishVideoTopicActivity extends Activity implements OnClickListen
|
287
|
294
|
@Override
|
288
|
295
|
public void onComplete(boolean isSuccess, String result) {
|
289
|
296
|
if (isSuccess) {
|
290
|
|
requestPublishServer("[" + result + "]");
|
|
297
|
VideoUploadResult videoUploadResult = new VideoUploadResult(result);
|
|
298
|
requestPublishServer("[" + videoUploadResult.formatResult() + "]");
|
291
|
299
|
} else {
|
292
|
300
|
ToastUtil.showToast(getApplicationContext(), "发布失败,请重试", Toast.LENGTH_SHORT);
|
293
|
301
|
uploadDialog.dismiss();
|
|
@ -302,24 +310,15 @@ public class PublishVideoTopicActivity extends Activity implements OnClickListen
|
302
|
310
|
}
|
303
|
311
|
|
304
|
312
|
private void requestPublishServer(String urls) {
|
305
|
|
File file = new File(media.getPath());
|
306
|
|
long size = 0L;
|
307
|
|
if (file.exists()) {
|
308
|
|
size = file.length();
|
309
|
|
}
|
310
|
313
|
|
311
|
314
|
String url = MainApplication.urlNew + "/topic/publish.do";
|
312
|
315
|
Map<String, String> map = new HashMap<>();
|
313
|
316
|
map.put("content", mPublishtopicCon.getText().toString().trim());
|
314
|
|
map.put("urls", urls);
|
|
317
|
map.put("urls", Base64.encode(urls.getBytes()).replaceAll("\\s*", ""));
|
315
|
318
|
if (chatRecommendBean != null) {
|
316
|
319
|
map.put("topicId", chatRecommendBean.topicId + "");
|
317
|
320
|
}
|
318
|
321
|
map.put("targetType", ChatRecommendBean.TARGET_TYPE_VIDEO + "");
|
319
|
|
map.put("coverImgW", media.getWidth() + "");
|
320
|
|
map.put("coverImgH", media.getHeight() + "");
|
321
|
|
map.put("duration", media.getDuration() + "");
|
322
|
|
map.put("size", size + "");
|
323
|
322
|
CommonParams.addCommonParams(map);
|
324
|
323
|
|
325
|
324
|
OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
|
|
@ -365,9 +364,26 @@ public class PublishVideoTopicActivity extends Activity implements OnClickListen
|
365
|
364
|
List<LocalMedia> selectList = PictureSelector.obtainMultipleResult(data);
|
366
|
365
|
if (selectList != null && selectList.size() > 0) {
|
367
|
366
|
media = selectList.get(0);
|
|
367
|
|
|
368
|
String deviceId = JPushInterface.getUdid(MainApplication.context);
|
|
369
|
media.fName = DateUtils.getSimpleCurrentDate();
|
|
370
|
if (TextUtils.isEmpty(deviceId)) {
|
|
371
|
media.fName += "_" + Util.getRandom(15);
|
|
372
|
} else {
|
|
373
|
media.fName += "_" + deviceId;
|
|
374
|
}
|
|
375
|
String path = media.getPath();
|
|
376
|
if (TextUtils.isEmpty(path)) {
|
|
377
|
media.fName = "";
|
|
378
|
} else {
|
|
379
|
String suffix = path.substring(path.lastIndexOf(".") + 1);
|
|
380
|
media.fName += "." + suffix;
|
|
381
|
}
|
|
382
|
|
368
|
383
|
if (TextUtils.isEmpty(media.getPath())) {
|
369
|
384
|
return;
|
370
|
385
|
}
|
|
386
|
|
371
|
387
|
if (!fileIsExists(media.getPath())) {
|
372
|
388
|
Log.e("yopic", "文件可能不存在了~");
|
373
|
389
|
return;
|