help me!!!

ShoniPRO
Сообщения: 13
Зарегистрирован: 21 авг 2012, 11:01

Re: help me!!!

Сообщение ShoniPRO » 22 авг 2012, 15:37

Но проблема все же осталась :(

ShoniPRO
Сообщения: 13
Зарегистрирован: 21 авг 2012, 11:01

Re: help me!!!

Сообщение ShoniPRO » 23 авг 2012, 13:17

кое-что поменял ... есть какие-то еще идеи ?? :idea: :idea: :?: :?:

class ForGPS {

private int dist = 0;
private int deg = 0;
private static volatile long time = 300000;
private long currentTime = 0;
private long timeSent = 0;
private long difTime = 0;
private double prevLat = 0.0;
private double prevLng = 0.0;
private boolean place = false;

private static volatile ForGPS instance;

public static ForGPS getInstance() {
ForGPS localInstance = instance;
if (localInstance == null) {
synchronized (ForGPS.class) {
localInstance = instance;
if (localInstance == null) {
instance = localInstance = new ForGPS();
}
}
}
return localInstance;
}

private boolean getParams(int distantion, int degrees) {

this.dist += distantion;
this.deg = degrees;

return isMinParams(this.dist, this.deg);
}

private void zeroParams() {
this.dist = 0;
this.deg = 0;
}

private boolean isMinParams(int distantion, int degrees) {
if (distantion > 50 || degrees > 5)
return true;
else
return false;
}

private void isParams (int speed, int distantion, int degrees) {
currentTime = SystemClock.elapsedRealtime();

if ((speed > 3) && (getParams(distantion, degrees))) {

//ставиться нова точка

zeroParams();
timeSent = currentTime;
setTimerTask();
}

else {
this.place = false;
}

}

private void setTimerTask() {

Timer timer = new Timer();
TimerTask task = new TimerTask() {

@Override
public void run() {
// TODO Auto-generated method stub
place = true;
}

};
difTime = time - timeSent;
if (difTime == 0)
timer.scheduleAtFixedRate(task, 0, time);
else
timer.scheduleAtFixedRate(task, 0, difTime);

task.cancel();
//task = new TimerTask();
//timer = new Timer();

}


@SuppressWarnings("null")
public void getCurrentLocation(Location location) {
double lat = location.getLatitude();
double lng = location.getLongitude();
float[] disArray = null;
float dis = 0;
double deg = location.getBearing();
double spd = location.getSpeed();

if ((this.prevLat != 0.0) && (this.prevLng != 0))
Location.distanceBetween(this.prevLat, this.prevLng, lat, lng, disArray);
else
disArray[0] = 0;

dis = disArray[0];

isParams((int)spd, (int)dis, (int)deg);

this.prevLat = lat;
this.prevLng = lng;
}

public boolean getPlace() {
return this.place;
}
}

Закрыто