Obsolete
Status Update
Comments
hb...@gmail.com <hb...@gmail.com> #2
As a corollary, for properties where unique=True one
should be able to fetch an entity by doing
Model.get_by_uniquepropertyname and also
Model.get_or_insert_by_uniquepropertyname... like Rails does with
ActiveRecord (e.g., Book.find_or_create_by_isbn).
should be able to fetch an entity by doing
Model.get_by_uniquepropertyname and also
Model.get_or_insert_by_uniquepropertyname... like Rails does with
ActiveRecord (e.g., Book.find_or_create_by_isbn).
dn...@google.com <dn...@google.com> #3
I'd rather see this added as an index feature, so the uniqueness could be spread
across multiple fields (and an index would almost certainly be needed to support this
efficiently, anyway).
across multiple fields (and an index would almost certainly be needed to support this
efficiently, anyway).
en...@google.com <en...@google.com>
[Deleted User] <[Deleted User]> #4
I totally agree that this should be implemented as an index. It could (and I think
should) still be specified in the schema/property constructor and the index
automatically generated.
should) still be specified in the schema/property constructor and the index
automatically generated.
ka...@gmail.com <ka...@gmail.com> #5
It would also be great to have a way, in the schema declarations, to specify
composite unique indexes/properties, especially for reference properties.
composite unique indexes/properties, especially for reference properties.
zh...@gmail.com <zh...@gmail.com> #6
Yes, this would be super useful.
zh...@gmail.com <zh...@gmail.com> #7
Yes, this is a very common usecase +1
Description
I got a problem on failed to get location occasionally. Although it is failed to get location on my own Android app, google map could still locate the current position. Problem still exists after kill and relaunch my app, but it could be solved after reboot the Phone.
Could anyone help? Thanks a lot!
Following is part of source code for your reference:
private LocationManager lm;
private boolean gps_enabled=false;
private boolean network_enabled=false;
private boolean got_location=false;
private static long location_time_threshold = 300000; //300000milliseconds = 5mins
private boolean getLocation() {
if(lm==null)
lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
try{network_enabled=lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);}catch(Exception ex){}
try{gps_enabled=lm.isProviderEnabled(LocationManager.GPS_PROVIDER);}catch(Exception ex){}
if(!gps_enabled && !network_enabled) {
System.out.println("failed to get from GPS and Network ");
//show err message box
return false;
}
if (!getLastLocation()) {
if(network_enabled)
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListenerNetwork);
if(gps_enabled)
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListenerGps);
System.out.println("getLocation Lat " + userLat + " Long " + userLong);
handler.postDelayed(delayForCheck, 10000);
}
return true;
}
private Runnable delayForCheck = new Runnable() {
public void run() {
if (!got_location){
if (!getLastLocation()) {
System.out.println("delayForCheck failed to get from GPS and Network ");
if (!network_enabled) {
//show err message box
} else {
//show err message box
}
}
}
}
};
LocationListener locationListenerGps = new LocationListener() {
public void onLocationChanged(Location location) {
lm.removeUpdates(this);
lm.removeUpdates(locationListenerNetwork);
got_location = true;
userLat = location.getLatitude();
userLong = location.getLongitude();
System.out.println("locationListenerGps: Lat " + userLat + " Long " + userLong);
}
public void onProviderDisabled(String provider) {}
public void onProviderEnabled(String provider) {}
public void onStatusChanged(String provider, int status, Bundle extras) {}
};
LocationListener locationListenerNetwork = new LocationListener() {
public void onLocationChanged(Location location) {
lm.removeUpdates(this);
lm.removeUpdates(locationListenerGps);
got_location = true;
userLat = location.getLatitude();
userLong = location.getLongitude();
System.out.println("locationListenerNetwork: Lat " + userLat + " Long " + userLong);
}
public void onProviderDisabled(String provider) {}
public void onProviderEnabled(String provider) {}
public void onStatusChanged(String provider, int status, Bundle extras) {}
};
private boolean getLastLocation() {
lm.removeUpdates(locationListenerGps);
lm.removeUpdates(locationListenerNetwork);
Location net_loc=null, gps_loc=null;
if(gps_enabled)
gps_loc=lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if(network_enabled)
net_loc=lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if(gps_loc!=null && net_loc!=null){
if ((new Date().getTime() - net_loc.getTime()) < location_time_threshold
|| (new Date().getTime() - gps_loc.getTime()) < location_time_threshold ) {
if(gps_loc.getTime()>net_loc.getTime()) {
userLat = gps_loc.getLatitude();
userLong = gps_loc.getLongitude();
} else {
userLat = net_loc.getLatitude();
userLong = net_loc.getLongitude();
}
got_location = true;
System.out.println("getLastKnownLocationLAST: Lat " + userLat + " Long " + userLong);
return true;
}
} else if(net_loc!=null){
if ((new Date().getTime() - net_loc.getTime()) < location_time_threshold) {
userLat = net_loc.getLatitude();
userLong = net_loc.getLongitude();
got_location = true;
System.out.println("getLastKnownLocationNetwork: Lat " + userLat + " Long " + userLong);
return true;
}
} else if(gps_loc!=null){
if ((new Date().getTime() - gps_loc.getTime()) < location_time_threshold) {
userLat = gps_loc.getLatitude();
userLong = gps_loc.getLongitude();
got_location = true;
System.out.println("getLastKnownLocationGPS: Lat " + userLat + " Long " + userLong);
return true;
}
}
return false;
}