Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
2edc14a6
Commit
2edc14a6
authored
Dec 30, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine database package
parent
bc94adef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
src/main/scala/com/github/shadowsocks/database/DBHelper.scala
...main/scala/com/github/shadowsocks/database/DBHelper.scala
+8
-5
src/main/scala/com/github/shadowsocks/database/Profile.scala
src/main/scala/com/github/shadowsocks/database/Profile.scala
+9
-9
No files found.
src/main/scala/com/github/shadowsocks/database/DBHelper.scala
View file @
2edc14a6
...
@@ -23,11 +23,11 @@ package com.github.shadowsocks.database
...
@@ -23,11 +23,11 @@ package com.github.shadowsocks.database
import
android.content.Context
import
android.content.Context
import
android.content.pm.ApplicationInfo
import
android.content.pm.ApplicationInfo
import
android.database.sqlite.SQLiteDatabase
import
android.database.sqlite.SQLiteDatabase
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
import
com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
import
com.j256.ormlite.dao.Dao
import
com.j256.ormlite.dao.Dao
import
com.j256.ormlite.support.ConnectionSource
import
com.j256.ormlite.support.ConnectionSource
import
com.j256.ormlite.table.TableUtils
import
com.j256.ormlite.table.TableUtils
import
com.github.shadowsocks.ShadowsocksApplication.app
import
scala.collection.JavaConverters._
import
scala.collection.JavaConverters._
import
scala.collection.mutable
import
scala.collection.mutable
...
@@ -55,12 +55,16 @@ class DBHelper(val context: Context)
...
@@ -55,12 +55,16 @@ class DBHelper(val context: Context)
TableUtils
.
createTable
(
connectionSource
,
classOf
[
Profile
])
TableUtils
.
createTable
(
connectionSource
,
classOf
[
Profile
])
}
}
def
recreate
(
database
:
SQLiteDatabase
,
connectionSource
:
ConnectionSource
)
{
TableUtils
.
dropTable
(
connectionSource
,
classOf
[
Profile
],
true
)
onCreate
(
database
,
connectionSource
)
}
def
onUpgrade
(
database
:
SQLiteDatabase
,
connectionSource
:
ConnectionSource
,
oldVersion
:
Int
,
def
onUpgrade
(
database
:
SQLiteDatabase
,
connectionSource
:
ConnectionSource
,
oldVersion
:
Int
,
newVersion
:
Int
)
{
newVersion
:
Int
)
{
if
(
oldVersion
!=
newVersion
)
{
if
(
oldVersion
!=
newVersion
)
{
if
(
oldVersion
<
7
)
{
if
(
oldVersion
<
7
)
{
profileDao
.
executeRawNoArgs
(
"DROP TABLE IF EXISTS 'profile';"
)
recreate
(
database
,
connectionSource
)
onCreate
(
database
,
connectionSource
)
return
return
}
}
...
@@ -132,8 +136,7 @@ class DBHelper(val context: Context)
...
@@ -132,8 +136,7 @@ class DBHelper(val context: Context)
}
catch
{
}
catch
{
case
ex
:
Exception
=>
case
ex
:
Exception
=>
app
.
track
(
ex
)
app
.
track
(
ex
)
profileDao
.
executeRawNoArgs
(
"DROP TABLE IF EXISTS 'profile';"
)
recreate
(
database
,
connectionSource
)
onCreate
(
database
,
connectionSource
)
return
return
}
}
}
}
...
...
src/main/scala/com/github/shadowsocks/database/Profile.scala
View file @
2edc14a6
...
@@ -31,7 +31,7 @@ import com.j256.ormlite.field.{DataType, DatabaseField}
...
@@ -31,7 +31,7 @@ import com.j256.ormlite.field.{DataType, DatabaseField}
class
Profile
{
class
Profile
{
@DatabaseField
(
generatedId
=
true
)
@DatabaseField
(
generatedId
=
true
)
var
id
:
Int
=
0
var
id
:
Int
=
_
@DatabaseField
@DatabaseField
var
name
:
String
=
""
var
name
:
String
=
""
...
@@ -59,28 +59,28 @@ class Profile {
...
@@ -59,28 +59,28 @@ class Profile {
var
remoteDns
:
String
=
"8.8.8.8"
var
remoteDns
:
String
=
"8.8.8.8"
@DatabaseField
@DatabaseField
var
proxyApps
:
Boolean
=
false
var
proxyApps
:
Boolean
=
_
@DatabaseField
@DatabaseField
var
bypass
:
Boolean
=
false
var
bypass
:
Boolean
=
_
@DatabaseField
@DatabaseField
var
udpdns
:
Boolean
=
false
var
udpdns
:
Boolean
=
_
@DatabaseField
@DatabaseField
var
auth
:
Boolean
=
false
var
auth
:
Boolean
=
_
@DatabaseField
@DatabaseField
var
ipv6
:
Boolean
=
false
var
ipv6
:
Boolean
=
_
@DatabaseField
(
dataType
=
DataType
.
LONG_STRING
)
@DatabaseField
(
dataType
=
DataType
.
LONG_STRING
)
var
individual
:
String
=
""
var
individual
:
String
=
""
@DatabaseField
@DatabaseField
var
tx
:
Long
=
0
var
tx
:
Long
=
_
@DatabaseField
@DatabaseField
var
rx
:
Long
=
0
var
rx
:
Long
=
_
@DatabaseField
@DatabaseField
val
date
:
java.util.Date
=
new
java
.
util
.
Date
()
val
date
:
java.util.Date
=
new
java
.
util
.
Date
()
...
@@ -89,7 +89,7 @@ class Profile {
...
@@ -89,7 +89,7 @@ class Profile {
var
userOrder
:
Long
=
_
var
userOrder
:
Long
=
_
@DatabaseField
@DatabaseField
var
kcp
:
Boolean
=
false
var
kcp
:
Boolean
=
_
@DatabaseField
@DatabaseField
var
kcpPort
:
Int
=
8399
var
kcpPort
:
Int
=
8399
...
...
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