2022-03-14 09:53:00 +00:00
|
|
|
package com.safemobile.dispatch;
|
|
|
|
|
2022-03-18 13:03:34 +00:00
|
|
|
import androidx.annotation.NonNull;
|
2022-03-14 09:53:00 +00:00
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
2022-03-17 08:18:23 +00:00
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.Spinner;
|
|
|
|
import android.widget.TextView;
|
2022-03-14 09:53:00 +00:00
|
|
|
|
2022-03-18 13:03:34 +00:00
|
|
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
2022-03-17 08:18:23 +00:00
|
|
|
import com.google.android.gms.maps.GoogleMap;
|
2022-03-18 13:03:34 +00:00
|
|
|
import com.google.android.gms.maps.OnMapReadyCallback;
|
2022-03-17 08:18:23 +00:00
|
|
|
import com.google.android.gms.maps.SupportMapFragment;
|
2022-03-18 13:03:34 +00:00
|
|
|
import com.google.android.gms.maps.model.LatLng;
|
|
|
|
import com.google.android.gms.maps.model.MarkerOptions;
|
2022-03-17 08:18:23 +00:00
|
|
|
import com.safemobile.lib.AppParams;
|
2022-03-14 09:53:00 +00:00
|
|
|
import com.safemobile.lib.SM;
|
2022-03-17 08:18:23 +00:00
|
|
|
import com.safemobile.lib.Vehicle;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Locale;
|
2022-03-14 09:53:00 +00:00
|
|
|
|
2022-03-18 13:03:34 +00:00
|
|
|
public class HistoryActivity extends AppCompatActivity implements OnMapReadyCallback {
|
2022-03-14 09:53:00 +00:00
|
|
|
|
|
|
|
public Bundle savedInstanceState;
|
2022-03-16 14:40:34 +00:00
|
|
|
private TabLayoutActivity parentTab;
|
2022-03-17 08:18:23 +00:00
|
|
|
private GoogleMap googleMap;
|
|
|
|
private Spinner spinnerVehicle;
|
|
|
|
private ImageView changeMapType, checkTraffic, slideLayoutImage;
|
|
|
|
private LinearLayout layoutTraffic, slidelayout, layoutVehicles;
|
2022-03-16 14:40:34 +00:00
|
|
|
|
2022-03-17 08:18:23 +00:00
|
|
|
private ArrayList<Vehicle> allVehicle = new ArrayList<>();
|
|
|
|
private ArrayList<String> allVehicleNames = new ArrayList<>();
|
|
|
|
private ArrayAdapter<String> adapter;
|
|
|
|
private boolean showVehicle = true;
|
2022-03-14 09:53:00 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
this.savedInstanceState = savedInstanceState;
|
|
|
|
setContentView(R.layout.tabhistory);
|
2022-03-16 14:40:34 +00:00
|
|
|
|
|
|
|
parentTab = (TabLayoutActivity) getParent();
|
|
|
|
parentTab.historyActivity = this;
|
|
|
|
|
2022-03-17 08:18:23 +00:00
|
|
|
Locale locale = new Locale(AppParams.LANGUAGETMP);
|
|
|
|
Locale.setDefault(locale);
|
|
|
|
|
2022-03-18 13:03:34 +00:00
|
|
|
// googleMap = parentTab.liveActivity.getMap();
|
2022-03-17 08:18:23 +00:00
|
|
|
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
|
|
|
.findFragmentById(R.id.map);
|
2022-03-18 13:03:34 +00:00
|
|
|
mapFragment.getMapAsync(this);
|
2022-03-17 08:18:23 +00:00
|
|
|
|
|
|
|
spinnerVehicle = findViewById(R.id.spinnerVehicle);
|
|
|
|
getVehicles();
|
|
|
|
|
|
|
|
adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, allVehicleNames);
|
|
|
|
adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
|
|
|
|
spinnerVehicle.setAdapter(adapter);
|
|
|
|
spinnerVehicle.setSelection(0);
|
|
|
|
|
|
|
|
changeMapType();
|
|
|
|
changeTraffic();
|
|
|
|
|
|
|
|
slidelayout = findViewById(R.id.slidelayout);
|
|
|
|
slideLayoutImage = findViewById(R.id.slideLayoutImage);
|
|
|
|
layoutVehicles = findViewById(R.id.layoutBig);
|
|
|
|
// slidelayout.setOnTouchListener((v, event) -> {
|
|
|
|
// if (showVehicle) {
|
|
|
|
// layoutVehicles.setVisibility(View.GONE);
|
|
|
|
// slideLayoutImage.setImageResource(R.drawable.arrow_right);
|
|
|
|
// showVehicle = false;
|
|
|
|
// } else {
|
|
|
|
// layoutVehicles.setVisibility(View.VISIBLE);
|
|
|
|
// slideLayoutImage.setImageResource(R.drawable.arrow_left);
|
|
|
|
// showVehicle = true;
|
|
|
|
// }
|
|
|
|
// return false;
|
|
|
|
// });
|
|
|
|
|
2022-03-18 13:03:34 +00:00
|
|
|
parentTab.demoPositionsList();
|
2022-03-17 08:18:23 +00:00
|
|
|
setDate();
|
2022-03-18 13:03:34 +00:00
|
|
|
|
|
|
|
// parentTab.HistPosList
|
2022-03-17 08:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void setDate() {
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
Date endDate = calendar.getTime();
|
|
|
|
calendar.add(Calendar.DATE, -1);
|
|
|
|
Date startDate = calendar.getTime();
|
|
|
|
|
|
|
|
LinearLayout layoutStartPicker = findViewById(R.id.layoutStartPicker);
|
|
|
|
TextView textViewDate = findViewById(R.id.textViewStartDate);
|
|
|
|
|
|
|
|
textViewDate.setText(new SimpleDateFormat("HH:mm, dd.MM.yyyy").format(startDate));
|
|
|
|
// layoutStartPicker.setOnTouchListener((v, event) -> {
|
|
|
|
// showDialog(layoutStartPicker);
|
|
|
|
// return false;
|
|
|
|
// });
|
|
|
|
|
|
|
|
// layoutEndPicker.setOnTouchListener(new OnTouchListener() {
|
|
|
|
// @Override
|
|
|
|
// public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
// showDialog(layoutEndPicker);
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void changeTraffic() {
|
|
|
|
ImageView changeTrafficImageView = findViewById(R.id.changeTraffic);
|
|
|
|
changeTrafficImageView.setOnClickListener(v -> {
|
|
|
|
if (googleMap.isTrafficEnabled()) {
|
|
|
|
changeTrafficImageView.setImageResource(R.drawable.traffic_off);
|
|
|
|
googleMap.setTrafficEnabled(false);
|
|
|
|
} else {
|
|
|
|
changeTrafficImageView.setImageResource(R.drawable.traffic);
|
|
|
|
googleMap.setTrafficEnabled(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void changeMapType() {
|
|
|
|
changeMapType = findViewById(R.id.changeMapType);
|
|
|
|
ImageView changeMapTypeImageView = findViewById(R.id.changeMapType);
|
|
|
|
changeMapType.setOnClickListener(view -> {
|
|
|
|
if (googleMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE) {
|
|
|
|
changeMapTypeImageView.setImageResource(R.drawable.satellite);
|
|
|
|
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
|
|
|
|
} else {
|
|
|
|
changeMapTypeImageView.setImageResource(R.drawable.map);
|
|
|
|
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void getVehicles() {
|
|
|
|
try {
|
|
|
|
for (Vehicle vehicle : parentTab.getAllVehicle()) {
|
|
|
|
allVehicleNames.add(vehicle.name);
|
|
|
|
allVehicle.add(vehicle);
|
|
|
|
}
|
|
|
|
} catch (Exception ex) { }
|
|
|
|
|
2022-03-14 09:53:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateMap() {
|
|
|
|
SM.Debug("Do the updateMAP post");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateUnableDisp() {
|
|
|
|
SM.Debug("Do Cancelwindow");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateCancel() {
|
|
|
|
SM.Debug("Do Cancelwindow");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateNrPos(int size) {
|
|
|
|
SM.Debug("Do Cancelwindow");
|
|
|
|
}
|
2022-03-18 13:03:34 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onMapReady(@NonNull GoogleMap googleMap) {
|
|
|
|
this.googleMap = googleMap;
|
|
|
|
|
|
|
|
// Add a marker in Sydney and move the camera
|
|
|
|
LatLng sydney = new LatLng(-34, 151);
|
|
|
|
this.googleMap.addMarker(new MarkerOptions()
|
|
|
|
.position(sydney)
|
|
|
|
.title("Marker in Sydney"));
|
|
|
|
this.googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
|
|
|
|
}
|
2022-03-14 09:53:00 +00:00
|
|
|
}
|