修改map的黑屏问题。以及友盟上的bug

This commit is contained in:
wangdongsheng 2021-10-29 18:51:31 +08:00
parent b753c8217e
commit dc81a6513d
19 changed files with 893 additions and 389 deletions

View File

@ -92,21 +92,6 @@ public class HomeActivity extends BaseActivity{
return fragments.size();
}
});
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { }
@Override
public void onPageSelected(int position) {
if (position == 1) {
recordFragment.refreshData();
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mViewPager.setCanScroll(true);
mViewPager.setNoScrollAnim(false);
mTab.setupWithViewPager(mViewPager);
@ -124,7 +109,16 @@ public class HomeActivity extends BaseActivity{
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
}else if (tab.getPosition()==3){
}else if (tab.getPosition()==1){
Message obtain = Message.obtain();
obtain.what = Constant.STAY_SUBMIT_ITEM;
obtain.obj = true;
EventBus.getDefault().post(obtain);
Message obtain1 = Message.obtain();
obtain1.what = Constant.HAS_SUBMIT_ITEM;
obtain1.obj = true;
EventBus.getDefault().post(obtain1);
} else if (tab.getPosition()==3){
Message obtain = Message.obtain();
obtain.what = Constant.HOME_MINE;
obtain.obj = true;
@ -133,11 +127,14 @@ public class HomeActivity extends BaseActivity{
}
//点击table layout效果
@Override
public void onTabUnselected(TabLayout.Tab tab) {}
@Override
public void onTabReselected(TabLayout.Tab tab) {}
});
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
@Subscribe
public void onEvent(Message data) {

View File

@ -399,7 +399,6 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
Intent intent = new Intent();
finalVideoPath = Objects.requireNonNull(paperFile.getParentFile()).getAbsolutePath() + "/" + videoIndex + ".webp";
intent.putExtra(Constant.INTENT_PICTURES_PATH, finalVideoPath);
intent.putExtra("type", poi_video_type);
setResult(0x111, intent);
this.finish();
break;

View File

@ -17,20 +17,14 @@ import java.util.ArrayList;
import java.util.List;
public class TaskExplainAdapter2 extends RecyclerView.Adapter<TaskExplainAdapter2.ViewHolder2> {
private List<TaskPrefectureBean.BodyBean.ListBean> explainList2 = new ArrayList<>();
private List<TaskPrefectureBean.BodyBean.ListBean> explainList2 ;
private Context context;
public TaskExplainAdapter2(Context context) {
public TaskExplainAdapter2(List<TaskPrefectureBean.BodyBean.ListBean> explainList2, Context context) {
this.explainList2 = explainList2;
this.context = context;
}
public void setExplainList2(List<TaskPrefectureBean.BodyBean.ListBean> explainList2) {
if (explainList2 != null) {
this.explainList2.addAll(explainList2);
notifyDataSetChanged();
}
}
public void taskExplainClearData() {
if (explainList2 != null) {
explainList2.clear();
@ -76,9 +70,9 @@ public class TaskExplainAdapter2 extends RecyclerView.Adapter<TaskExplainAdapter
void onClick2(int pos);
}
private TaskExplainAdapter2.OnItemClick2 mOnItemClick2;
private OnItemClick2 mOnItemClick2;
public void setOnItemClick(TaskExplainAdapter2.OnItemClick2 pOnItemClick2) {
public void setOnItemClick(OnItemClick2 pOnItemClick2) {
mOnItemClick2 = pOnItemClick2;
}
}

View File

@ -63,12 +63,12 @@ public class Constant {
//筛选
public static final int FILTER_CODE = 0x200;
/*
存储用户信息
access_token 后续需求需要用到的key 过期时间8小时
refresh_token 刷新token用 过期时间1个月
userId 用户id
username 用户编号
*/
存储用户信息
access_token 后续需求需要用到的key 过期时间8小时
refresh_token 刷新token用 过期时间1个月
userId 用户id
username 用户编号
*/
public static String ACCESS_TOKEN = null;
public static String REFRESH_TOKEN = null;
public static String USHERED = null;
@ -120,8 +120,8 @@ public class Constant {
public static final int PILE_MARKER_SHOW = 33;//刷新充电桩的显示
public static final int JOB_WORD_MONITOR = 34;//寻宝界面和删选的刷新
public static final int EVENT_WHAT_LOCATION_CHANGE = 35; // 定位位置更新的Event的What值
// public static final int CHARGING_PILE_BODY = 36;//充电装的body
// public static final int CHARGING_PILE_PHOTO = 37;//充电桩的照片
//public static final int CHARGING_PILE_BODY = 36;//充电装的body
//public static final int CHARGING_PILE_PHOTO = 37;//充电桩的照片
public static final int Filter_WhAT_RECYCLER = 39;//刪選適配器的刷新
public static final int EVENT_WHAT_CURRENT_MARKER = 41; // 显示当前正在编辑的POI类型数据的Event的What值
// CompleteTask
@ -133,17 +133,31 @@ public class Constant {
public static final int PICTURE_VIDEO_WORD = 48; //视频页面崩溃后发给poi录像和道路
public static final int PHOTO_FINISH_VIDEO = 49;//拍照列表的返回
public static final int NEST_WORD_SUBMIT = 50;//所有的提交/上传
public static final int STAY_SUBMIT_ITEM = 52;//待提交
public static final int HAS_SUBMIT_ITEM = 53;//已提交
public static final String INTENT_POI_VIDEO_TYPE = "poi_video_type";
public static int NUMBER = 200; //任务个数
public static int LIMIT_TYPE = -1; //权限类型普通任务-0专属任务-1
public static int TASK_TYPE = -1; // 任务类型
public static int TASK_STARTUP = -1; // 任务状态
public static String CODE = ""; //区号
/*用户当前位置*/
/*
用户当前位置
*/
public static TencentLocation currentLocation;
public static LatLng markerLacing;
public static JobSearchBean jobSearchBean;//
public static MapView treasureMap;
public static final String INTENT_VIDEO_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置
public static final String INTENT_JPG_PATH = "INTENT_JPG_PATH"; // 拍照界面指定的图片保存位置
public static final String INTENT_PHOTO_PATH = "INTENT_PHOTO_PATH"; // 拍照界面指定的图片保存位置
public static final String INTENT_PICTURES_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置
public static final String INTENT_VIDEO_OBLATION = "INTENT_VIDEO_OBLATION"; // 视频拍摄时屏幕方向 0-强制横屏 其他-任意
public static SlidingUpPanelLayout SLIDING_LAYOUT = null;//設置
public static boolean IS_FILTER_LIST_ITEM = true;//poi页面的查重
public static TencentMap.OnMarkerClickListener markerClickListener = null;
public static final String NAVIN_FO = "10.29";//版本日期
//marker
public static final BitmapDescriptor MARKER_POI_SHOW = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_show);
public static final BitmapDescriptor MARKER_CHARGE_SHOW = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_show);
public static final BitmapDescriptor MARKER_CHARGE_PILE_SHOW=BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_pile_show);
@ -152,7 +166,6 @@ public class Constant {
public static final BitmapDescriptor MARKER_OTHER_SHOW= BitmapDescriptorFactory.fromResource(R.drawable.marker_other_show);
public static final BitmapDescriptor MARKER_FACET_SHOW= BitmapDescriptorFactory.fromResource(R.drawable.marker_facet_show);
public static final BitmapDescriptor MARKER_POI = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi);
public static final BitmapDescriptor MARKER_CHARGE_PILE=BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_pile);
public static final BitmapDescriptor MARKER_POI_VIDEO = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video);
public static final BitmapDescriptor MARKER_ROOD = BitmapDescriptorFactory.fromResource(R.drawable.marker_road);
@ -166,17 +179,8 @@ public class Constant {
public static final BitmapDescriptor GRAY_OTHER= BitmapDescriptorFactory.fromResource(R.drawable.grayother);
public static final BitmapDescriptor GRAY_FACET= BitmapDescriptorFactory.fromResource(R.drawable.grayfacet);
public static final BitmapDescriptor ICON_OPERATION=BitmapDescriptorFactory.fromResource(R.mipmap.icon_operation);
public static JobSearchBean jobSearchBean;//
public static MapView treasureMap;
public static final String INTENT_VIDEO_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置
public static final String INTENT_JPG_PATH = "INTENT_JPG_PATH"; // 拍照界面指定的图片保存位置
public static final String INTENT_PHOTO_PATH = "INTENT_PHOTO_PATH"; // 拍照界面指定的图片保存位置
public static final String INTENT_PICTURES_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置
public static final String INTENT_VIDEO_OBLATION = "INTENT_VIDEO_OBLATION"; // 视频拍摄时屏幕方向 0-强制横屏 其他-任意
public static SlidingUpPanelLayout SLIDING_LAYOUT = null;//設置
public static boolean IS_FILTER_LIST_ITEM = true;//poi页面的查重
public static TencentMap.OnMarkerClickListener markerClickListener = null;
public static final String NAVIN_FO = "10.26";//版本日期
/*
*联系我们的QQ群名称和QQ群号
*/

View File

@ -1094,12 +1094,14 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
@Override
public void run() {
chargingStationSaveByWork(poiEntity, isLocal);
}
});
if (getActivity()!=null){
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
chargingStationSaveByWork(poiEntity, isLocal);
}
});
}
}
}).start();
@ -1167,7 +1169,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
* 保存充电站数据到服务器
*/
private void chargingStationSaveByWork(PoiEntity poiEntity, boolean isLocal) {
showLoadingDialog();
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("sptype", poiEntity.getStation_type());
@ -1176,6 +1177,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
httpParams.put("telephone", poiEntity.getTelPhone());
httpParams.put("memo", poiEntity.getMemo());
httpParams.put("geo", poiEntity.getGeoWkt());
showLoadingDialog();
OkGoBuilder.getInstance()
.Builder(getActivity())
.url(HttpInterface.SUBMIT_CTASK)

View File

@ -54,7 +54,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.Objects;
/*收款信息
/*
收款信息
*/
public class GatheringFragment extends BaseFragment implements View.OnClickListener {
private TextView tvBank;
@ -133,7 +134,6 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
}
}
gatheringBuilder = new StringBuilder();
gatheringBuilder.append("GatheringFragment-onCreate-initData ,");
if (Constant.USHERED!=null){
@ -328,12 +328,17 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe
Toast.makeText(getContext(), "识别失败,可以重新识别或则进行手动输入", Toast.LENGTH_SHORT).show();
} else {
if (bankCardBean.getResult() != null && bankCardBean.getResult().getBank_card_number() != null) {
String bank_card_number = bankCardBean.getResult().getBank_card_number();
String bank_card_number = bankCardBean.getResult().getBank_card_number().trim();
if (StringUtils.isEmpty(bank_card_number)) {
Toast.makeText(getActivity(), "识别失败,可以重新识别或则进行手动输入", Toast.LENGTH_SHORT).show();
return;
}
etBankNum.setText(bank_card_number);
if (bank_card_number.contains(" ")){
Log.d("TAG", "onActivityResult: 包含空格");
}else {
Log.d("TAG", "onActivityResult: 不包含空格");
}
// String bankName = bankCardBean.getResult().getBank_name();
} else {
Toast.makeText(getActivity(), "识别失败,可以重新识别或则进行手动输入", Toast.LENGTH_SHORT).show();
@ -366,7 +371,6 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe
gatheringBuilder.append("onPause ,");
}
@Override
public void onStop() {
super.onStop();
@ -376,7 +380,7 @@ public class GatheringFragment extends BaseFragment implements View.OnClickListe
@Override
public void onDestroy() {
super.onDestroy();
gatheringBuilder.append("onDestroy ,");
gatheringBuilder.append("onDestroy ");
gatheringBuilder.append("\r\n");
FileUtils.writeFile(logFile.getAbsolutePath(), gatheringBuilder.toString(), true);
}

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
@ -23,6 +24,9 @@ import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@ -48,8 +52,9 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
private TextView poiVideoAuditProcess;
private TextView poiVideoAuditThrough;
private TextView poiVideoAuditProcessAbleNotThrough;
private File logFile;
private StringBuilder hasSubmitBuilder;
private File logFile;
private HasSubmitBean.BodyBean hasSubmitBeanBody;
public static HasSubmitFragment newInstance(Bundle bundle) {
HasSubmitFragment fragment = new HasSubmitFragment();
@ -57,6 +62,14 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
return fragment;
}
@Override
public void onStart() {
super.onStart();
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this);
}
}
@Override
protected int getLayout() {
return R.layout.fragment_has_submit;
@ -69,25 +82,21 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
auditProcess = findViewById(R.id.audit_process);
auditThrough = findViewById(R.id.audit_through);
auditNotThrough = findViewById(R.id.audit_not_through);
ConstraintLayout clRoad = findViewById(R.id.cl_road);
clRoad.setOnClickListener(this);
roadAuditProcess = findViewById(R.id.road_audit_process);
roadAuditThrough = findViewById(R.id.road_audit_through);
roadAuditNotThrough = findViewById(R.id.road_audit_not_through);
ConstraintLayout clCharging = findViewById(R.id.cl_charging);
clCharging.setOnClickListener(this);
chargingAuditProcess = findViewById(R.id.charging_audit_process);
chargingAuditThrough = findViewById(R.id.charging_audit_through);
chargingAuditNotThrough = findViewById(R.id.charging_audit_not_through);
ConstraintLayout clOther = findViewById(R.id.cl_other);
clOther.setOnClickListener(this);
otherAuditProcess = findViewById(R.id.other_audit_process);
otherAuditThrough = findViewById(R.id.other_audit_through);
otherAuditNotThrough = findViewById(R.id.other_audit_not_through);
ConstraintLayout clPoiVideo = findViewById(R.id.cl_poiVideo);
clPoiVideo.setOnClickListener(this);
poiVideoAuditProcess = findViewById(R.id.poiVideo_audit_process);
@ -96,6 +105,15 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
initRequest();
}
@Subscribe
public void onEvent(Message data) {
if (data.what == Constant.HAS_SUBMIT_ITEM) {
if ((boolean) data.obj) {
initRequest();
}
}
}
public void initRequest() {
initPoiSubMitWork();//poi
initCaningSubMitWork();//充电站
@ -129,7 +147,6 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
} else {
Toast.makeText(getActivity(), hasSubmitBean.getMessage() + "", Toast.LENGTH_SHORT).show();
}
Log.d("TAG", "onSuccess: " + hasSubmitBean.getBody() + "");
}
@Override
@ -166,7 +183,6 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
Toast.makeText(getActivity(), hasSubmitBean.getMessage() + "", Toast.LENGTH_SHORT).show();
}
Log.d("TAG", "onSuccess: " + hasSubmitBean.getBody() + "");
}
@Override
@ -195,15 +211,13 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
if (hasSubmitBean.getCode() == 200) {
HasSubmitBean.BodyBean hasSubmitBeanBody = hasSubmitBean.getBody();
if (hasSubmitBeanBody != null) {
roadAuditProcess.setText(hasSubmitBeanBody.getAuditingCount()+"");
roadAuditThrough.setText(hasSubmitBeanBody.getPassCount()+"");
roadAuditProcess.setText(hasSubmitBeanBody.getAuditingCount() + "");
roadAuditThrough.setText(hasSubmitBeanBody.getPassCount() + "");
roadAuditNotThrough.setText(hasSubmitBeanBody.getNotPassCount() + "");
}
} else {
Toast.makeText(getActivity(), hasSubmitBean.getMessage(), Toast.LENGTH_SHORT).show();
}
Log.d("TAG", "onSuccess: " + hasSubmitBean.getBody() + "");
}
@Override
@ -239,8 +253,6 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
} else {
Toast.makeText(getActivity(), hasSubmitBean.getMessage() + "", Toast.LENGTH_SHORT).show();
}
Log.d("TAG", "onSuccess: " + hasSubmitBean.getBody() + "");
}
@Override
@ -260,19 +272,18 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
.Builder(getActivity())
.url(HttpInterface.GET_COMMIT_LIST)
.cls(HasSubmitBean.class)
.params(httpParams)
.token(Constant.ACCESS_TOKEN)
.params(httpParams)
.getRequest(new Callback<HasSubmitBean>() {
@Override
public void onSuccess(HasSubmitBean hasSubmitBean, int id) {
dismissLoadingDialog();
if (hasSubmitBean.getCode() == 200) {
HasSubmitBean.BodyBean hasSubmitBeanBody = hasSubmitBean.getBody();
hasSubmitBeanBody = hasSubmitBean.getBody();
if (hasSubmitBeanBody != null) {
auditProcess.setText(hasSubmitBeanBody.getAuditingCount() + "");
auditThrough.setText(hasSubmitBeanBody.getPassCount() + "");
auditNotThrough.setText(hasSubmitBeanBody.getNotPassCount() + "");
Log.d("TAG", "onSuccess: " + hasSubmitBean.getBody() + "");
}
} else {
Toast.makeText(getActivity(), hasSubmitBean.getMessage() + "", Toast.LENGTH_SHORT).show();
@ -282,7 +293,6 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
Log.d("TAG", "onError: " + e.getMessage());
Toast.makeText(getActivity(), "请求失败", Toast.LENGTH_SHORT).show();
}
});
@ -333,6 +343,7 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
roadIntent.putExtra("type", 4);
startActivity(roadIntent);
break;
case R.id.cl_charging:
hasSubmitBuilder.append("点击了charging item跳转到charging列表 ,");
Intent chargingIntent = new Intent(getContext(), FragmentManagement.class);
@ -371,10 +382,11 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
hasSubmitBuilder.append("onDestroy ");
hasSubmitBuilder.append("\r\n");
FileUtils.writeFile(logFile.getAbsolutePath(), hasSubmitBuilder.toString(), true);
}
}

View File

@ -81,7 +81,6 @@ import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* 寻宝-上报-其他的fragment
*/
@ -277,11 +276,8 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
});
//数据展示
initShowPoi();
//禁用所有操作控件
//disables();
//长按刪除
onLongDelPic();
}
private void onLongDelPic() {
@ -385,9 +381,9 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
if (name != null && !name.equals("")) {
editTaskName.setText(name);
}
String geoWkt = showPoiEntity.getGeoWkt();
if (geoWkt != null) {
linearExist.setVisibility(View.VISIBLE);
String geo = Geohash.getInstance().decode(geoWkt);
Geometry geometry = GeometryTools.createGeometry(geo);
switch (geometry.getGeometryType()) {
@ -419,7 +415,6 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
}
}
if (showPoiEntity.getName() != null) {
linearExist.setVisibility(View.VISIBLE);
spinnerExist.setSelection(showPoiEntity.getExistence(), true);
}
String describe = showPoiEntity.getMemo();//任务描述

View File

@ -55,6 +55,7 @@ import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.UploadUtils;
import com.navinfo.outdoor.util.ZipUtils;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
@ -91,6 +92,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
private TextView tvShort;
private File logFile;
private StringBuilder poiVideoBuilder;
private LatLng rearLatLng;
public static PoiVideoFragment newInstance(Bundle bundle) {
PoiVideoFragment fragment = new PoiVideoFragment();
@ -201,20 +203,20 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String newFormat = formatter.format(new Date(System.currentTimeMillis()));
String pictures_time = sharedPreferences.getString("pictures_time", null);
if (pictures_time==null){
sharedEdit.putString("pictures_time",newFormat);
if (pictures_time == null) {
sharedEdit.putString("pictures_time", newFormat);
sharedEdit.apply();
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
}else {
if (pictures_time.equals(newFormat)){
} else {
if (pictures_time.equals(newFormat)) {
logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt");
}else {
} else {
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
}
}
poiVideoBuilder = new StringBuilder();
poiVideoBuilder.append("PoiVideoActivity-onCreate-initData ,");
if (Constant.USHERED!=null){
if (Constant.USHERED != null) {
poiVideoBuilder.append("userId:").append(Constant.USHERED).append(",");
}
}
@ -241,6 +243,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
assert latLineString != null;
latLng = latLineString.get(0);
rearLatLng = latLineString.get(latLineString.size() - 1);
break;
}
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
@ -307,6 +310,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID.size() == 1) {
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
ivPoiVideoPicture.setImageDrawable(null);
@ -348,23 +352,41 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
break;
case R.id.tv_short://手动拍摄
poiVideoBuilder.append("点击了手动拍摄的按钮 ,");
Intent intents = new Intent(getActivity(), PicturesActivity.class);
File filePath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intents.putExtra(Constant.INTENT_JPG_PATH, filePath.getAbsolutePath());
intents.putExtra("poiEntity", showPoiEntity);
intents.putExtra(Constant.INTENT_VIDEO_OBLATION, 0);
intents.putExtra(Constant.INTENT_POI_VIDEO_TYPE, 2);
startActivityForResult(intents, 0x102);
double latitude = Constant.currentLocation.getLatitude();
double longitude = Constant.currentLocation.getLongitude();
LatLng startLatLng = new LatLng(latitude, longitude); //用户当前位置
double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);
double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);
if (geometry > 5000 || rearGeometry > 5000) {
Toast.makeText(getActivity(), "用户距离作业起点或者终点五公里以内才能拍摄", Toast.LENGTH_SHORT).show();
return;
} else {
Intent intents = new Intent(getActivity(), PicturesActivity.class);
File filePath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intents.putExtra(Constant.INTENT_JPG_PATH, filePath.getAbsolutePath());
intents.putExtra("poiEntity", showPoiEntity);
intents.putExtra(Constant.INTENT_VIDEO_OBLATION, 0);
intents.putExtra(Constant.INTENT_POI_VIDEO_TYPE, 2);
startActivityForResult(intents, 0x102);
}
break;
case R.id.tv_combo://自动连拍:
poiVideoBuilder.append("点击了自动连拍的按钮 ,");
Intent intent = new Intent(getActivity(), PicturesActivity.class);
File fileJpgPath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intent.putExtra(Constant.INTENT_JPG_PATH, fileJpgPath.getAbsolutePath());
intent.putExtra("poiEntity", showPoiEntity);
intent.putExtra(Constant.INTENT_VIDEO_OBLATION, 0);
intent.putExtra(Constant.INTENT_POI_VIDEO_TYPE, 1);
startActivityForResult(intent, 0x101);
LatLng startLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); //用户当前位置
double geom = GeometryTools.distanceToDouble(startLng, latLng);
double rearGeom = GeometryTools.distanceToDouble(startLng, rearLatLng);
if (geom > 5000 || rearGeom > 5000) {
Toast.makeText(getActivity(), "用户距离作业起点或者终点五公里以内才能拍摄", Toast.LENGTH_SHORT).show();
return;
} else {
Intent intent = new Intent(getActivity(), PicturesActivity.class);
File fileJpgPath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intent.putExtra(Constant.INTENT_JPG_PATH, fileJpgPath.getAbsolutePath());
intent.putExtra("poiEntity", showPoiEntity);
intent.putExtra(Constant.INTENT_VIDEO_OBLATION, 0);
intent.putExtra(Constant.INTENT_POI_VIDEO_TYPE, 1);
startActivityForResult(intent, 0x101);
}
break;
case R.id.btn_poi_video_upload:
poiVideoBuilder.append("点击了上传的按钮 ,");
@ -376,17 +398,37 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
@Override
public void run() {
ZipUtil.zipFiles(videoFileList, fileZip, null);
long zipTrueSize = ZipUtils.getZipTrueSize(fileZip.getAbsolutePath());
if (zipTrueSize > 0) {
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (showPoiEntity == null) {
showPoiEntity = new PoiEntity();
}
if (showPoiEntity.getTaskStatus() == 1 || showPoiEntity.getTaskStatus() == 2 || showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 5) {
initPoiSaveLocal(true);
} else {
poiVideoUpload(showPoiEntity.getBodyId(), fileZip);
Constant.isPresent = false;
}
}
});
}
} else {
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
fileZip.delete();
Toast.makeText(getActivity(), "压缩文件失败,请重新提交", Toast.LENGTH_SHORT).show();
}
});
}
}
}
}).start();
if (showPoiEntity == null) {
showPoiEntity = new PoiEntity();
}
if (showPoiEntity.getTaskStatus() == 1 || showPoiEntity.getTaskStatus() == 2 || showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 5) {
initPoiSaveLocal(true);
} else {
poiVideoUpload(showPoiEntity.getBodyId(), fileZip);
Constant.isPresent = false;
}
} else {
dismissLoadingDialog();
Toast.makeText(getActivity(), "请录像", Toast.LENGTH_SHORT).show();
@ -395,7 +437,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} else {
Toast.makeText(getContext(), "有正在提交的数据,等提交成功后,方可操作", Toast.LENGTH_SHORT).show();
}
break;
}
}
@ -418,12 +459,14 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
@Override
public void run() {
poiVideoSave(poiEntity, isLocal);
}
});
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
poiVideoSave(poiEntity, isLocal);
}
});
}
}
}).start();
//onBackPressed();
@ -443,7 +486,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
});
}
private void poiVideoUpload(int poiVideoBody, File fileZip) {
if (poiVideoBody == 0) {
Toast.makeText(getActivity(), "请先保存本地在上传", Toast.LENGTH_SHORT).show();
@ -468,7 +510,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
Objects.requireNonNull(getActivity()).onBackPressed();//回退
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
WaitDialog.dismiss(3000);
}
private void poiVideoSave(PoiEntity poiEntity, boolean isLocal) {
@ -498,7 +539,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
if (getActivity()!=null){
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
@ -589,7 +630,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
if (showPoiEntity.getTaskStatus() == 5) {
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);//结束领取
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
if (showPoiEntity.getId()!=null){
if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
@ -622,7 +663,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
poiVideoBuilder.append("onStop ,");
}
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
@ -682,7 +722,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
public void onError(Throwable e, int id) {
dismissLoadingDialog();
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
Log.d("TAG", "onError: " + e.getMessage());
}
});
}

View File

@ -19,6 +19,7 @@ public class PrivilegeFragment extends BaseFragment implements View.OnClickListe
fragment.setArguments(bundle);
return fragment;
}
@Override
protected int getLayout() {
return R.layout.privilege_fragment;
@ -42,4 +43,5 @@ public class PrivilegeFragment extends BaseFragment implements View.OnClickListe
Objects.requireNonNull(getActivity()).finish();
}
}
}

View File

@ -3,6 +3,7 @@ package com.navinfo.outdoor.fragment;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import androidx.annotation.NonNull;
@ -12,9 +13,11 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.tabs.TabLayout;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseFragment;
import com.navinfo.outdoor.util.NoSlideViewPager;
import org.greenrobot.eventbus.EventBus;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@ -24,11 +27,9 @@ import java.util.Objects;
* 记录的Fragment
* 2021-5-25
*/
public class RecordFragment extends BaseFragment implements View.OnClickListener {
public class RecordFragment extends BaseFragment {
private final String[] names = {"待提交", "已提交"};
private StaySubmitFragment staySubmitFragment; // 待提交
private HasSubmitFragment hasSubmitFragment;// 已提交
public static RecordFragment newInstance(Bundle bundle) {
RecordFragment fragment = new RecordFragment();
@ -47,10 +48,10 @@ public class RecordFragment extends BaseFragment implements View.OnClickListener
TabLayout tabRecord = (TabLayout) findViewById(R.id.tab_record);
NoSlideViewPager vpRecord = (NoSlideViewPager) findViewById(R.id.vp_record);
ArrayList<Fragment> fragments = new ArrayList<>();
staySubmitFragment = new StaySubmitFragment();
fragments.add(staySubmitFragment);
hasSubmitFragment = new HasSubmitFragment();
fragments.add(hasSubmitFragment);
// 待提交
fragments.add(new StaySubmitFragment());
// 已提交
fragments.add(new HasSubmitFragment());
assert getFragmentManager() != null;
vpRecord.setAdapter(new FragmentPagerAdapter(getFragmentManager()) {
@NotNull
@ -64,48 +65,32 @@ public class RecordFragment extends BaseFragment implements View.OnClickListener
return fragments.size();
}
});
tabRecord.setupWithViewPager(vpRecord);
Objects.requireNonNull(tabRecord.getTabAt(0)).setText(names[0]);
Objects.requireNonNull(tabRecord.getTabAt(1)).setText(names[1]);
tabRecord.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
refreshData();
if (tab.getPosition()==0){
Message obtain = Message.obtain();
obtain.what = Constant.STAY_SUBMIT_ITEM;
obtain.obj = true;
EventBus.getDefault().post(obtain);
}else if (tab.getPosition()==1){
Message obtain = Message.obtain();
obtain.what = Constant.HAS_SUBMIT_ITEM;
obtain.obj = true;
EventBus.getDefault().post(obtain);
}
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
public void onTabUnselected(TabLayout.Tab tab) { }
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
public void onTabReselected(TabLayout.Tab tab) { }
});
}
@Override
protected void initData() {
super.initData();
}
@Override
public void onClick(View v) {
}
/**
* 刷新fragment内的所有数据
* */
public void refreshData() {
if (staySubmitFragment!=null) {
staySubmitFragment.refreshData();
}
if (hasSubmitFragment!=null) {
hasSubmitFragment.initRequest();
}
}
}

View File

@ -55,6 +55,7 @@ import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.ZipUtils;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
@ -90,6 +91,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
private LatLng latLng;
private File logFile;
private StringBuilder roadBuilder;
private LatLng rearLatLng;
public static RoadFragment newInstance(Bundle bundle) {
RoadFragment fragment = new RoadFragment();
@ -237,6 +239,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
assert latLineString != null;
latLng = latLineString.get(0);
rearLatLng = latLineString.get(latLineString.size() - 1);
break;
}
BitmapDescriptor roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_show);
@ -360,13 +363,23 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
break;
case R.id.tv_pictures:
roadBuilder.append("点击了自动拍照的按钮 ,");
Intent intent = new Intent(getContext(), PicturesActivity.class);
File finalFile = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intent.putExtra(Constant.INTENT_JPG_PATH, finalFile.getAbsolutePath());
intent.putExtra(Constant.INTENT_VIDEO_OBLATION, 0);
intent.putExtra(Constant.INTENT_POI_VIDEO_TYPE, 3);
intent.putExtra("poiEntity", showPoiEntity);
startActivityForResult(intent, 0x101);
double latitude = Constant.currentLocation.getLatitude();
double longitude = Constant.currentLocation.getLongitude();
LatLng startLatLng = new LatLng(latitude, longitude); //用户当前位置
double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);
double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);
if (geometry>5000||rearGeometry>5000){
Toast.makeText(getActivity(), "用户距离作业起点或者终点五公里以内才能拍摄", Toast.LENGTH_SHORT).show();
return;
}else {
Intent intent = new Intent(getContext(), PicturesActivity.class);
File finalFile = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intent.putExtra(Constant.INTENT_JPG_PATH, finalFile.getAbsolutePath());
intent.putExtra(Constant.INTENT_VIDEO_OBLATION, 0);
intent.putExtra(Constant.INTENT_POI_VIDEO_TYPE, 3);
intent.putExtra("poiEntity", showPoiEntity);
startActivityForResult(intent, 0x101);
}
break;
case R.id.road_upload:
roadBuilder.append("点击了上传的按钮 ,");
@ -378,17 +391,38 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
@Override
public void run() {
ZipUtil.zipFiles(videoFileList, fileZip, null);//压缩
long zipTrueSize = ZipUtils.getZipTrueSize(fileZip.getAbsolutePath());
if (zipTrueSize>0){
if (getActivity()!=null){
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (showPoiEntity == null) {
showPoiEntity = new PoiEntity();
}
if (showPoiEntity.getTaskStatus() == 1 || showPoiEntity.getTaskStatus() == 2 || showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 5) {
initPoiSaveLocal(true);
} else {
poiVideoUpload(showPoiEntity.getBodyId(), fileZip);
Constant.isPresent = false;
}
}
});
}
}else {
if (getActivity()!=null){
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
fileZip.delete();
Toast.makeText(getActivity(), "压缩文件失败,请重新提交", Toast.LENGTH_SHORT).show();
}
});
}
}
}
}).start();
if (showPoiEntity == null) {
showPoiEntity = new PoiEntity();
}
if (showPoiEntity.getTaskStatus() == 1 || showPoiEntity.getTaskStatus() == 2 || showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 5) {
initPoiSaveLocal(true);
} else {
poiVideoUpload(showPoiEntity.getBodyId(), fileZip);
Constant.isPresent = false;
}
} else {
dismissLoadingDialog();
Toast.makeText(getActivity(), "请录像", Toast.LENGTH_SHORT).show();

View File

@ -128,8 +128,8 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
staySubmitAdapter.notifyDataSetChanged();
}
});
if (Constant.currentLocation!=null){
if (Constant.USHERED!=null){
if (Constant.currentLocation != null) {
if (Constant.USHERED != null) {
cbSelect.setChecked(false);
refreshData();
}
@ -166,18 +166,25 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
@Subscribe
public void onEvent(Message data) {
if (data.what == Constant.EVENT_STAY_REFRESH) {
cbSelect.setChecked(false);
if (Constant.currentLocation!=null){
if (Constant.USHERED!=null){
cbSelect.setChecked(false);
if (Constant.currentLocation != null) {
if (Constant.USHERED != null) {
if (cbSelect != null) {
cbSelect.setChecked(false);
}
refreshData();
}
}
}else if (data.what==Constant.NEST_WORD_SUBMIT){
if (messageDialog!=null){
} else if (data.what == Constant.NEST_WORD_SUBMIT) {
if (messageDialog != null) {
messageDialog.doDismiss();
}
}else if (data.what==Constant.STAY_SUBMIT_ITEM){
if ((boolean)data.obj){
if (cbSelect != null) {
cbSelect.setChecked(false);
}
refreshData();
}
}
}
@ -305,52 +312,54 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
}
}
}
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
@Override
public void run() {
StringBuilder taskIds = new StringBuilder();
StringBuilder auditIds = new StringBuilder();
for (int i = 0; i < poiEntities.size(); i++) {
if (poiEntities.get(i).getTaskStatus() == 2) {
taskIds.append(poiEntities.get(i).getTaskId()).append(",");
} else if (poiEntities.get(i).getTaskStatus() == 3) {
auditIds.append(poiEntities.get(i).getBodyId()).append(",");
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
StringBuilder taskIds = new StringBuilder();
StringBuilder auditIds = new StringBuilder();
for (int i = 0; i < poiEntities.size(); i++) {
if (poiEntities.get(i).getTaskStatus() == 2) {
taskIds.append(poiEntities.get(i).getTaskId()).append(",");
} else if (poiEntities.get(i).getTaskStatus() == 3) {
auditIds.append(poiEntities.get(i).getBodyId()).append(",");
}
}
}
if (!taskIds.toString().equals("")) {
taskIds = new StringBuilder(taskIds.substring(0, taskIds.length() - 1));
}
if (!auditIds.toString().equals("")) {
auditIds = new StringBuilder(auditIds.substring(0, auditIds.length() - 1));
}
HttpParams httpParams = new HttpParams();
httpParams.put("taskIds", taskIds.toString());
httpParams.put("auditIds", auditIds.toString());
OkGoBuilder.getInstance()
.Builder(getActivity())
.url(HttpInterface.UNRECEIVED_POLYGON_TASK)
.params(httpParams)
.token(Constant.ACCESS_TOKEN)
.cls(UnPolygonTaskBean.class)
.getRequest(new Callback<UnPolygonTaskBean>() {
@Override
public void onSuccess(UnPolygonTaskBean response, int id) {
dismissLoadingDialog();
if (response.getCode() == 200) {
staySubmitAdapter.setAllCheckedDelete();
} else {
Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show();
if (!taskIds.toString().equals("")) {
taskIds = new StringBuilder(taskIds.substring(0, taskIds.length() - 1));
}
if (!auditIds.toString().equals("")) {
auditIds = new StringBuilder(auditIds.substring(0, auditIds.length() - 1));
}
HttpParams httpParams = new HttpParams();
httpParams.put("taskIds", taskIds.toString());
httpParams.put("auditIds", auditIds.toString());
OkGoBuilder.getInstance()
.Builder(getActivity())
.url(HttpInterface.UNRECEIVED_POLYGON_TASK)
.params(httpParams)
.token(Constant.ACCESS_TOKEN)
.cls(UnPolygonTaskBean.class)
.getRequest(new Callback<UnPolygonTaskBean>() {
@Override
public void onSuccess(UnPolygonTaskBean response, int id) {
dismissLoadingDialog();
if (response.getCode() == 200) {
staySubmitAdapter.setAllCheckedDelete();
} else {
Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show();
}
}
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
Toast.makeText(getActivity(), e.getMessage() + "", Toast.LENGTH_SHORT).show();
}
});
}
});
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
Toast.makeText(getActivity(), e.getMessage() + "", Toast.LENGTH_SHORT).show();
}
});
}
});
}
}
}).start();
}
@ -368,29 +377,30 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
}
PoiDatabase roadDatabase = PoiDatabase.getInstance(getContext());
PoiDao roadDao = roadDatabase.getPoiDao();
if (roadDao!=null){
if (roadDao != null) {
new Thread(new Runnable() {
@Override
public void run() {
List<PoiEntity> roadAll = roadDao.getAllPoiByRecoded();
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
@Override
public void run() {
roadEntities.clear();
roadEntities.addAll(roadAll);
// for (int i = 0; i < roadAll.size(); i++) {
// if (roadAll.get(i).getType()!=6){
// roadEntities.add(roadAll.get(i));
// }
// }
Log.d("TAG", "run: " + roadEntities.toString());
staySubmitAdapter.setAllRoad(roadEntities);
staySubmitAdapter.notifyDataSetChanged();
}
});
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
roadEntities.clear();
roadEntities.addAll(roadAll);
Log.d("TAG", "run: " + roadEntities.toString());
staySubmitAdapter.setAllRoad(roadEntities);
staySubmitAdapter.notifyDataSetChanged();
/*for (int i = 0; i < roadAll.size(); i++) {
if (roadAll.get(i).getType()!=6){
roadEntities.add(roadAll.get(i));
}
}*/
}
});
}
}
}).start();
}
}
@ -401,7 +411,6 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
}
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断

View File

@ -1,6 +1,9 @@
package com.navinfo.outdoor.fragment;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@ -10,6 +13,7 @@ import android.widget.Toast;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.github.lazylibrary.util.FileUtils;
import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.R;
@ -27,8 +31,13 @@ import com.jcodecraeer.xrecyclerview.XRecyclerView;
import org.json.JSONObject;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
/**
@ -38,7 +47,10 @@ public class TaskExplainFragment2 extends BaseFragment implements View.OnClickLi
private XRecyclerView taskExplain2Recycler;
private TaskExplainAdapter2 taskExplainAdapter2;
private List<TaskPrefectureBean.BodyBean.ListBean> explainList;
private int taskExplainPage = 1;
private File logFile;
private StringBuilder taskExplain2Builder;
public static TaskExplainFragment2 newInstance(Bundle bundle) {
TaskExplainFragment2 fragment = new TaskExplainFragment2();
@ -60,32 +72,31 @@ public class TaskExplainFragment2 extends BaseFragment implements View.OnClickLi
ivTaskExplain2.setOnClickListener(this);
taskExplain2Recycler.setLayoutManager(new LinearLayoutManager(getActivity()));
//下划线
// taskExplain2Recycler.addItemDecoration(new DividerItemDecoration(getActivity(),DividerItemDecoration.VERTICAL));
// taskExplain2Recycler.addItemDecoration(new DividerItemDecoration(getActivity(),DividerItemDecoration.VERTICAL));
taskExplain2Recycler.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);
taskExplain2Recycler.setLoadingMoreProgressStyle(ProgressStyle.BallRotate);
//取消上拉加载刷新功能
// taskExplain2Recycler.setPullRefreshEnabled(false);
// taskExplain2Recycler.setLoadingMoreEnabled(false);
taskExplainAdapter2 = new TaskExplainAdapter2(getActivity());
// taskExplain2Recycler.setPullRefreshEnabled(false);
// taskExplain2Recycler.setLoadingMoreEnabled(false);
taskExplainAdapter2 = new TaskExplainAdapter2(explainList,getActivity());
taskExplain2Recycler.setAdapter(taskExplainAdapter2);
taskExplain2Recycler.getDefaultFootView().setNoMoreHint("加载完毕");
taskExplain2Recycler.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
taskExplainAdapter2.taskExplainClearData();
taskExplainPage=1;
initNetWork2();
initNetWork2(true);
}
@Override
public void onLoadMore() {
initNetWork2();
initNetWork2(false);
}
});
taskExplainAdapter2.setOnItemClick(new TaskExplainAdapter2.OnItemClick2() {
@Override
public void onClick2(int pos) {
taskExplain2Builder.append("点击了item ,");
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("id",pos+"");
intint2WebActivity(HttpInterface.MSG_CONTENT, paramMap);
@ -96,17 +107,39 @@ public class TaskExplainFragment2 extends BaseFragment implements View.OnClickLi
@Override
protected void initData() {
super.initData();
ArrayList<TaskExplainInfo.BodyBean.DataBean> dataBeans2 = new ArrayList<>();
initNetWork2();
explainList = new ArrayList<>();
initNetWork2(true);
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String newFormat = formatter.format(new Date(System.currentTimeMillis()));
String pictures_time = sharedPreferences.getString("pictures_time", null);
if (pictures_time == null) {
sharedEdit.putString("pictures_time", newFormat);
sharedEdit.apply();
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
} else {
if (pictures_time.equals(newFormat)) {
logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt");
} else {
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
}
}
taskExplain2Builder = new StringBuilder();
taskExplain2Builder.append("TaskExplainFragment-onCreate-initData ,");
if (Constant.USHERED != null) {
taskExplain2Builder.append("userId:").append(Constant.USHERED).append(",");
}
}
private void initNetWork2() {
showLoadingDialog();
private void initNetWork2(boolean aBoolean) {
String id = Objects.requireNonNull(getActivity()).getIntent().getStringExtra("id");
HttpParams httpParams = new HttpParams();
httpParams.put("fid", id);
httpParams.put("pageNum", taskExplainPage);
httpParams.put("pageSize", "20");
httpParams.put("pageSize", 20);
showLoadingDialog();
OkGoBuilder.getInstance()
.Builder(getActivity())
.url(HttpInterface.LIST_TASK)
@ -118,18 +151,15 @@ public class TaskExplainFragment2 extends BaseFragment implements View.OnClickLi
public void onSuccess(TaskPrefectureBean response, int id) {
dismissLoadingDialog();
if (response.getCode() == 200){
taskExplainAdapter2.setExplainList2(response.getBody().getList());
taskExplainPage++;
initTaskPrefectureBean(response,aBoolean);
}else {
Toast.makeText(getActivity(), response.getMessage()+"", Toast.LENGTH_SHORT).show();
}
taskExplain2Recycler.refreshComplete();
taskExplain2Recycler.loadMoreComplete();
Log.d("TAG", "onSuccess: " + response.getMessage() + "sassafras's");
Log.d("TAG", "onSuccess: " + response.getMessage() + "");
}
@Override
public void onError(Throwable e, int id) {
taskExplain2Recycler.refreshComplete();
taskExplain2Recycler.loadMoreComplete();
dismissLoadingDialog();
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
Log.d("TAG", "onError: " + e.getMessage());
@ -137,10 +167,62 @@ public class TaskExplainFragment2 extends BaseFragment implements View.OnClickLi
});
}
private void initTaskPrefectureBean(TaskPrefectureBean taskPrefectureBean, boolean aBoolean) {
if (taskPrefectureBean.getCode() == 200) {
if (aBoolean) {
if (explainList.size() > 0) {
explainList.clear();
}
if (taskPrefectureBean.getBody().getList()== null) {
Toast.makeText(getActivity(), "没有相关数据", Toast.LENGTH_SHORT).show();
} else {
explainList.addAll(taskPrefectureBean.getBody().getList());
taskExplainPage++;
}
taskExplainAdapter2.notifyDataSetChanged();
taskExplain2Recycler.refreshComplete();
} else {
if (taskPrefectureBean.getBody().getList() == null) {
taskExplain2Recycler.setNoMore(true);
} else {
explainList.addAll(taskPrefectureBean.getBody().getList());
taskExplainAdapter2.notifyDataSetChanged();
taskExplain2Recycler.loadMoreComplete();
taskExplainPage++;
}
}
} else {
Toast.makeText(getActivity(), taskPrefectureBean.getMessage(), Toast.LENGTH_SHORT).show();
Log.d("TAG", "" + taskPrefectureBean.getMessage());
}
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.iv_task_explain2_finish) {
Objects.requireNonNull(getActivity()).finish();
taskExplain2Builder.append("点击了返回的按钮 ,");
}
}
@Override
public void onPause() {
super.onPause();
taskExplain2Builder.append("onPause ,");
}
@Override
public void onStop() {
super.onStop();
taskExplain2Builder.append("onStop ,");
}
@Override
public void onDestroy() {
super.onDestroy();
taskExplain2Builder.append("onDestroy");
taskExplain2Builder.append("\r\n");
FileUtils.writeFile(logFile.getAbsolutePath(), taskExplain2Builder.toString(), true);
}
}

View File

@ -79,6 +79,7 @@ import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
import com.tencent.tencentmap.mapsdk.maps.MapView;
import com.tencent.tencentmap.mapsdk.maps.Projection;
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
import com.tencent.tencentmap.mapsdk.maps.TextureMapView;
import com.tencent.tencentmap.mapsdk.maps.UiSettings;
import com.tencent.tencentmap.mapsdk.maps.interfaces.Removable;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
@ -116,7 +117,7 @@ import java.util.Objects;
* 2021-5-25
*/
public class TreasureFragment extends BaseFragment implements View.OnClickListener {
private MapView treasureMap;
private TextureMapView mapView;
private TencentMap tencentMap;
private CheckBox cbMapType;
private ImageView ivZoomAdd;
@ -298,8 +299,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
ivSubmit.setOnClickListener(this);
ivMessage = findViewById(R.id.iv_message);
ivMessage.setOnClickListener(this);
treasureMap = (MapView) findViewById(R.id.treasure_map);
tencentMap = treasureMap.getMap();
mapView = findViewById(R.id.treasure_map);
tencentMap = mapView.getMap();
// 设置地图宽高为屏幕的宽高
int[] widthHeight = DensityUtil.getDeviceInfo(getActivity());
mapView.getLayoutParams().width = widthHeight[0];
mapView.getLayoutParams().height = widthHeight[1];
ivMassNotification = findViewById(R.id.iv_mas_notification);//定时消息小红点
MapManager.getInstance().init(getActivity(), tencentMap);
cbMapType = (CheckBox) findViewById(R.id.cb_map_type);
@ -387,10 +392,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
tencentMap.setOnMarkerClickListener(Constant.markerClickListener);
}
});
// 设置地图宽高为屏幕的宽高
int[] widthHeight = DensityUtil.getDeviceInfo(getActivity());
treasureMap.getLayoutParams().width = widthHeight[0];
treasureMap.getLayoutParams().height = widthHeight[1];
}
/* //监听回传
@ -411,15 +413,18 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
Toast.makeText(getActivity(), "没有确定经纬度", Toast.LENGTH_SHORT).show();
return;
}
HttpParams httpParams = new HttpParams();
httpParams.put("geo", encode);
OkGoBuilder.getInstance()
.Builder(getActivity())
.url(HttpInterface.GET_PHONES)
.params(new HttpParams("geo", encode))
.params(httpParams)
.cls(GetPhoneBean.class)
.token(Constant.ACCESS_TOKEN)
.getRequest(new Callback<GetPhoneBean>() {
@Override
public void onSuccess(GetPhoneBean getPhoneBean, int id) {
dismissLoadingDialog();
if (getPhoneBean.getCode() == 200) {
String code = getPhoneBean.getBody().getCode();
Integer telLength = getPhoneBean.getBody().getTelLength();
@ -430,6 +435,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
@ -1044,7 +1050,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.grayother);
}
assert latLng != null;
Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor)
.anchor(0.5f, 1f)
.flat(true)
@ -1105,7 +1110,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你poi页面还有未提交完的数据之前的成果已保存点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append("initSharePre-点击了poi,");
treasureBuilder.append("initSharePre-点击了poi");
Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity);
PoiFragment poiFragment = PoiFragment.newInstance(bundle);
@ -1121,7 +1126,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你充电站页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append("initSharePre-点击了充电站,");
treasureBuilder.append("initSharePre-点击了充电站");
Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity);
ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
@ -1137,7 +1142,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你poi录像页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append("initSharePre-点击了poi录像,");
treasureBuilder.append("initSharePre-点击了poi录像");
Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity);
PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
@ -1153,7 +1158,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你道路页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append("initSharePre-点击了道路,");
treasureBuilder.append("initSharePre-点击了道路");
Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity);
RoadFragment roadFragment = RoadFragment.newInstance(bundle);
@ -1169,7 +1174,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你其他页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append("initSharePre-点击了其他,");
treasureBuilder.append("initSharePre-点击了其他");
Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity);
OtherFragment otherFragment = OtherFragment.newInstance(bundle);
@ -1178,7 +1183,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
return false;
}
});
break;
break;
}
}
}
@ -1453,40 +1458,41 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this);
}
treasureMap.onStart();
mapView.onStart();
}
@Override
public void onResume() {
super.onResume();
treasureMap.onResume();
mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
treasureMap.onPause();
mapView.onPause();
treasureBuilder.append("onPause,");
}
@Override
public void onStop() {
super.onStop();
treasureMap.onStop();
mapView.onStop();
treasureBuilder.append("onStop,");
}
@Override
public void onDestroy() {
treasureBuilder.append("onDestroy");
treasureBuilder.append("\r\n");
FileUtils.writeFile(logFile.getAbsolutePath(), treasureBuilder.toString(), true);
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}
super.onDestroy();
treasureMap.onDestroy();
mapView.onDestroy();
treasureBuilder.append("onDestroy");
treasureBuilder.append("\r\n");
FileUtils.writeFile(logFile.getAbsolutePath(), treasureBuilder.toString(), true);
if (bigMarker != null) {
bigMarker.remove();
}
@ -2035,12 +2041,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
int measuredWidth = treasureMap.getWidth();
int measuredHeight = treasureMap.getHeight();
int measuredWidth = mapView.getWidth();
int measuredHeight = mapView.getHeight();
if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
treasureMap.onSizeChanged(measuredHeight, measuredWidth, measuredWidth, measuredHeight);
mapView.onSizeChanged(measuredHeight, measuredWidth, measuredWidth, measuredHeight);
} else if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
treasureMap.onSizeChanged(measuredHeight, measuredWidth, measuredWidth, measuredHeight);
mapView.onSizeChanged(measuredHeight, measuredWidth, measuredWidth, measuredHeight);
}
}

View File

@ -61,6 +61,10 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen
private CheckBox checkBox;
private File logFile;
private StringBuilder withdrawBuilder;
private TextView tvAll;
private ImageView ivWithDraw;
private TextView tvText;
private Button btWithdraw;
public static WithdrawFragment newInstance(Bundle bundle) {
WithdrawFragment fragment = new WithdrawFragment();
@ -106,12 +110,12 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen
tvUnit = findViewById(R.id.tv_unit);//可提现
tvAlready = findViewById(R.id.tv_already);//已提现
tvTotal = findViewById(R.id.tv_total);//总资产
TextView tvAll = findViewById(R.id.tv_all);
tvAll = findViewById(R.id.tv_all);
tvAll.setOnClickListener(this);
etAllPrice = findViewById(R.id.et_allPrice);
ImageView ivWithDraw = findViewById(R.id.iv_withdraw);
ivWithDraw = findViewById(R.id.iv_withdraw);
ivWithDraw.setOnClickListener(this);
TextView tvText = findViewById(R.id.tv_text);
tvText = findViewById(R.id.tv_text);
tvText.setOnClickListener(this);
checkBox = findViewById(R.id.checkBox);
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@ -129,7 +133,7 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen
}
}
});
Button btWithdraw = findViewById(R.id.button);
btWithdraw = findViewById(R.id.button);
btWithdraw.setOnClickListener(this);
poiPushMoney = findViewById(R.id.poi_push_money);
poiReportMoney = findViewById(R.id.poi_report_money);
@ -150,18 +154,16 @@ public class WithdrawFragment extends BaseFragment implements View.OnClickListen
.Builder(getActivity())
.url(HttpInterface.GET_PRICE)
.cls(GetPriceBean.class)
.token(Constant.ACCESS_TOKEN)
.params(new HttpParams())
.token(Constant.ACCESS_TOKEN)
.getRequest(new Callback<GetPriceBean>() {
@Override
public void onSuccess(GetPriceBean response, int id) {
dismissLoadingDialog();
if (response.getCode() == 200) {
GetPriceBean.BodyBean body = response.getBody();
Double userPrice = body.getUserPrice();
tvTotal.setText(userPrice + "");
canExchangePrice = body.getCanExchangePrice();
tvUnit.setText(canExchangePrice + "");
tvTotal.setText(body.getUserPrice() + "");
tvUnit.setText( body.getCanExchangePrice() + "");
tvAlready.setText(body.getHaveExchangePrice()+"");
poiPushMoney.setText(body.getPoiPushPrice()+"");
poiReportMoney.setText(body.getPoiNonepushPrice()+"");

View File

@ -266,74 +266,52 @@ public class PoiSaveUtils {
}
}
}
if (poiEntity.getType()==3||poiEntity.getType()==4){
//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
if (poiEntity.getType() == 1) {
initList(HttpInterface.POI_TASK_UPLOAD_PIC,photoFile,poiEntity);
} else if (poiEntity.getType() == 2) {
initList(HttpInterface.C_TASK_UP_LOAD_PIC,photoFile,poiEntity);
} else if (poiEntity.getType() == 3) {
List<File> videoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
if (videoFileList != null && !videoFileList.isEmpty()) {
File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
ZipUtil.zipFiles(videoFileList, fileZip, null);
photoFile.add(fileZip);
}
}
String url = null;
//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
if (poiEntity.getType() == 1) {
url = HttpInterface.POI_TASK_UPLOAD_PIC;
} else if (poiEntity.getType() == 2) {
url = HttpInterface.C_TASK_UP_LOAD_PIC;
} else if (poiEntity.getType() == 3) {
url = HttpInterface.POI_VIDEO_UPLOAD_PIC;
} else if (poiEntity.getType() == 4) {
url = HttpInterface.ROAD_TASK_UPLOAD_PIC;
} else if (poiEntity.getType() == 5) {
url = HttpInterface.OTHER_TASK_UPLOAD_PIC;
}
try {
HttpParams httpParams = new HttpParams();
httpParams.put("auditId", bodyId);
Response execute = OkGoBuilder.getInstance()
.Builder(mContext)
.url(url)
.params(httpParams)
.token(Constant.ACCESS_TOKEN)
.fileList(photoFile).postFileSynchronization();
if (execute == null) {
return;
}
if (execute.code() != 200) {
return;
}
assert execute.body() != null;
String bodyStr = execute.body().string();
if (bodyStr == null) {
return;
}
Gson gson = new Gson();
OtherUploadPicBean otherUploadPicBean = gson.fromJson(bodyStr, OtherUploadPicBean.class);
if (otherUploadPicBean.getCode() == 200) {
PoiDatabase.getInstance(mContext).getPoiDao().deletePoiEntity(poiEntity);
for (int i = 0; i < photoFile.size(); i++) {
photoFile.get(i).delete();
}
if (poiEntity.getType()==3||poiEntity.getType()==4) {
if (poiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
filePath.delete();
if (photoFile.size()>0){
long zipTrueSize = ZipUtils.getZipTrueSize(photoFile.get(0).getAbsolutePath());
if (zipTrueSize>0){
initList(HttpInterface.POI_VIDEO_UPLOAD_PIC,photoFile,poiEntity);
}else {
for (int i = 0; i < photoFile.size(); i++) {
photoFile.get(i).delete();
}
bInt++;
return;
}
Log.d("TAGss", "uploadPoiNet: 成功" + anInt);
anInt++;
return;
} else {
Log.d("TAGss", "uploadPoiNet: 失败" + bInt);
bInt++;
return;
}
} catch (IOException e) {
e.printStackTrace();
} else if (poiEntity.getType() == 4) {
List<File> videoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
if (videoFileList != null && !videoFileList.isEmpty()) {
File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
ZipUtil.zipFiles(videoFileList, fileZip, null);
photoFile.add(fileZip);
}
if (photoFile.size()>0){
long zipTrueSize = ZipUtils.getZipTrueSize(photoFile.get(0).getAbsolutePath());
if (zipTrueSize>0){
initList(HttpInterface.ROAD_TASK_UPLOAD_PIC,photoFile,poiEntity);
}else {
for (int i = 0; i < photoFile.size(); i++) {
photoFile.get(i).delete();
}
bInt++;
return;
}
}
} else if (poiEntity.getType() == 5) {
initList(HttpInterface.OTHER_TASK_UPLOAD_PIC,photoFile,poiEntity);
}
/* OkGo
// 请求方式和请求url
@ -358,6 +336,58 @@ public class PoiSaveUtils {
});*/
}
private void initList(String url,List<File> list,PoiEntity poiEntity) {
try {
HttpParams httpParams = new HttpParams();
httpParams.put("auditId", poiEntity.getBodyId());
Response execute = OkGoBuilder.getInstance()
.Builder(mContext)
.url(url)
.params(httpParams)
.token(Constant.ACCESS_TOKEN)
.fileList(list)
.postFileSynchronization();
if (execute == null) {
return;
}
if (execute.code() != 200) {
return;
}
assert execute.body() != null;
String bodyStr = execute.body().string();
if (bodyStr == null) {
return;
}
Gson gson = new Gson();
OtherUploadPicBean otherUploadPicBean = gson.fromJson(bodyStr, OtherUploadPicBean.class);
if (otherUploadPicBean.getCode() == 200) {
PoiDatabase.getInstance(mContext).getPoiDao().deletePoiEntity(poiEntity);
for (int i = 0; i < list.size(); i++) {
list.get(i).delete();
}
if (poiEntity.getType()==3||poiEntity.getType()==4) {
if (poiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
filePath.delete();
}
}
Log.d("TAGss", "uploadPoiNet: 成功" + anInt);
anInt++;
return;
} else {
Log.d("TAGss", "uploadPoiNet: 失败" + bInt);
bInt++;
return;
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 根据充电站数据检查充电桩数据如果没有网络保存则批量网络保存
*/
@ -366,21 +396,19 @@ public class PoiSaveUtils {
if (chargingStationPoiEntity != null) {
List<ChargingPileEntity> chargingPileEntityList = PoiDatabase.getInstance(mContext).getChargingPileDao().getChargingPileByStationId(chargingStationPoiEntity.getId());
PoiEntity poiEntity = PoiDatabase.getInstance(mContext).getPoiDao().getPoiEntity(chargingStationPoiEntity.getId());
if (poiEntity!=null){
if (chargingPileEntityList != null && !chargingPileEntityList.isEmpty()) {
// 依次上传充电桩数据如果有一条数据未上传成功则返回false
for (ChargingPileEntity pileEntity : chargingPileEntityList) {
if (pileEntity.getBodyId() == 0) {
int saveResult = saveChargingPile2NetWork(pileEntity, poiEntity.getBodyId());
if (saveResult == 200) {
result = result & true;
} else {
result = result & false;
}
if (chargingPileEntityList != null && !chargingPileEntityList.isEmpty()) {
// 依次上传充电桩数据如果有一条数据未上传成功则返回false
for (ChargingPileEntity pileEntity : chargingPileEntityList) {
if (pileEntity.getBodyId() == 0) {
int saveResult = saveChargingPile2NetWork(pileEntity, poiEntity.getBodyId());
if (saveResult == 200) {
result = result & true;
} else {
result = result & false;
}
}
}
}
}
Log.d("TAGss", "saveChargingPileByChargingStation" + result);

View File

@ -0,0 +1,308 @@
package com.navinfo.outdoor.util;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
/**
* Java utils 实现的Zip工具
*
* @author once
*/
public class ZipUtils{
private static final int BUFF_SIZE = 1024 * 1024; // 1M Byte
private static boolean stopZipFlag;
/**
* 批量压缩文件
*
* @param resFileList 要压缩的文件列表
* @param zipFile 生成的压缩文件
*/
public static void zipFiles(Collection<File> resFileList, File zipFile) {
ZipOutputStream zipout = null;
try {
zipout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(
zipFile), BUFF_SIZE));
for (File resFile : resFileList) {
if(stopZipFlag){
break;
}
zipFile(resFile, zipout, "");
}
zipout.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 批量压缩文件
*
* @param resFileList 要压缩的文件列表
* @param zipFile 生成的压缩文件
* @param comment 压缩文件的注释
* @param zipListener zipListener
*/
public static void zipFiles(Collection<File> resFileList, File zipFile, String comment, com.github.lazylibrary.util.ZipUtil.ZipListener zipListener)
{
ZipOutputStream zipout = null;
try {
zipout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile), BUFF_SIZE));
for (File resFile : resFileList) {
zipFile(resFile, zipout, "");
}
zipout.setComment(comment);
zipout.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 解压缩一个文件
*
* @param zipFile 压缩文件
* @param folderPath 解压缩的目标目录
*/
public static void upZipFile(File zipFile, String folderPath) {
File desDir = new File(folderPath);
if (!desDir.exists()) {
desDir.mkdirs();
}
ZipFile zf = null;
try {
zf = new ZipFile(zipFile);
for (Enumeration<?> entries = zf.entries(); entries.hasMoreElements();) {
ZipEntry entry = ((ZipEntry)entries.nextElement());
InputStream in = zf.getInputStream(entry);
String str = folderPath + File.separator + entry.getName();
str = new String(str.getBytes("8859_1"), "GB2312");
File desFile = new File(str);
if (!desFile.exists()) {
File fileParentDir = desFile.getParentFile();
if (!fileParentDir.exists()) {
fileParentDir.mkdirs();
}
desFile.createNewFile();
}
OutputStream out = new FileOutputStream(desFile);
byte buffer[] = new byte[BUFF_SIZE];
int realLength;
while ((realLength = in.read(buffer)) > 0) {
out.write(buffer, 0, realLength);
}
in.close();
out.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 解压文件名包含传入文字的文件
*
* @param zipFile 压缩文件
* @param folderPath 目标文件夹
* @param nameContains 传入的文件匹配名
* @return 返回的集合
*/
public static ArrayList<File> upZipSelectedFile(File zipFile, String folderPath,
String nameContains) {
ArrayList<File> fileList = new ArrayList<File>();
File desDir = new File(folderPath);
if (!desDir.exists()) {
desDir.mkdir();
}
ZipFile zf = null;
try {
zf = new ZipFile(zipFile);
for (Enumeration<?> entries = zf.entries(); entries.hasMoreElements();) {
ZipEntry entry = ((ZipEntry)entries.nextElement());
if (entry.getName().contains(nameContains)) {
InputStream in = zf.getInputStream(entry);
String str = folderPath + File.separator + entry.getName();
str = new String(str.getBytes("8859_1"), "GB2312");
// str.getBytes("GB2312"),"8859_1" 输出
// str.getBytes("8859_1"),"GB2312" 输入
File desFile = new File(str);
if (!desFile.exists()) {
File fileParentDir = desFile.getParentFile();
if (!fileParentDir.exists()) {
fileParentDir.mkdirs();
}
desFile.createNewFile();
}
OutputStream out = new FileOutputStream(desFile);
byte buffer[] = new byte[BUFF_SIZE];
int realLength;
while ((realLength = in.read(buffer)) > 0) {
out.write(buffer, 0, realLength);
}
in.close();
out.close();
fileList.add(desFile);
}
}
return fileList;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 获得压缩文件内文件列表
*
* @param zipFile 压缩文件
* @return 压缩文件内文件名称
*/
public static ArrayList<String> getEntriesNames(File zipFile) {
ArrayList<String> entryNames = new ArrayList<String>();
Enumeration<?> entries = null;
try {
entries = getEntriesEnumeration(zipFile);
while (entries.hasMoreElements()) {
ZipEntry entry = ((ZipEntry)entries.nextElement());
entryNames.add(new String(getEntryName(entry).getBytes("GB2312"), "8859_1"));
}
return entryNames;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* 获得压缩文件内压缩文件对象以取得其属性
*
* @param zipFile 压缩文件
* @return 返回一个压缩文件列表
*/
public static Enumeration<?> getEntriesEnumeration(File zipFile) {
ZipFile zf = null;
try {
zf = new ZipFile(zipFile);
} catch (IOException e) {
e.printStackTrace();
}
return zf.entries();
}
/**
* 取得压缩文件对象的注释
*
* @param entry 压缩文件对象
* @return 压缩文件对象的注释
*/
public static String getEntryComment(ZipEntry entry) {
try {
return new String(entry.getComment().getBytes("GB2312"), "8859_1");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
/**
* 取得压缩文件对象的名称
*
* @param entry 压缩文件对象
* @return 压缩文件对象的名称
*/
public static String getEntryName(ZipEntry entry) {
try {
return new String(entry.getName().getBytes("GB2312"), "8859_1");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
/**
* 压缩文件
*
* @param resFile 需要压缩的文件
* @param zipout 压缩的目的文件
* @param rootpath 压缩的文件路径
*/
private static void zipFile(File resFile, ZipOutputStream zipout, String rootpath) {
try {
rootpath = rootpath + (rootpath.trim().length() == 0 ? "" : File.separator)
+ resFile.getName();
rootpath = new String(rootpath.getBytes("8859_1"), "GB2312");
if (resFile.isDirectory()) {
File[] fileList = resFile.listFiles();
int length=fileList.length;
// Log.e("zipprogress", (int)((1 / (float) (length+1))*100)+"%");
//zipListener.zipProgress((int)((1 / (float) (length+1))*100));
for (int i=0;i<length;i++) {
if(stopZipFlag){
break;
}
File file=fileList[i];
zipFile(file, zipout, rootpath);
// Log.e("zipprogress", (int)(((i+2) / (float) (length+1))*100)+"%");
/// zipListener.zipProgress((int)(((i+2) / (float) (length+1))*100));
}
} else {
byte buffer[] = new byte[BUFF_SIZE];
BufferedInputStream in = new BufferedInputStream(new FileInputStream(resFile),
BUFF_SIZE);
zipout.putNextEntry(new ZipEntry(rootpath));
int realLength;
while ((realLength = in.read(buffer)) != -1) {
if(stopZipFlag){
break;
}
zipout.write(buffer, 0, realLength);
}
in.close();
zipout.flush();
zipout.closeEntry();
}
}catch (Exception e){
e.printStackTrace();
}
}
public static long getZipTrueSize(String filePath) {
long size = 0;
ZipFile f;
try {
f = new ZipFile(filePath);
Enumeration<? extends ZipEntry> en = f.entries();
while (en.hasMoreElements()) {
size += en.nextElement().getSize();
}
} catch (IOException e) {
e.printStackTrace();
}
return size;
}
public interface ZipListener{
void zipProgress(int zipProgress);
}
}

View File

@ -14,23 +14,23 @@
<FrameLayout
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent">
<com.tencent.tencentmap.mapsdk.maps.MapView
<com.tencent.tencentmap.mapsdk.maps.TextureMapView
android:id="@+id/treasure_map"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"></com.tencent.tencentmap.mapsdk.maps.MapView>
android:gravity="center">
</com.tencent.tencentmap.mapsdk.maps.TextureMapView>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:id="@+id/iv_message"
android:layout_width="25dp"
@ -39,7 +39,8 @@
android:layout_marginTop="80dp"
android:background="@drawable/iv_message"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"></ImageView>
app:layout_constraintTop_toTopOf="parent">
</ImageView>
<ImageView
android:id="@+id/iv_mas_notification"
@ -153,7 +154,8 @@
<FrameLayout
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"></FrameLayout>
android:layout_height="wrap_content">
</FrameLayout>
</LinearLayout>