Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RvApp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lify
RvApp
Commits
bbec3b71
Commit
bbec3b71
authored
Sep 24, 2019
by
linfeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_im' of
http://113.105.137.151:22280/lify/rvapp
into master-video
parents
3a2e31d0
e096abfc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
0 deletions
+90
-0
AppCookie.java
...utils/src/main/java/com/rv/component/utils/AppCookie.java
+90
-0
No files found.
component_utils/src/main/java/com/rv/component/utils/AppCookie.java
0 → 100644
View file @
bbec3b71
package
com
.
rv
.
component
.
utils
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
java.lang.ref.WeakReference
;
public
class
Cookie
{
private
final
static
String
COOKIE_FILE
=
"cookie"
;
private
static
SharedPreferences
preferences
;
private
static
WeakReference
<
Context
>
weakReference
=
null
;
public
static
void
init
(
Context
context
)
{
weakReference
=
new
WeakReference
<>(
context
);
}
private
static
SharedPreferences
getPreference
()
{
if
(
preferences
==
null
)
{
preferences
=
weakReference
.
get
().
getSharedPreferences
(
COOKIE_FILE
,
Context
.
MODE_PRIVATE
);
}
return
preferences
;
}
public
static
void
save
(
Context
context
,
String
key
,
String
s
)
{
getPreference
().
edit
().
putString
(
key
,
s
).
commit
();
}
public
static
void
save
(
Context
context
,
String
key
,
int
i
)
{
getPreference
().
edit
().
putInt
(
key
,
i
).
commit
();
}
public
static
void
save
(
Context
context
,
String
key
,
long
l
)
{
getPreference
().
edit
().
putLong
(
key
,
l
).
commit
();
}
public
static
void
save
(
Context
context
,
String
key
,
boolean
b
)
{
getPreference
().
edit
().
putBoolean
(
key
,
b
).
commit
();
}
public
static
void
save
(
Context
context
,
String
key
,
float
f
)
{
getPreference
().
edit
().
putFloat
(
key
,
f
).
commit
();
}
public
static
String
getStringValue
(
Context
context
,
String
key
)
{
return
getStringValue
(
context
,
key
,
""
);
}
public
static
String
getStringValue
(
Context
context
,
String
key
,
String
def
)
{
return
getPreference
().
getString
(
key
,
def
);
}
public
static
int
getIntValue
(
Context
context
,
String
key
)
{
return
getIntValue
(
context
,
key
,
-
1
);
}
public
static
int
getIntValue
(
Context
context
,
String
key
,
int
def
)
{
return
getPreference
().
getInt
(
key
,
def
);
}
public
static
long
getLongValue
(
Context
context
,
String
key
)
{
return
getLongValue
(
context
,
key
,
0
l
);
}
public
static
long
getLongValue
(
Context
context
,
String
key
,
long
def
)
{
return
getPreference
().
getLong
(
key
,
def
);
}
public
static
float
getFloatValue
(
Context
context
,
String
key
)
{
return
getFloatValue
(
context
,
key
,
0
f
);
}
public
static
float
getFloatValue
(
Context
context
,
String
key
,
float
def
)
{
return
getPreference
().
getFloat
(
key
,
def
);
}
public
static
boolean
getBooleanValue
(
Context
context
,
String
key
)
{
return
getBooleanValue
(
context
,
key
,
false
);
}
public
static
boolean
getBooleanValue
(
Context
context
,
String
key
,
boolean
def
)
{
return
getPreference
().
getBoolean
(
key
,
def
);
}
public
static
void
clear
(
Context
context
)
{
getPreference
().
edit
().
clear
().
commit
();
}
}
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