clean history activity
This commit is contained in:
parent
db360c4d45
commit
c85dc279dc
@ -10,12 +10,9 @@ import android.graphics.drawable.ColorDrawable;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.DatePicker;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -23,11 +20,8 @@ import com.google.android.gms.maps.CameraUpdateFactory;
|
|||||||
import com.google.android.gms.maps.GoogleMap;
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||||
import com.google.android.gms.maps.SupportMapFragment;
|
import com.google.android.gms.maps.SupportMapFragment;
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptor;
|
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
import com.google.android.gms.maps.model.MarkerOptions;
|
import com.google.android.gms.maps.model.MarkerOptions;
|
||||||
import com.google.android.gms.maps.model.Polyline;
|
|
||||||
import com.google.android.gms.maps.model.PolylineOptions;
|
import com.google.android.gms.maps.model.PolylineOptions;
|
||||||
import com.safemobile.lib.AppParams;
|
import com.safemobile.lib.AppParams;
|
||||||
import com.safemobile.lib.HistPos;
|
import com.safemobile.lib.HistPos;
|
||||||
@ -47,18 +41,14 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
private TabLayoutActivity parentTab;
|
private TabLayoutActivity parentTab;
|
||||||
private GoogleMap googleMap;
|
private GoogleMap googleMap;
|
||||||
private Spinner spinnerVehicle;
|
private Spinner spinnerVehicle;
|
||||||
private ImageView changeMapType, checkTraffic, slideLayoutImage;
|
|
||||||
private LinearLayout layoutTraffic, slidelayout, layoutVehicles;
|
|
||||||
private Button displayButton;
|
private Button displayButton;
|
||||||
private Date startDate, endDate;
|
private Date startDate, endDate;
|
||||||
private final Handler myHandler = new Handler();
|
private final Handler myHandler = new Handler();
|
||||||
private GoogleMapsInfoBubble infoBubble;
|
private GoogleMapsInfoBubble infoBubble;
|
||||||
|
|
||||||
private ArrayList<Vehicle> allVehicle = new ArrayList<>();
|
private final ArrayList<Vehicle> allVehicle = new ArrayList<>();
|
||||||
private ArrayList<String> allVehicleNames = new ArrayList<>();
|
private final ArrayList<String> allVehicleNames = new ArrayList<>();
|
||||||
private ArrayAdapter<String> adapter;
|
private final SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd yyyy");
|
||||||
private boolean showVehicle = true;
|
|
||||||
private SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd yyyy");
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -75,12 +65,13 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
|
|
||||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||||
.findFragmentById(R.id.map);
|
.findFragmentById(R.id.map);
|
||||||
mapFragment.getMapAsync(this);
|
if (mapFragment != null)
|
||||||
|
mapFragment.getMapAsync(this);
|
||||||
|
|
||||||
spinnerVehicle = findViewById(R.id.spinnerVehicle);
|
spinnerVehicle = findViewById(R.id.spinnerVehicle);
|
||||||
getVehicles();
|
getVehicles();
|
||||||
|
|
||||||
adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, allVehicleNames);
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, allVehicleNames);
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
|
adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
|
||||||
spinnerVehicle.setAdapter(adapter);
|
spinnerVehicle.setAdapter(adapter);
|
||||||
spinnerVehicle.setSelection(0);
|
spinnerVehicle.setSelection(0);
|
||||||
@ -88,9 +79,6 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
changeMapType();
|
changeMapType();
|
||||||
changeTraffic();
|
changeTraffic();
|
||||||
|
|
||||||
slidelayout = findViewById(R.id.slidelayout);
|
|
||||||
slideLayoutImage = findViewById(R.id.slideLayoutImage);
|
|
||||||
layoutVehicles = findViewById(R.id.layoutBig);
|
|
||||||
displayButton = findViewById(R.id.buttonDisplay);
|
displayButton = findViewById(R.id.buttonDisplay);
|
||||||
displayButton.setOnClickListener(view -> {
|
displayButton.setOnClickListener(view -> {
|
||||||
googleMap.clear();
|
googleMap.clear();
|
||||||
@ -127,7 +115,7 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Polyline polyline1 = googleMap.addPolyline(polylineOptions);
|
googleMap.addPolyline(polylineOptions);
|
||||||
if (latLng != null)
|
if (latLng != null)
|
||||||
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14));
|
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14));
|
||||||
}
|
}
|
||||||
@ -138,7 +126,6 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
calendar.add(Calendar.DATE, -1);
|
calendar.add(Calendar.DATE, -1);
|
||||||
startDate = calendar.getTime();
|
startDate = calendar.getTime();
|
||||||
|
|
||||||
LinearLayout layoutStartPicker = findViewById(R.id.layoutStartPicker);
|
|
||||||
TextView textViewStartDate = findViewById(R.id.textViewStartDate);
|
TextView textViewStartDate = findViewById(R.id.textViewStartDate);
|
||||||
TextView textViewEndDate = findViewById(R.id.textViewEndDate);
|
TextView textViewEndDate = findViewById(R.id.textViewEndDate);
|
||||||
|
|
||||||
@ -187,14 +174,13 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void changeMapType() {
|
private void changeMapType() {
|
||||||
changeMapType = findViewById(R.id.changeMapType);
|
ImageView changeMapType = findViewById(R.id.changeMapType);
|
||||||
ImageView changeMapTypeImageView = findViewById(R.id.changeMapType);
|
|
||||||
changeMapType.setOnClickListener(view -> {
|
changeMapType.setOnClickListener(view -> {
|
||||||
if (googleMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE) {
|
if (googleMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE) {
|
||||||
changeMapTypeImageView.setImageResource(R.drawable.satellite);
|
changeMapType.setImageResource(R.drawable.satellite);
|
||||||
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
|
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
|
||||||
} else {
|
} else {
|
||||||
changeMapTypeImageView.setImageResource(R.drawable.map);
|
changeMapType.setImageResource(R.drawable.map);
|
||||||
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
|
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -202,11 +188,13 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
|
|
||||||
public void getVehicles() {
|
public void getVehicles() {
|
||||||
try {
|
try {
|
||||||
|
allVehicle.clear();
|
||||||
|
allVehicleNames.clear();
|
||||||
for (Vehicle vehicle : parentTab.getAllVehicle()) {
|
for (Vehicle vehicle : parentTab.getAllVehicle()) {
|
||||||
allVehicleNames.add(vehicle.name);
|
allVehicleNames.add(vehicle.name);
|
||||||
allVehicle.add(vehicle);
|
allVehicle.add(vehicle);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) { }
|
} catch (Exception ignored) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user