start working on history
This commit is contained in:
parent
4f7def273f
commit
91a05ae4d1
@ -2,6 +2,7 @@ package com.safemobile.activities;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
import com.safemobile.lib.Vehicle;
|
import com.safemobile.lib.Vehicle;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@ -23,6 +24,7 @@ public abstract class AbstractLiveActivity extends AppCompatActivity {
|
|||||||
public abstract void pollReceived(int position, double lat, double lng); // --> UpdatePoll
|
public abstract void pollReceived(int position, double lat, double lng); // --> UpdatePoll
|
||||||
public abstract void vehicleStatusReceived(long imei, int opCode, int status); // --> UpdateOptions
|
public abstract void vehicleStatusReceived(long imei, int opCode, int status); // --> UpdateOptions
|
||||||
public abstract void emergencyAlarmReceived(int position, double lat, double lng); // --> UpdateEmergencyAlarm
|
public abstract void emergencyAlarmReceived(int position, double lat, double lng); // --> UpdateEmergencyAlarm
|
||||||
|
public abstract GoogleMap getMap(); // --> UpdateEmergencyAlarm
|
||||||
|
|
||||||
/** Misc */
|
/** Misc */
|
||||||
public AbstractSDParentActivity getParentTab() {
|
public AbstractSDParentActivity getParentTab() {
|
||||||
|
@ -3,14 +3,37 @@ package com.safemobile.dispatch;
|
|||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
|
import com.google.android.gms.maps.SupportMapFragment;
|
||||||
|
import com.safemobile.lib.AppParams;
|
||||||
import com.safemobile.lib.SM;
|
import com.safemobile.lib.SM;
|
||||||
|
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;
|
||||||
|
|
||||||
public class HistoryActivity extends AppCompatActivity {
|
public class HistoryActivity extends AppCompatActivity {
|
||||||
|
|
||||||
public Bundle savedInstanceState;
|
public Bundle savedInstanceState;
|
||||||
private TabLayoutActivity parentTab;
|
private TabLayoutActivity parentTab;
|
||||||
|
private GoogleMap googleMap;
|
||||||
|
private Spinner spinnerVehicle;
|
||||||
|
private ImageView changeMapType, checkTraffic, slideLayoutImage;
|
||||||
|
private LinearLayout layoutTraffic, slidelayout, layoutVehicles;
|
||||||
|
|
||||||
|
private ArrayList<Vehicle> allVehicle = new ArrayList<>();
|
||||||
|
private ArrayList<String> allVehicleNames = new ArrayList<>();
|
||||||
|
private ArrayAdapter<String> adapter;
|
||||||
|
private boolean showVehicle = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -21,6 +44,104 @@ public class HistoryActivity extends AppCompatActivity {
|
|||||||
parentTab = (TabLayoutActivity) getParent();
|
parentTab = (TabLayoutActivity) getParent();
|
||||||
parentTab.historyActivity = this;
|
parentTab.historyActivity = this;
|
||||||
|
|
||||||
|
Locale locale = new Locale(AppParams.LANGUAGETMP);
|
||||||
|
Locale.setDefault(locale);
|
||||||
|
|
||||||
|
googleMap = parentTab.liveActivity.getMap();
|
||||||
|
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||||
|
.findFragmentById(R.id.map);
|
||||||
|
|
||||||
|
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;
|
||||||
|
// });
|
||||||
|
|
||||||
|
setDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
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) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateMap() {
|
public void UpdateMap() {
|
||||||
|
@ -788,4 +788,9 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoogleMap getMap() {
|
||||||
|
return googleMap;
|
||||||
|
}
|
||||||
}
|
}
|
@ -283,14 +283,14 @@
|
|||||||
style="?sliders" />
|
style="?sliders" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<fragment
|
||||||
android:id="@+id/layoutGoogleMaps"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
|
android:id="@+id/map"
|
||||||
android:layout_toRightOf="@id/slidelayout"
|
android:layout_toRightOf="@id/slidelayout"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="horizontal" >
|
android:name="com.google.android.gms.maps.SupportMapFragment" />
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<ImageView
|
<ImageView
|
||||||
|
Loading…
Reference in New Issue
Block a user