修改bug

This commit is contained in:
wds 2021-08-04 14:52:07 +08:00
parent 30ad378cde
commit 4f157306ad
5 changed files with 112 additions and 42 deletions

View File

@ -4,6 +4,8 @@ import android.graphics.Color;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -27,6 +29,9 @@ import com.navinfo.outdoor.util.BackHandlerHelper;
import com.navinfo.outdoor.util.FragmentBackHandler; import com.navinfo.outdoor.util.FragmentBackHandler;
import com.navinfo.outdoor.util.NetWorkUtils; import com.navinfo.outdoor.util.NetWorkUtils;
import java.util.Timer;
import java.util.TimerTask;
public abstract class BaseFragment extends Fragment implements FragmentBackHandler { public abstract class BaseFragment extends Fragment implements FragmentBackHandler {
@ -57,8 +62,7 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
return false; return false;
} }
public void initEvent() { public void initEvent() {}
}
protected <T extends View> T findViewById(@IdRes int id) { protected <T extends View> T findViewById(@IdRes int id) {
return getView().findViewById(id); return getView().findViewById(id);
@ -81,14 +85,42 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
//loading样式 //loading样式
View view = LayoutInflater.from(getContext()).inflate(R.layout.loading, null); View view = LayoutInflater.from(getContext()).inflate(R.layout.loading, null);
alertDialog.setView(view); alertDialog.setView(view);
alertDialog.setCanceledOnTouchOutside(false); alertDialog.setCanceledOnTouchOutside(false);
alertDialog.show(); alertDialog.show();
/* final Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
alertDialog.dismiss();
timer.cancel();
}
},10000);*/
initTimer();
} else { } else {
Toast.makeText(getActivity(), "网络不可用", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), "网络不可用", Toast.LENGTH_SHORT).show();
} }
} }
private void initTimer() {
Timer timer = new Timer(true);
TimerTask timerTask = new TimerTask() {
int countTime = 10;
@Override
public void run() {
if (countTime > 0) {
countTime--;
}
if (countTime == 1) {
dismissLoadingDialog();
}
}
};
timer.schedule(timerTask, 1000, 1000);
}
public void setLoadingDialogText(String s) { public void setLoadingDialogText(String s) {
//给loading 添加文字 //给loading 添加文字
TextView view = alertDialog.findViewById(R.id.progressBar_tx); TextView view = alertDialog.findViewById(R.id.progressBar_tx);
@ -108,18 +140,14 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
} }
} }
protected void initMvp() { protected void initMvp() {}
}
protected void initData() { protected void initData() {}
}
protected void initView() { protected void initView() {}
}
@Override @Override
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
} }
} }

View File

@ -62,6 +62,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
fragment.setArguments(bundle); fragment.setArguments(bundle);
return fragment; return fragment;
} }
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
@ -72,7 +73,6 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
} }
@Override @Override
protected int getLayout() { protected int getLayout() {
return R.layout.fragment_stay_submit; return R.layout.fragment_stay_submit;
@ -122,18 +122,13 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
}); });
refreshData(); refreshData();
} }
@Subscribe @Subscribe
public void onEvent(Message data) { public void onEvent(Message data) {
if (data.what == Constant.EVENT_STAY_REFRESH) { if (data.what == Constant.EVENT_STAY_REFRESH) {
if ((boolean)data.obj){ Toast.makeText(getContext(), (String) data.obj, Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), "提交成功", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(getContext(), "提交失败", Toast.LENGTH_SHORT).show();
}
dismissLoadingDialog(); dismissLoadingDialog();
refreshData(); refreshData();
} }
} }
@ -209,20 +204,20 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
}); });
break; break;
case R.id.btn_stay_submit://提交 case R.id.btn_stay_submit://提交
if (poiEntities==null){ if (poiEntities == null) {
poiEntities = new ArrayList<>(); poiEntities = new ArrayList<>();
} }
poiEntities.clear(); poiEntities.clear();
List<PoiEntity> allRoad = staySubmitAdapter.getAllRoad(); List<PoiEntity> allRoad = staySubmitAdapter.getAllRoad();
for (int i = 0; i < allRoad.size(); i++) { for (int i = 0; i < allRoad.size(); i++) {
if (allRoad.get(i).isChecked()){ if (allRoad.get(i).isChecked()) {
poiEntities.add(allRoad.get(i)); poiEntities.add(allRoad.get(i));
} }
} }
if (poiEntities.size()>0){ if (poiEntities.size() > 0) {
showLoadingDialog(); showLoadingDialog();
PoiSaveUtils.getInstance(getActivity()).uploadPoiEntityBatch(poiEntities); PoiSaveUtils.getInstance(getActivity()).uploadPoiEntityBatch(poiEntities);
}else { } else {
Toast.makeText(getContext(), "请选择要删除的条目数据", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "请选择要删除的条目数据", Toast.LENGTH_SHORT).show();
} }
@ -234,28 +229,29 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
if (roadEntities == null) { if (roadEntities == null) {
roadEntities = new ArrayList<>(); roadEntities = new ArrayList<>();
}else { } else {
roadEntities.clear(); roadEntities.clear();
} }
if (newEntities == null) { if (newEntities == null) {
newEntities = new ArrayList<>(); newEntities = new ArrayList<>();
}else { } else {
newEntities.clear(); newEntities.clear();
} }
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
List<PoiEntity> roadAll = roadDao.getAllPoi(); List<PoiEntity> roadAll = roadDao.getAllPoiByRecoder();
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
roadEntities.clear(); roadEntities.clear();
for (int i = 0; i < roadAll.size(); i++) { roadEntities.addAll(roadAll);
if (roadAll.get(i).getType()!=6){ // for (int i = 0; i < roadAll.size(); i++) {
roadEntities.add(roadAll.get(i)); // if (roadAll.get(i).getType()!=6){
} // roadEntities.add(roadAll.get(i));
} // }
// }
Log.d("TAG", "run: " + roadEntities.toString()); Log.d("TAG", "run: " + roadEntities.toString());
staySubmitAdapter.setAllRoad(roadEntities); staySubmitAdapter.setAllRoad(roadEntities);
staySubmitAdapter.notifyDataSetChanged(); staySubmitAdapter.notifyDataSetChanged();

View File

@ -676,8 +676,13 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
} }
switch (Integer.valueOf(poiEntity.getType())) { switch (Integer.valueOf(poiEntity.getType())) {
case 1://poi case 1://poi
BitmapDescriptor poiDescriptor=null;
if (poiEntity.getTaskStatus()==1){
poiDescriptor= BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bg1);
}else {
poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.graypoi);
}
BitmapDescriptor poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.graypoi);
Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f) Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f)
.flat(true) .flat(true)
.clockwise(false)); .clockwise(false));
@ -690,7 +695,13 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
break; break;
case 2://充电站 case 2://充电站
BitmapDescriptor chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.graycharge); BitmapDescriptor chargeDescriptor = null;
if (poiEntity.getTaskStatus()==1){
chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_bg1);
}else {
chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.graycharge);
}
Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(chargeDescriptor).alpha(0.9f) Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(chargeDescriptor).alpha(0.9f)
.flat(true) .flat(true)
.clockwise(false)); .clockwise(false));
@ -701,7 +712,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
removablesLocality.add(stationMarker); removablesLocality.add(stationMarker);
break; break;
case 3://poi录像 case 3://poi录像
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_have_bg); BitmapDescriptor poiVideoDescriptor = null;
if (poiEntity.getTaskStatus()==1){
poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_bg1);
}else {
poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_have_bg);
}
Marker poiVideoMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).alpha(0.9f) Marker poiVideoMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).alpha(0.9f)
.flat(true) .flat(true)
.clockwise(false)); .clockwise(false));
@ -712,7 +728,13 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
removablesLocality.add(poiVideoMarker); removablesLocality.add(poiVideoMarker);
break; break;
case 4://道路录像 case 4://道路录像
BitmapDescriptor roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.grayroad); BitmapDescriptor roadDescriptor =null;
if (poiEntity.getTaskStatus()==1){
roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_bg);
}else {
roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.grayroad);
}
Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).alpha(0.9f) Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).alpha(0.9f)
.flat(true) .flat(true)
.clockwise(false)); .clockwise(false));
@ -723,7 +745,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
removablesLocality.add(roadMarker); removablesLocality.add(roadMarker);
break; break;
case 5://其他 case 5://其他
BitmapDescriptor otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.grayother); BitmapDescriptor otherDescriptor = null;
if (poiEntity.getTaskStatus()==1){
otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_bg1);
}else {
otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.grayother);
}
Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).alpha(0.9f) Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).alpha(0.9f)
.flat(true) .flat(true)
.clockwise(false)); .clockwise(false));
@ -734,7 +761,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
removablesLocality.add(otherMarker); removablesLocality.add(otherMarker);
break; break;
case 6://面状任务 case 6://面状任务
BitmapDescriptor Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_have_bag); BitmapDescriptor Descriptor =null;
if (poiEntity.getTaskStatus()==1){
Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_bg);
}else {
Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_have_bag);
}
Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f) Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f)
.clockwise(false) .clockwise(false)
.flat(true)); .flat(true));
@ -746,6 +778,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
break; break;
} }
} }
Message obtain = Message.obtain(); Message obtain = Message.obtain();
obtain.what = Constant.JOB_SEARCH_POI_WORD; obtain.what = Constant.JOB_SEARCH_POI_WORD;
obtain.obj = allTaskStatus; obtain.obj = allTaskStatus;
@ -772,6 +805,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity); bundle.putSerializable("poiEntity", poiEntity);
PoiFragment poiFragment = PoiFragment.newInstance(bundle); PoiFragment poiFragment = PoiFragment.newInstance(bundle);
LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()),Double.valueOf(poiEntity.getX()));
showPoiMarkerByType(1, newPoiLatLng);
showSlidingFragment(poiFragment); showSlidingFragment(poiFragment);
initRemovePoiSharePre(); initRemovePoiSharePre();
return false; return false;
@ -786,6 +821,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity); bundle.putSerializable("poiEntity", poiEntity);
ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle); ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()),Double.valueOf(poiEntity.getX()));
showPoiMarkerByType(4, newPoiLatLng);
showSlidingFragment(chargingStationFragment); showSlidingFragment(chargingStationFragment);
initRemovePoiSharePre(); initRemovePoiSharePre();
return false; return false;
@ -800,6 +837,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity); bundle.putSerializable("poiEntity", poiEntity);
PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle); PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()),Double.valueOf(poiEntity.getX()));
showPoiMarkerByType(2, newPoiLatLng);
showSlidingFragment(poiVideoFragment); showSlidingFragment(poiVideoFragment);
initRemovePoiSharePre(); initRemovePoiSharePre();
return false; return false;
@ -814,6 +853,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity); bundle.putSerializable("poiEntity", poiEntity);
RoadFragment roadFragment = RoadFragment.newInstance(bundle); RoadFragment roadFragment = RoadFragment.newInstance(bundle);
LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()),Double.valueOf(poiEntity.getX()));
showPoiMarkerByType(3, newPoiLatLng);
showSlidingFragment(roadFragment); showSlidingFragment(roadFragment);
initRemovePoiSharePre(); initRemovePoiSharePre();
return false; return false;
@ -829,6 +870,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity); bundle.putSerializable("poiEntity", poiEntity);
OtherFragment otherFragment = OtherFragment.newInstance(bundle); OtherFragment otherFragment = OtherFragment.newInstance(bundle);
LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()),Double.valueOf(poiEntity.getX()));
showPoiMarkerByType(5, newPoiLatLng);
showSlidingFragment(otherFragment); showSlidingFragment(otherFragment);
initRemovePoiSharePre(); initRemovePoiSharePre();
return false; return false;
@ -1105,7 +1148,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
} else { } else {
frameLayout.setVisibility(View.VISIBLE); frameLayout.setVisibility(View.VISIBLE);
} }
} }
} }

View File

@ -22,6 +22,9 @@ public interface PoiDao {
@Query("SELECT * FROM poi") @Query("SELECT * FROM poi")
List<PoiEntity> getAllPoi(); List<PoiEntity> getAllPoi();
@Query("SELECT * FROM poi where taskStatus > 1 and type!=6")
List<PoiEntity> getAllPoiByRecoder();
@Query("SELECT * FROM poi where type=:type") @Query("SELECT * FROM poi where type=:type")
List<PoiEntity> getAllPoiType(int type); List<PoiEntity> getAllPoiType(int type);

View File

@ -46,7 +46,8 @@ public class PoiSaveUtils {
private Activity mContext; private Activity mContext;
private Gson gson; private Gson gson;
private static PoiSaveUtils instance; private static PoiSaveUtils instance;
private boolean isBoolean; private int anInt=0;
private int bInt=1;
public static PoiSaveUtils getInstance(Activity mContext) { public static PoiSaveUtils getInstance(Activity mContext) {
if (instance == null) { if (instance == null) {
@ -96,7 +97,7 @@ public class PoiSaveUtils {
public void run() { public void run() {
Message obtain = Message.obtain(); Message obtain = Message.obtain();
obtain.what = Constant.EVENT_STAY_REFRESH; obtain.what = Constant.EVENT_STAY_REFRESH;
obtain.obj = isBoolean; obtain.obj = "提交成功"+anInt+",提交失败"+bInt;
EventBus.getDefault().post(obtain); EventBus.getDefault().post(obtain);
} }
}); });
@ -294,10 +295,10 @@ public class PoiSaveUtils {
if (otherUploadPicBean.getCode() == 200) { if (otherUploadPicBean.getCode() == 200) {
PoiDatabase.getInstance(mContext).getPoiDao().deletePoiEntity(poiEntity); PoiDatabase.getInstance(mContext).getPoiDao().deletePoiEntity(poiEntity);
Log.d("TAGss", "uploadPoiNet: 成功"); Log.d("TAGss", "uploadPoiNet: 成功");
isBoolean=true; anInt++;
} else { } else {
Log.d("TAGss", "uploadPoiNet: 失败"); Log.d("TAGss", "uploadPoiNet: 失败");
isBoolean=false; bInt++;
return; return;
} }
} catch (IOException e) { } catch (IOException e) {