use of com.mtm.mrecord.mvp.model.entity.VideoGsonBean in project Mvp-Rxjava-Retrofit-dagger2 by pengMaster.
the class MediaRecordPresenter method downLoadMediaFile.
/**
* 下载监督媒体文件
*
* @param token
* @param id
*/
public void downLoadMediaFile(final String token, final String id) {
ThreadUtils.runThread(new Runnable() {
@Override
public void run() {
HttpClient httpClient = new HttpClient();
Map<String, String> msg = new HashMap<String, String>();
msg.put("superviseId", id);
String params = new Gson().toJson(msg);
StringRequestEntity paramEntity = null;
try {
paramEntity = new StringRequestEntity(params, "application/json", "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
PostMethod postMethod = new PostMethod(Api.GET_MEDIA_RECORD + "?token=" + token);
postMethod.setRequestEntity(paramEntity);
try {
httpClient.executeMethod(postMethod);
} catch (IOException e) {
e.printStackTrace();
}
try {
InputStream inputStream = postMethod.getResponseBodyAsStream();
final String resultKey = convertStreamToString(inputStream);
ThreadUtils.runInMainThread(new Runnable() {
@Override
public void run() {
VideoGsonBean resultKeyBean = new Gson().fromJson(resultKey, VideoGsonBean.class);
mRootView.setViewData(resultKeyBean);
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
use of com.mtm.mrecord.mvp.model.entity.VideoGsonBean in project Mvp-Rxjava-Retrofit-dagger2 by pengMaster.
the class MediaRecordFragment method setViewData.
@Override
public void setViewData(VideoGsonBean videoGsonBean) {
boolean audio = true, pic = true, video = true;
try {
if (null == videoGsonBean) {
showMessage("解析数据失败");
return;
}
String result = videoGsonBean.getResult();
if ("0".equals(result)) {
showMessage("没有相关视频数据");
return;
}
if ("1".equals(result)) {
// 1成功 0失败
dataAcquisitions = videoGsonBean.getDataAcquisitions();
}
linearContent.removeAllViews();
// -------------------------- 视频 ------------------------------
lyInfo = UIUtils.inflate(R.layout.layout_utdetail_info);
LinearLayout linearInfo = (LinearLayout) lyInfo.findViewById(R.id.fl_info_item);
TextView tvType = (TextView) lyInfo.findViewById(R.id.tv_typeName);
tvType.setText("视频");
if (dataAcquisitions.size() > 0) {
for (int i = 0; i < dataAcquisitions.size(); i++) {
View lyItem = UIUtils.inflate(R.layout.layout_utdetail_item_video);
TextView tvItem = (TextView) lyItem.findViewById(R.id.tv_audio_name);
videoBean = dataAcquisitions.get(i);
final String path = videoBean.getCcwz();
final String name = videoBean.getMediaName();
int mediaType = videoBean.getMediaType();
tvItem.setText(name);
lyItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
mPresenter.downLoadVideo(port + path, name, progressBar);
} catch (Exception e) {
e.printStackTrace();
}
}
});
lyItem.setBackgroundResource(R.drawable.shape_rd8_gray_square);
if (1 == mediaType) {
if (video) {
linearInfo.removeAllViews();
video = false;
}
linearInfo.addView(lyItem);
}
}
}
linearContent.addView(lyInfo);
// -------------------------- 音频 ------------------------------
lyInfo = UIUtils.inflate(R.layout.layout_utdetail_info);
TextView tvConnectAu = (TextView) lyInfo.findViewById(R.id.tv_connect);
tvConnectAu.setVisibility(View.GONE);
LinearLayout linearInfo1 = (LinearLayout) lyInfo.findViewById(R.id.fl_info_item);
TextView tvType1 = (TextView) lyInfo.findViewById(R.id.tv_typeName);
tvType1.setText("音频");
if (dataAcquisitions.size() > 0) {
for (int i = 0; i < dataAcquisitions.size(); i++) {
View lyItem = UIUtils.inflate(R.layout.layout_utdetail_item_audio);
TextView tvItem = (TextView) lyItem.findViewById(R.id.tv_audio_name);
final VideoGsonBean.DataAcquisitionsBean dataAcquisitionsBean = dataAcquisitions.get(i);
final String path = dataAcquisitionsBean.getCcwz();
final String name = dataAcquisitionsBean.getMediaName();
int mediaType = dataAcquisitionsBean.getMediaType();
tvItem.setText(name);
lyItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString("url", path);
bundle.putString("type", "2");
bundle.putString("name", name);
bundle.putString("pic", gson.toJson(dataAcquisitionsBean));
// startActivity(RecordPreFileActivity.class, bundle);
}
});
lyItem.setBackgroundResource(R.drawable.shape_rd8_gray_square);
if (2 == mediaType) {
if (audio) {
linearInfo1.removeAllViews();
audio = false;
}
linearInfo1.addView(lyItem);
}
}
}
linearContent.addView(lyInfo);
// -------------------------- 图片 ------------------------------
lyInfo = UIUtils.inflate(R.layout.layout_utdetail_info);
TextView tvConnectPic = (TextView) lyInfo.findViewById(R.id.tv_connect);
tvConnectPic.setVisibility(View.GONE);
LinearLayout linearInfo2 = (LinearLayout) lyInfo.findViewById(R.id.fl_info_item);
TextView tvType2 = (TextView) lyInfo.findViewById(R.id.tv_typeName);
tvType2.setText("图片");
if (dataAcquisitions.size() > 0) {
for (int i = 0; i < dataAcquisitions.size(); i++) {
View lyItem = UIUtils.inflate(R.layout.layout_utdetail_item_pic);
TextView tvItem = (TextView) lyItem.findViewById(R.id.tv_audio_name);
final VideoGsonBean.DataAcquisitionsBean dataAcquisitionsBean = dataAcquisitions.get(i);
final String path = dataAcquisitionsBean.getCcwz();
final String name = dataAcquisitionsBean.getMediaName();
int mediaType = dataAcquisitionsBean.getMediaType();
tvItem.setText(name);
lyItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString("url", path);
bundle.putString("type", "1");
bundle.putString("name", name);
bundle.putString("pic", gson.toJson(dataAcquisitionsBean));
// startActivity(RecordPreFileActivity.class, bundle);
}
});
lyItem.setBackgroundResource(R.drawable.shape_rd8_gray_square);
if (3 == mediaType) {
if (pic) {
linearInfo2.removeAllViews();
pic = false;
}
linearInfo2.addView(lyItem);
}
}
}
linearContent.addView(lyInfo);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations