Compare commits
4 Commits
0fabbc73be
...
89f8cbfcae
Author | SHA1 | Date | |
---|---|---|---|
89f8cbfcae | |||
4420af337d | |||
6b6543ca3f | |||
f554356af1 |
@ -198,12 +198,11 @@ public abstract class AbstractSDParentActivity extends TabActivity {
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean getHistoryPositions(int sc_id, long timeGMTStart, long timeGMTStop)
|
||||
{
|
||||
public boolean getHistoryPositions(int sc_id, long timeGMTStart, long timeGMTStop) {
|
||||
if(tcp == null)
|
||||
return false;
|
||||
|
||||
String histSeqID = "1."+Integer.toString((int) (System.currentTimeMillis() / 1000L));
|
||||
String histSeqID = "1."+ (int) (System.currentTimeMillis() / 1000L);
|
||||
boolean res = tcp.Write(histSeqID,"#26#"+sc_id+"#"+timeGMTStart+"#"+timeGMTStop+"#");
|
||||
if(res)
|
||||
SM.Debug("Message [getHistoryPositions] sent to app server");
|
||||
@ -213,8 +212,7 @@ public abstract class AbstractSDParentActivity extends TabActivity {
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean getRadiosList()
|
||||
{
|
||||
public boolean getRadiosList() {
|
||||
if(tcp == null)
|
||||
return false;
|
||||
|
||||
|
@ -1,17 +1,30 @@
|
||||
package com.safemobile.dispatch;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
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.MarkerOptions;
|
||||
import com.google.android.gms.maps.model.Polyline;
|
||||
import com.google.android.gms.maps.model.PolylineOptions;
|
||||
import com.safemobile.lib.AppParams;
|
||||
import com.safemobile.lib.HistPos;
|
||||
import com.safemobile.lib.OperationCodes;
|
||||
import com.safemobile.lib.SM;
|
||||
import com.safemobile.lib.Vehicle;
|
||||
|
||||
@ -21,7 +34,7 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class HistoryActivity extends AppCompatActivity {
|
||||
public class HistoryActivity extends AppCompatActivity implements OnMapReadyCallback {
|
||||
|
||||
public Bundle savedInstanceState;
|
||||
private TabLayoutActivity parentTab;
|
||||
@ -29,6 +42,9 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
private Spinner spinnerVehicle;
|
||||
private ImageView changeMapType, checkTraffic, slideLayoutImage;
|
||||
private LinearLayout layoutTraffic, slidelayout, layoutVehicles;
|
||||
private Button displayButton;
|
||||
private Date startDate, endDate;
|
||||
private final Handler myHandler = new Handler();
|
||||
|
||||
private ArrayList<Vehicle> allVehicle = new ArrayList<>();
|
||||
private ArrayList<String> allVehicleNames = new ArrayList<>();
|
||||
@ -47,9 +63,9 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
Locale locale = new Locale(AppParams.LANGUAGETMP);
|
||||
Locale.setDefault(locale);
|
||||
|
||||
googleMap = parentTab.liveActivity.getMap();
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(this);
|
||||
|
||||
spinnerVehicle = findViewById(R.id.spinnerVehicle);
|
||||
getVehicles();
|
||||
@ -65,6 +81,23 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
slidelayout = findViewById(R.id.slidelayout);
|
||||
slideLayoutImage = findViewById(R.id.slideLayoutImage);
|
||||
layoutVehicles = findViewById(R.id.layoutBig);
|
||||
displayButton = findViewById(R.id.buttonDisplay);
|
||||
displayButton.setOnClickListener(view -> {
|
||||
googleMap.clear();
|
||||
if (!AppParams.DEMO) {
|
||||
parentTab.dropAllData =false;
|
||||
parentTab.firstHistData = true;
|
||||
parentTab.HistMsgList.clear();
|
||||
parentTab.HistPosList.clear();
|
||||
|
||||
// request history
|
||||
parentTab.executeNetworkStuff(new String[] {OperationCodes.GetHistoryPositions + "", allVehicle.get(spinnerVehicle.getSelectedItemPosition()).sc_id + "",
|
||||
(startDate.getTime()/ 1000L) + "", (endDate.getTime()/ 1000L) + ""});
|
||||
} else {
|
||||
parentTab.demoPositionsList();
|
||||
displayHistory(parentTab.demoPositions);
|
||||
}
|
||||
});
|
||||
// slidelayout.setOnTouchListener((v, event) -> {
|
||||
// if (showVehicle) {
|
||||
// layoutVehicles.setVisibility(View.GONE);
|
||||
@ -81,11 +114,29 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
setDate();
|
||||
}
|
||||
|
||||
private void displayHistory(ArrayList<HistPos> positions) {
|
||||
LatLng latLng = null;
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
BitmapDescriptor markerIcon = BitmapDescriptorFactory.fromResource(R.drawable.bus);
|
||||
for (HistPos pos : positions) {
|
||||
latLng = new LatLng(pos.lat, pos.lng);
|
||||
polylineOptions.add(latLng);
|
||||
|
||||
googleMap.addMarker(new MarkerOptions()
|
||||
.position(latLng)
|
||||
.icon(markerIcon));
|
||||
}
|
||||
|
||||
Polyline polyline1 = googleMap.addPolyline(polylineOptions);
|
||||
if (latLng != null)
|
||||
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14));
|
||||
}
|
||||
|
||||
private void setDate() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date endDate = calendar.getTime();
|
||||
endDate = calendar.getTime();
|
||||
calendar.add(Calendar.DATE, -1);
|
||||
Date startDate = calendar.getTime();
|
||||
startDate = calendar.getTime();
|
||||
|
||||
LinearLayout layoutStartPicker = findViewById(R.id.layoutStartPicker);
|
||||
TextView textViewDate = findViewById(R.id.textViewStartDate);
|
||||
@ -144,7 +195,16 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
final Runnable UpdateMapResults = new Runnable() {
|
||||
public void run() {
|
||||
Log.v("updateMap", parentTab.HistPosList.toString());
|
||||
SM.Debug("Do the Display");
|
||||
displayHistory(parentTab.HistPosList);
|
||||
}
|
||||
};
|
||||
|
||||
public void UpdateMap() {
|
||||
myHandler.post(UpdateMapResults);
|
||||
SM.Debug("Do the updateMAP post");
|
||||
}
|
||||
|
||||
@ -159,4 +219,12 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
public void UpdateNrPos(int size) {
|
||||
SM.Debug("Do Cancelwindow");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(@NonNull GoogleMap googleMap) {
|
||||
this.googleMap = googleMap;
|
||||
|
||||
parentTab.demoPositionsList();
|
||||
displayButton.performClick();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -284,14 +284,15 @@
|
||||
</LinearLayout>
|
||||
|
||||
<fragment
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/map"
|
||||
android:layout_toRightOf="@id/slidelayout"
|
||||
android:layout_weight="1"
|
||||
tools:context=".HistoryActivity"
|
||||
android:name="com.google.android.gms.maps.SupportMapFragment" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/changeMapType"
|
||||
|
Loading…
x
Reference in New Issue
Block a user