Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
VLC-Android
Commits
7d5d28c1
Commit
7d5d28c1
authored
Jul 04, 2012
by
Sébastien Toque
Browse files
Only save last media & position on exit and if not at the beginning
parent
d0b93a1e
Changes
2
Hide whitespace changes
Inline
Side-by-side
vlc-android/src/org/videolan/vlc/gui/video/VideoListFragment.java
View file @
7d5d28c1
...
...
@@ -105,8 +105,8 @@ public class VideoListFragment extends SherlockListFragment implements ISortable
public
void
onResume
()
{
//Get & highlight the last media
SharedPreferences
preferences
=
getActivity
().
getSharedPreferences
(
PreferencesActivity
.
NAME
,
Context
.
MODE_PRIVATE
);
String
lastPath
=
preferences
.
getString
(
"LastMedia"
,
null
);
long
lastTime
=
preferences
.
getLong
(
"LastTime"
,
0
);
String
lastPath
=
preferences
.
getString
(
PreferencesActivity
.
LAST_MEDIA
,
null
);
long
lastTime
=
preferences
.
getLong
(
PreferencesActivity
.
LAST_TIME
,
0
);
mVideoAdapter
.
setLastMedia
(
lastTime
,
lastPath
);
mVideoAdapter
.
notifyDataSetChanged
();
mMediaLibrary
.
addUpdateHandler
(
mHandler
);
...
...
vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
View file @
7d5d28c1
...
...
@@ -81,6 +81,7 @@ public class VideoPlayerActivity extends Activity {
private
SurfaceView
mSurface
;
private
SurfaceHolder
mSurfaceHolder
;
private
LibVLC
mLibVLC
;
private
String
mLocation
;
private
static
final
int
SURFACE_BEST_FIT
=
0
;
private
static
final
int
SURFACE_FIT_HORIZONTAL
=
1
;
...
...
@@ -212,10 +213,13 @@ public class VideoPlayerActivity extends Activity {
mSurface
.
setKeepScreenOn
(
false
);
// Save position
SharedPreferences
preferences
=
getSharedPreferences
(
PreferencesActivity
.
NAME
,
MODE_PRIVATE
);
SharedPreferences
.
Editor
editor
=
preferences
.
edit
();
editor
.
putLong
(
PreferencesActivity
.
LAST_TIME
,
time
);
editor
.
commit
();
if
(
time
>=
0
)
{
SharedPreferences
preferences
=
getSharedPreferences
(
PreferencesActivity
.
NAME
,
MODE_PRIVATE
);
SharedPreferences
.
Editor
editor
=
preferences
.
edit
();
editor
.
putString
(
PreferencesActivity
.
LAST_MEDIA
,
mLocation
);
editor
.
putLong
(
PreferencesActivity
.
LAST_TIME
,
time
);
editor
.
commit
();
}
super
.
onPause
();
}
...
...
@@ -827,7 +831,7 @@ public class VideoPlayerActivity extends Activity {
*
*/
private
void
load
()
{
String
l
ocation
=
null
;
mL
ocation
=
null
;
String
title
=
null
;
String
lastLocation
=
null
;
long
lastTime
=
0
;
...
...
@@ -836,27 +840,24 @@ public class VideoPlayerActivity extends Activity {
if
(
getIntent
().
getAction
()
!=
null
&&
getIntent
().
getAction
().
equals
(
Intent
.
ACTION_VIEW
))
{
/* Started from external application */
l
ocation
=
getIntent
().
getDataString
();
mL
ocation
=
getIntent
().
getDataString
();
}
else
if
(
getIntent
().
getExtras
()
!=
null
)
{
/* Started from VideoListActivity */
l
ocation
=
getIntent
().
getExtras
().
getString
(
"itemLocation"
);
mL
ocation
=
getIntent
().
getExtras
().
getString
(
"itemLocation"
);
}
if
(
l
ocation
!=
null
&&
l
ocation
.
length
()
>
0
)
{
mLibVLC
.
readMedia
(
l
ocation
,
false
);
if
(
mL
ocation
!=
null
&&
mL
ocation
.
length
()
>
0
)
{
mLibVLC
.
readMedia
(
mL
ocation
,
false
);
mSurface
.
setKeepScreenOn
(
true
);
// Save media for next time, and restore position if it's the same one as before
lastLocation
=
preferences
.
getString
(
PreferencesActivity
.
LAST_MEDIA
,
null
);
lastTime
=
preferences
.
getLong
(
PreferencesActivity
.
LAST_TIME
,
0
);
SharedPreferences
.
Editor
editor
=
preferences
.
edit
();
editor
.
putString
(
PreferencesActivity
.
LAST_MEDIA
,
location
);
editor
.
commit
();
if
(
lastTime
>
0
&&
location
.
equals
(
lastLocation
))
if
(
lastTime
>
0
&&
mLocation
.
equals
(
lastLocation
))
mLibVLC
.
setTime
(
lastTime
);
try
{
title
=
URLDecoder
.
decode
(
l
ocation
,
"UTF-8"
);
title
=
URLDecoder
.
decode
(
mL
ocation
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
}
if
(
title
.
startsWith
(
"file:"
))
{
...
...
Write
Preview
Supports
Markdown
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