解决bug
This commit is contained in:
@@ -21,6 +21,10 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.UserApplication;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.navinfo.outdoor.util.NetWorkUtils;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
@@ -64,19 +68,64 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
protected void initMVP() {
|
||||
}
|
||||
public void showLoadingDialog() {
|
||||
alertDialog = new AlertDialog.Builder(this).create();
|
||||
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable());
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.setOnKeyListener((dialog, keyCode, event) -> {
|
||||
if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_BACK)
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
//loading样式
|
||||
View view = LayoutInflater.from(this).inflate(R.layout.loading, null);
|
||||
alertDialog.setView(view);
|
||||
alertDialog.setCanceledOnTouchOutside(false);
|
||||
alertDialog.show();
|
||||
if (NetWorkUtils.iConnected(this)) { // 当前网络可用
|
||||
alertDialog = new AlertDialog.Builder(this).create();
|
||||
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable());
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.setOnKeyListener((dialog, keyCode, event) -> {
|
||||
if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_BACK)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
});
|
||||
//loading样式
|
||||
View view = LayoutInflater.from(this).inflate(R.layout.loading, null);
|
||||
alertDialog.setView(view);
|
||||
alertDialog.setCanceledOnTouchOutside(false);
|
||||
alertDialog.show();
|
||||
initTimer();
|
||||
} else {
|
||||
Toast.makeText(this, "网络不可用", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
public void showFileLoadingDialog() {
|
||||
if (NetWorkUtils.iConnected(this)) { // 当前网络可用
|
||||
alertDialog = new AlertDialog.Builder(this).create();
|
||||
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable());
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.setOnKeyListener((dialog, keyCode, event) -> {
|
||||
if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_BACK)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
});
|
||||
//loading样式
|
||||
View view = LayoutInflater.from(this).inflate(R.layout.loading, null);
|
||||
alertDialog.setView(view);
|
||||
alertDialog.setCanceledOnTouchOutside(false);
|
||||
alertDialog.show();
|
||||
} else {
|
||||
Toast.makeText(this, "网络不可用", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void initTimer() {
|
||||
Timer timer = new Timer(true);
|
||||
TimerTask timerTask = new TimerTask() {
|
||||
int countTime = 20;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (countTime > 0) {
|
||||
countTime--;
|
||||
}
|
||||
if (countTime == 1) {
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
timer.schedule(timerTask, 1000, 1000);
|
||||
}
|
||||
|
||||
public void setLoadingDialogText(String s) {
|
||||
|
||||
@@ -87,19 +87,31 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
|
||||
alertDialog.setView(view);
|
||||
alertDialog.setCanceledOnTouchOutside(false);
|
||||
alertDialog.show();
|
||||
/* final Timer timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
alertDialog.dismiss();
|
||||
timer.cancel();
|
||||
}
|
||||
},10000);*/
|
||||
initTimer();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), "网络不可用", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
public void showFileLoadingDialog() {
|
||||
if (NetWorkUtils.iConnected(getContext())) { // 当前网络可用
|
||||
alertDialog = new AlertDialog.Builder(getActivity()).create();
|
||||
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable());
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.setOnKeyListener((dialog, keyCode, event) -> {
|
||||
if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_BACK)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
});
|
||||
//loading样式
|
||||
View view = LayoutInflater.from(getContext()).inflate(R.layout.loading, null);
|
||||
alertDialog.setView(view);
|
||||
alertDialog.setCanceledOnTouchOutside(false);
|
||||
alertDialog.show();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), "网络不可用", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void initTimer() {
|
||||
Timer timer = new Timer(true);
|
||||
|
||||
@@ -993,7 +993,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
}
|
||||
|
||||
private void stationUploadByNetWork(PoiEntity poiEntity, ArrayList<File> chargingStationList) {
|
||||
showLoadingDialog();
|
||||
showFileLoadingDialog();
|
||||
if (poiEntity == null || poiEntity.getBodyId() == 0) {
|
||||
Toast.makeText(getActivity(), "没有保存本地", Toast.LENGTH_SHORT).show();
|
||||
Log.e("TAG", "poiUploadByNetWork: " + poiEntity.getBodyId() + chargingStationList);
|
||||
|
||||
@@ -178,7 +178,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
}
|
||||
break;
|
||||
case R.id.btn_get_task://领取任务
|
||||
if (poiEntity.getTaskStatus() < 2) {
|
||||
/* if (poiEntity.getTaskStatus() < 2) {
|
||||
double latitude = Constant.currentLocation.getLatitude();
|
||||
double longitude = Constant.currentLocation.getLongitude();
|
||||
LatLng startLatLng = new LatLng(latitude, longitude); //用户当前位置
|
||||
@@ -188,7 +188,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
Toast.makeText(getActivity(), "作业不在领取范围内,无法领取", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (poiEntity != null) {
|
||||
int type = poiEntity.getType();
|
||||
|
||||
@@ -468,7 +468,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
Log.e("TAG", "poiUploadByNetWork: " + body + otherUploadList);
|
||||
return;
|
||||
}
|
||||
showLoadingDialog();
|
||||
showFileLoadingDialog();
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<PoiUploadBean>post(HttpInterface.OTHER_TASK_UPLOAD_PIC)
|
||||
|
||||
@@ -739,7 +739,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
Log.e("TAG", "poiUploadByNetWork: " + body + poiPicList);
|
||||
return;
|
||||
}
|
||||
showLoadingDialog();
|
||||
showFileLoadingDialog();
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<OtherUploadPicBean>post(HttpInterface.POI_TASK_UPLOAD_PIC)
|
||||
|
||||
@@ -486,7 +486,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
Toast.makeText(getActivity(), "未压缩完成", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
showLoadingDialog();
|
||||
showFileLoadingDialog();
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<OtherUploadPicBean>post(HttpInterface.POI_VIDEO_UPLOAD_PIC)
|
||||
|
||||
@@ -498,6 +498,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
Toast.makeText(getContext(), "未压缩完成", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
showFileLoadingDialog();
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<OtherUploadPicBean>post(HttpInterface.ROAD_TASK_UPLOAD_PIC)
|
||||
|
||||
Reference in New Issue
Block a user