feature/apk_versioning_mechanism #7
@ -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,5 +1,6 @@
|
||||
package com.safemobile.dispatch;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
@ -9,8 +10,12 @@ 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.LatLng;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
import com.safemobile.lib.AppParams;
|
||||
import com.safemobile.lib.SM;
|
||||
import com.safemobile.lib.Vehicle;
|
||||
@ -21,7 +26,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;
|
||||
@ -47,9 +52,10 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
Locale locale = new Locale(AppParams.LANGUAGETMP);
|
||||
Locale.setDefault(locale);
|
||||
|
||||
googleMap = parentTab.liveActivity.getMap();
|
||||
// googleMap = parentTab.liveActivity.getMap();
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(this);
|
||||
|
||||
spinnerVehicle = findViewById(R.id.spinnerVehicle);
|
||||
getVehicles();
|
||||
@ -78,7 +84,10 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
// return false;
|
||||
// });
|
||||
|
||||
parentTab.demoPositionsList();
|
||||
setDate();
|
||||
|
||||
// parentTab.HistPosList
|
||||
}
|
||||
|
||||
private void setDate() {
|
||||
@ -159,4 +168,16 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
public void UpdateNrPos(int size) {
|
||||
SM.Debug("Do Cancelwindow");
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
@ -109,14 +109,14 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
|
||||
/* Lists */
|
||||
public ArrayList<RadioGW> allRadios;
|
||||
public volatile ArrayList<HistPos> HistPosList = new ArrayList<HistPos>();
|
||||
public volatile ArrayList<HistPos> HistPosList = new ArrayList<>();
|
||||
public volatile Boolean firstHistData = false;
|
||||
public volatile Boolean dropAllData = false;
|
||||
public volatile ArrayList<Boolean> HistMsgList = new ArrayList<Boolean>();
|
||||
public volatile ArrayList<Boolean> HistMsgList = new ArrayList<>();
|
||||
|
||||
/* DEMO lists */
|
||||
public ArrayList<SMS> listSMS;
|
||||
public ArrayList<HistPos> demoPositions = new ArrayList<HistPos>();
|
||||
public ArrayList<HistPos> demoPositions = new ArrayList<>();
|
||||
|
||||
/* Tab */
|
||||
private TabWidget tabWidget;
|
||||
@ -737,33 +737,26 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
|
||||
|
||||
// hide buttons if safenet
|
||||
if(AppParams.theme == AppParams.Theme.SAFENET)
|
||||
{
|
||||
if (AppParams.theme == AppParams.Theme.SAFENET) {
|
||||
buttonRadio.setVisibility(View.GONE);
|
||||
buttonRecordings.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
if(AppParams.DEMO && liveActivity != null)
|
||||
{
|
||||
if (AppParams.DEMO && liveActivity != null) {
|
||||
liveActivity.vehiclesReceived(getAllVehicle());
|
||||
demoPositionsList();
|
||||
}
|
||||
|
||||
if(!AppParams.DEMO)
|
||||
{
|
||||
//TCPinit();
|
||||
//*
|
||||
if (!AppParams.DEMO) {
|
||||
Timer t = new Timer();
|
||||
t.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// init tcp
|
||||
TCPinit();
|
||||
}
|
||||
}, 100);
|
||||
//*/
|
||||
}
|
||||
|
||||
// Notification Click Filter
|
||||
@ -871,17 +864,16 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
|
||||
|
||||
private void demoPositionsList() {
|
||||
public void demoPositionsList() {
|
||||
AssetManager assetManager = res.getAssets();
|
||||
SM.Debug("TRY 2 OPEN demo_positions.txt");
|
||||
InputStream input = null;
|
||||
InputStream input;
|
||||
try {
|
||||
input = assetManager.open("demo_positions.txt");
|
||||
InputStreamReader inputreader = new InputStreamReader(input);
|
||||
BufferedReader buffreader = new BufferedReader(inputreader);
|
||||
String line = "";
|
||||
while ((line = buffreader.readLine()) != null)
|
||||
{
|
||||
String line;
|
||||
while ((line = buffreader.readLine()) != null) {
|
||||
String[] posi = line.split("#");
|
||||
HistPos gps = new HistPos();
|
||||
gps.lat = Double.parseDouble(posi[1]);
|
||||
@ -892,7 +884,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
HistPosmsg msg = new HistPosmsg(new TCPmsg(new char[]{}));
|
||||
demoPositions = msg.CalcHeadingForArray(demoPositions);
|
||||
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
@ -1057,7 +1048,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
|
||||
SM.Debug("########### UPDATE");
|
||||
int sc_id = demoPosition%3 == 0 ? 101:102;
|
||||
((SuperVehicle) getSuperVehHash().get((long)sc_id)).SetNewPosition(crtPos.lat, crtPos.lng, Calendar.getInstance().getTime().getTime(), crtPos.speed);
|
||||
getSuperVehHash().get((long)sc_id).SetNewPosition(crtPos.lat, crtPos.lng, Calendar.getInstance().getTime().getTime(), crtPos.speed);
|
||||
liveActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
@ -1071,7 +1062,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
|
||||
SM.Debug("########### UPDATE");
|
||||
int sc_id = Integer.parseInt(getImei());
|
||||
((SuperVehicle) getSuperVehHash().get((long)sc_id)).SetNewPosition(crtPos.lat + 0.0002, crtPos.lng + 0.0002, Calendar.getInstance().getTime().getTime(), crtPos.speed+2);
|
||||
getSuperVehHash().get((long)sc_id).SetNewPosition(crtPos.lat + 0.0002, crtPos.lng + 0.0002, Calendar.getInstance().getTime().getTime(), crtPos.speed+2);
|
||||
setMess("Lat:" + String.format("%5f", crtPos.lat + 0.0002) + ", Lng:" + String.format("%5f", crtPos.lng + 0.0002));
|
||||
liveActivity.refreshMap();
|
||||
}
|
||||
@ -1505,7 +1496,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
SM.Debug("Got last pos");
|
||||
|
||||
LastPosmsg lastPos= new LastPosmsg(msg);
|
||||
//SM.Debug("Got LastPost msg.data:" + msg.data);
|
||||
for(LastPos posMsg: lastPos.PosList) {
|
||||
if(getSuperVehHash().get(posMsg.imei) != null)
|
||||
getSuperVehHash().get(posMsg.imei).SetDataFromLastPos(posMsg.lat, posMsg.lng, posMsg.timeGMT, posMsg.speed, posMsg.Address, posMsg.isON);
|
||||
@ -1516,30 +1506,20 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
public void onHistoryPositionsCountReceived(TCPEvent event) {
|
||||
TCPmsg msg= event.msg();
|
||||
SM.Debug("Got POS Count");
|
||||
//SM.Debug("Got lastpos :" + msg.allData);
|
||||
|
||||
HistCountmsg histcount= new HistCountmsg(msg);
|
||||
SM.Debug("Message Count:"+histcount.histcountValue.count);
|
||||
//SM.Debug("Got LastPost msg.data:" + msg.data);
|
||||
if (histcount.histcountValue.count>=2000)
|
||||
{
|
||||
if (histcount.histcountValue.count>=2000) {
|
||||
//list for live
|
||||
if(AppParams.crtTab == AppParams.Tabs.history)
|
||||
{
|
||||
//SM.Debug("+++++ duda +++++");
|
||||
if(AppParams.crtTab == AppParams.Tabs.history) {
|
||||
SM.Debug("currentActivity instanceof HistoryActivity");
|
||||
try
|
||||
{
|
||||
if(historyActivity != null)
|
||||
{
|
||||
try {
|
||||
if(historyActivity != null) {
|
||||
historyActivity.UpdateCancel();
|
||||
historyActivity.UpdateUnableDisp();
|
||||
}
|
||||
//dialogLoading.cancel();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SM.Debug("Error load hash:"+ex.toString());
|
||||
} catch (Exception ex) {
|
||||
SM.Debug("Error load hash:"+ ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1553,7 +1533,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
HistPosmsg tmpHist= new HistPosmsg(msg);
|
||||
Boolean SendDataToMap =true;
|
||||
try{
|
||||
|
||||
for (HistPos obj : tmpHist.PosList)
|
||||
HistPosList.add(obj);
|
||||
|
||||
@ -1561,25 +1540,18 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
//
|
||||
int pos = Integer.parseInt(tmpHist.seqID.substring(0,tmpHist.seqID.indexOf('.')));
|
||||
int all = Integer.parseInt(tmpHist.seqID.substring(tmpHist.seqID.indexOf('.')+1,tmpHist.seqID.length()));
|
||||
if (all!=0)
|
||||
{
|
||||
if (firstHistData)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (all!=0) {
|
||||
if (firstHistData) {
|
||||
try {
|
||||
for(int i=0;i<all;i++)
|
||||
HistMsgList.add(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Error on init hashTable:"+e.toString());
|
||||
}
|
||||
firstHistData =false;
|
||||
}
|
||||
|
||||
HistMsgList.set(pos-1, true);
|
||||
//for(int i=0;i<(all);i++)
|
||||
// SM.Debug("i:"+i+" value:"+HistMsgList.get(i));
|
||||
for(int i=0;i<(all);i++)
|
||||
{
|
||||
if (!HistMsgList.get(i))
|
||||
@ -1593,20 +1565,16 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
SM.Debug("Error on parse:"+e.toString());
|
||||
SM.Debug("Error on parse: "+ e);
|
||||
}
|
||||
if (SendDataToMap)
|
||||
{
|
||||
Collections.sort(HistPosList, new Comparator<Object>()
|
||||
{
|
||||
public int compare(Object o1, Object o2) {
|
||||
HistPos p1 = (HistPos) o1;
|
||||
HistPos p2 = (HistPos) o2;
|
||||
if (p1.timeGMT<p2.timeGMT) return -1;
|
||||
else if (p1.timeGMT==p2.timeGMT) return 0;
|
||||
else return 1;
|
||||
}
|
||||
});
|
||||
if (SendDataToMap) {
|
||||
Collections.sort(HistPosList, (Comparator<Object>) (o1, o2) -> {
|
||||
HistPos p1 = (HistPos) o1;
|
||||
HistPos p2 = (HistPos) o2;
|
||||
if (p1.timeGMT<p2.timeGMT) return -1;
|
||||
else if (p1.timeGMT==p2.timeGMT) return 0;
|
||||
else return 1;
|
||||
});
|
||||
|
||||
//list for live
|
||||
if(AppParams.crtTab == AppParams.Tabs.history)
|
||||
@ -1623,7 +1591,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
Thread.sleep(101);
|
||||
if (HistPosList.size()<2000)
|
||||
{
|
||||
if ((HistPosList.size()==1) && (((HistPos)(HistPosList.get(0))).timeGMT==0))
|
||||
if ((HistPosList.size()==1) && (HistPosList.get(0).timeGMT==0))
|
||||
;// do nothing is not data message
|
||||
else
|
||||
historyActivity.UpdateNrPos(HistPosList.size());
|
||||
@ -1634,7 +1602,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
else
|
||||
historyActivity.UpdateUnableDisp(); // update with more than 200 points
|
||||
}
|
||||
//((HistoryActivity)currentActivity).UpdateMap(HistPosList.size());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -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…
Reference in New Issue
Block a user