[Android] Directly save Uri for network favorites
Geoffrey Métais
git at videolan.org
Fri Jun 12 12:25:14 CEST 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jun 12 12:24:05 2015 +0200| [b427fb85c819b7961bdd58b964bc81bb14f2f3ad] | committer: Geoffrey Métais
Directly save Uri for network favorites
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=b427fb85c819b7961bdd58b964bc81bb14f2f3ad
---
vlc-android/src/org/videolan/vlc/MediaDatabase.java | 14 +++++++-------
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 2 +-
.../videolan/vlc/gui/browser/NetworkBrowserFragment.java | 6 +++---
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
index 727cc02..201f328 100644
--- a/vlc-android/src/org/videolan/vlc/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
@@ -1047,18 +1047,18 @@ public class MediaDatabase {
}
- public synchronized void addNetworkFavItem(String mrl, String title) {
+ public synchronized void addNetworkFavItem(Uri uri, String title) {
ContentValues values = new ContentValues();
- values.put(NETWORK_FAV_URI, Uri.encode(mrl));
+ values.put(NETWORK_FAV_URI, uri.toString());
values.put(NETWORK_FAV_TITLE, Uri.encode(title));
mDb.replace(NETWORK_FAV_TABLE_NAME, null, values);
}
- public synchronized boolean networkFavExists(String mrl) {
+ public synchronized boolean networkFavExists(Uri uri) {
Cursor cursor = mDb.query(NETWORK_FAV_TABLE_NAME,
new String[] { NETWORK_FAV_URI },
NETWORK_FAV_URI + "=?",
- new String[] { Uri.encode(mrl) },
+ new String[] { uri.toString() },
null, null, null);
boolean exists = cursor.moveToFirst();
cursor.close();
@@ -1074,7 +1074,7 @@ public class MediaDatabase {
null, null, null, null, null);
while (cursor.moveToNext()) {
- mw = new MediaWrapper(Uri.parse(Uri.decode(cursor.getString(0))));
+ mw = new MediaWrapper(Uri.parse(cursor.getString(0)));
mw.setTitle(Uri.decode(cursor.getString(1)));
mw.setType(MediaWrapper.TYPE_DIR);
favs.add(mw);
@@ -1084,8 +1084,8 @@ public class MediaDatabase {
return favs;
}
- public synchronized void deleteNetworkFav(String uri) {
- mDb.delete(NETWORK_FAV_TABLE_NAME, NETWORK_FAV_URI + "=?", new String[] { Uri.encode(uri) });
+ public synchronized void deleteNetworkFav(Uri uri) {
+ mDb.delete(NETWORK_FAV_TABLE_NAME, NETWORK_FAV_URI + "=?", new String[] { uri.toString() });
}
public synchronized void clearNetworkFavTable() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 7b1c5ad..2f32903 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -446,7 +446,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements OnItem
item = menu.findItem(R.id.ml_menu_save);
item.setVisible(true);
String mrl = ((BaseBrowserFragment)current).mMrl;
- item.setIcon(MediaDatabase.getInstance().networkFavExists(mrl) ?
+ item.setIcon(MediaDatabase.getInstance().networkFavExists(Uri.parse(mrl)) ?
R.drawable.ic_menu_bookmark_w :
R.drawable.ic_menu_bookmark_outline_w);
} else
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
index cdd515b..506d9d9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
@@ -129,10 +129,10 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
public void toggleFavorite() {
MediaDatabase db = MediaDatabase.getInstance();
- if (db.networkFavExists(mMrl))
- db.deleteNetworkFav(mMrl);
+ if (db.networkFavExists(mCurrentMedia.getUri()))
+ db.deleteNetworkFav(mCurrentMedia.getUri());
else
- db.addNetworkFavItem(mMrl, mCurrentMedia.getTitle());
+ db.addNetworkFavItem(mCurrentMedia.getUri(), mCurrentMedia.getTitle());
getActivity().supportInvalidateOptionsMenu();
}
More information about the Android
mailing list