Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cordova-background-geolocation
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Aksimaya
cordova-background-geolocation
Commits
8913484d
Commit
8913484d
authored
Apr 04, 2015
by
Chris Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove wakelock
parent
f944038c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
134 additions
and
1 deletion
+134
-1
BackgroundGeolocationService.java
src/android/BackgroundGeolocationService.java
+1
-1
LocationDAO.java
src/android/data/LocationDAO.java
+10
-0
LocationOpenHelper.java
src/android/data/sqlite/LocationOpenHelper.java
+30
-0
SQLiteLocationDAO.java
src/android/data/sqlite/SQLiteLocationDAO.java
+93
-0
No files found.
src/android/BackgroundGeolocationService.java
View file @
8913484d
...
@@ -491,7 +491,7 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
...
@@ -491,7 +491,7 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
removeActivityUpdates
();
removeActivityUpdates
();
removeLocationUpdates
();
removeLocationUpdates
();
stopSelf
();
stopSelf
();
wakeLock
.
release
();
//
wakeLock.release();
}
}
/**
/**
...
...
src/android/data/LocationDAO.java
0 → 100644
View file @
8913484d
package
com
.
transistorsoft
.
cordova
.
bggeo
.
data
;
import
org.json.JSONObject
;
import
org.json.JSONException
;
public
interface
LocationDAO
{
public
JSONObject
[]
getAllLocations
();
public
boolean
persistLocation
(
JSONObject
l
);
public
void
deleteLocation
(
JSONObject
l
);
}
\ No newline at end of file
src/android/data/sqlite/LocationOpenHelper.java
0 → 100644
View file @
8913484d
package
com
.
transistorsoft
.
cordova
.
bggeo
.
data
.
sqlite
;
import
android.content.Context
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteOpenHelper
;
import
android.util.Log
;
public
class
LocationOpenHelper
extends
SQLiteOpenHelper
{
private
static
final
String
SQLITE_DATABASE_NAME
=
"cordova_background_geolocation"
;
private
static
final
int
DATABASE_VERSION
=
1
;
public
static
final
String
LOCATION_TABLE_NAME
=
"locations"
;
private
static
final
String
LOCATION_TABLE_COLUMNS
=
"timestamp INTEGER PRIMARY KEY, json TEXT"
;
private
static
final
String
LOCATION_TABLE_CREATE
=
"CREATE TABLE "
+
LOCATION_TABLE_NAME
+
" ("
+
LOCATION_TABLE_COLUMNS
+
");"
;
LocationOpenHelper
(
Context
context
)
{
super
(
context
,
SQLITE_DATABASE_NAME
,
null
,
DATABASE_VERSION
);
}
@Override
public
void
onCreate
(
SQLiteDatabase
db
)
{
db
.
execSQL
(
LOCATION_TABLE_CREATE
);
Log
.
d
(
this
.
getClass
().
getName
(),
LOCATION_TABLE_CREATE
);
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
// TODO Auto-generated method stub
}
}
src/android/data/sqlite/SQLiteLocationDAO.java
0 → 100644
View file @
8913484d
package
com
.
transistorsoft
.
cordova
.
bggeo
.
data
.
sqlite
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.TimeZone
;
import
java.util.List
;
import
org.json.JSONObject
;
import
org.json.JSONException
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.util.Log
;
import
com.transistorsoft.cordova.bggeo.data.LocationDAO
;
public
class
SQLiteLocationDAO
implements
LocationDAO
{
private
static
final
String
TAG
=
"SQLiteLocationDAO"
;
private
Context
context
;
public
SQLiteLocationDAO
(
Context
context
)
{
this
.
context
=
context
;
}
/*
public JSONObject[] getAllLocations() {
SQLiteDatabase db = null;
Cursor c = null;
List<JSONObject> all = new ArrayList<JSONObject>();
try {
db = new LocationOpenHelper(context).getReadableDatabase();
c = db.query(LocationOpenHelper.LOCATION_TABLE_NAME, null);
while (c.moveToNext()) {
all.add(hydrate(c));
}
} finally {
if (c != null) {
c.close();
}
if (db != null) {
db.close();
}
}
return all.toArray(new JSONObject[all.size()]);
}
public boolean persistLocation(JSONObject location) {
SQLiteDatabase db = new LocationOpenHelper(context).getWritableDatabase();
db.beginTransaction();
ContentValues values = getContentValues(location);
long rowId = db.insert(LocationOpenHelper.LOCATION_TABLE_NAME, null, values);
Log.d(TAG, "After insert, rowId = " + rowId);
db.setTransactionSuccessful();
db.endTransaction();
db.close();
if (rowId > -1) {
return true;
} else {
return false;
}
}
public void deleteLocation(JSONObject location) {
SQLiteDatabase db = new LocationOpenHelper(context).getWritableDatabase();
db.beginTransaction();
db.delete(LocationOpenHelper.LOCATION_TABLE_NAME, "timestamp = ?", location.getString("timestamp"));
db.setTransactionSuccessful();
db.endTransaction();
db.close();
}
private JSONObject hydrate(Cursor c) {
JSONObject l = new JSONObject(c);
return l;
}
private ContentValues getContentValues(JSONObject location) {
ContentValues values = new ContentValues();
values.put("latitude", location.get("latitude"));
values.put("longitude", location.get("longitude"));
values.put("timestamp", location.get("timestamp"));
values.put("accuracy", location.get("accuracy"));
values.put("altitude", location.get("altitude"));
values.put("bearing", location.get("bearing"));
values.put("speed", location.get("speed"));
return values;
}
*/
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment