-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a helper for handling the "find me" functionality when theres a…
… page reset due to the out of memory workaround.
- Loading branch information
kzusy
committed
Feb 5, 2014
1 parent
e27a615
commit 61f382e
Showing
10 changed files
with
284 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
Arbiter-Android/assets/www/js/Arbiter/Geolocation/FindMe_OOM.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Arbiter.SavedFindMe = function(gotHighAccuracy, position){ | ||
this.gotHighAccuracy = gotHighAccuracy; | ||
this.position = position; | ||
}; | ||
|
||
Arbiter.FindMe_OOM = function(){ | ||
|
||
}; | ||
|
||
Arbiter.FindMe_OOM.prototype.FINDME = "findme"; | ||
|
||
Arbiter.FindMe_OOM.prototype.savePoint = function(gotHighAccuracy, position, onSuccess, onFailure){ | ||
var obj = new Arbiter.SavedFindMe(gotHighAccuracy, position); | ||
|
||
console.log("saving point: " + obj.gotHighAccuracy); | ||
|
||
Arbiter.PreferencesHelper.put(this.FINDME, | ||
JSON.stringify(obj), this, function(){ | ||
|
||
console.log("point saved successfully: " + obj.gotHighAccuracy); | ||
if(Arbiter.Util.funcExists(onSuccess)){ | ||
onSuccess(); | ||
} | ||
}, function(e){ | ||
|
||
console.log("could not save point: " + obj.gotHighAccuracy); | ||
if(Arbiter.Util.funcExists(onFailure)){ | ||
onFailure(e); | ||
} | ||
}); | ||
}; | ||
|
||
Arbiter.FindMe_OOM.prototype.getPoint = function(onSuccess, onFailure){ | ||
var context = this; | ||
|
||
var success = function(findme){ | ||
if(Arbiter.Util.funcExists(onSuccess)){ | ||
|
||
if(Arbiter.Util.existsAndNotNull(findme)){ | ||
onSuccess(JSON.parse(findme)); | ||
}else{ | ||
onSuccess(findme); | ||
} | ||
} | ||
}; | ||
|
||
Arbiter.PreferencesHelper.get(this.FINDME, this, function(findme){ | ||
|
||
context.clearSavedPoint(function(){ | ||
|
||
success(findme); | ||
}, function(e){ | ||
|
||
console.log("Could not remove findme from preferences table: " + JSON.stringify(e)); | ||
|
||
success(findme); | ||
}); | ||
|
||
}, function(e){ | ||
|
||
if(Arbiter.Util.funcExists(onFailure)){ | ||
onFailure(e); | ||
} | ||
}); | ||
}; | ||
|
||
Arbiter.FindMe_OOM.prototype.clearSavedPoint = function(onSuccess, onFailure){ | ||
|
||
Arbiter.PreferencesHelper.remove(this.FINDME, this, function(){ | ||
|
||
if(Arbiter.Util.funcExists(onSuccess)){ | ||
onSuccess(); | ||
} | ||
}, function(e){ | ||
|
||
if(Arbiter.Util.funcExists(onFailure)){ | ||
onFailure(e); | ||
} | ||
}); | ||
}; |
Oops, something went wrong.