[Android] Save ArtworkUrl in favorites
Geoffrey Métais
git at videolan.org
Thu Mar 3 19:16:41 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 3 18:46:00 2016 +0100| [6f4063c52b43ddae0c5695b5be63e8a3e85d92ec] | committer: Geoffrey Métais
Save ArtworkUrl in favorites
> https://code.videolan.org/videolan/vlc-android/commit/6f4063c52b43ddae0c5695b5be63e8a3e85d92ec
---
.../vlc/gui/browser/NetworkBrowserFragment.java | 4 ++--
.../videolan/vlc/gui/dialogs/NetworkServerDialog.java | 2 +-
.../videolan/vlc/gui/tv/MediaItemDetailsFragment.java | 2 +-
.../src/org/videolan/vlc/media/MediaDatabase.java | 19 +++++++++++++++----
4 files changed, 19 insertions(+), 8 deletions(-)
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 f426f39..b40b2de 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
@@ -110,7 +110,7 @@ public class NetworkBrowserFragment extends BaseBrowserFragment implements View.
switch (id){
case R.id.network_add_favorite:
db = MediaDatabase.getInstance();
- db.addNetworkFavItem(mw.getUri(), mw.getTitle());
+ db.addNetworkFavItem(mw.getUri(), mw.getTitle(), mw.getArtworkURL());
if (isRootDirectory())
updateDisplay();
return true;
@@ -206,7 +206,7 @@ public class NetworkBrowserFragment extends BaseBrowserFragment implements View.
if (db.networkFavExists(mCurrentMedia.getUri()))
db.deleteNetworkFav(mCurrentMedia.getUri());
else
- db.addNetworkFavItem(mCurrentMedia.getUri(), mCurrentMedia.getTitle());
+ db.addNetworkFavItem(mCurrentMedia.getUri(), mCurrentMedia.getTitle(), mCurrentMedia.getArtworkURL());
getActivity().supportInvalidateOptionsMenu();
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
index eff3bcf..9e1aba3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
@@ -143,7 +143,7 @@ public class NetworkServerDialog extends DialogFragment implements AdapterView.O
MediaDatabase db = MediaDatabase.getInstance();
if (mUri != null)
db.deleteNetworkFav(mUri);
- db.addNetworkFavItem(uri, name);
+ db.addNetworkFavItem(uri, name, null);
}
private void updateUrl() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
index 72c3ad1..d6b92d7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
@@ -119,7 +119,7 @@ public class MediaItemDetailsFragment extends DetailsFragment implements Playbac
startActivity(intent);
break;
case ID_FAVORITE_ADD:
- mDb.addNetworkFavItem(Uri.parse(mMedia.getLocation()), mMedia.getTitle());
+ mDb.addNetworkFavItem(Uri.parse(mMedia.getLocation()), mMedia.getTitle(), null);
detailsOverview.removeAction(actionAdd);
detailsOverview.addAction(actionDelete);
mRowsAdapter.notifyArrayItemRangeChanged(0, mRowsAdapter.size());
diff --git a/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java
index 611e49a..ea78ea2 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java
@@ -42,6 +42,7 @@ import android.graphics.BitmapFactory;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
+import android.text.TextUtils;
import android.util.Log;
import org.videolan.libvlc.util.AndroidUtil;
@@ -54,7 +55,7 @@ public class MediaDatabase {
private SQLiteDatabase mDb;
private static final String DB_NAME = "vlc_database";
- private static final int DB_VERSION = 23;
+ private static final int DB_VERSION = 24;
private static final int CHUNK_SIZE = 50;
private static final String DIR_TABLE_NAME = "directories_table";
@@ -110,6 +111,7 @@ public class MediaDatabase {
private static final String NETWORK_FAV_TABLE_NAME = "fav_table";
private static final String NETWORK_FAV_URI = "uri";
private static final String NETWORK_FAV_TITLE = "title";
+ private static final String NETWORK_FAV_ICON_URL = "icon_url";
// public static final int INDEX_MEDIA_TABLE_NAME = 0;
// public static final int INDEX_MEDIA_PATH = 1;
@@ -320,7 +322,8 @@ public class MediaDatabase {
String createMrlTableQuery = "CREATE TABLE IF NOT EXISTS " +
NETWORK_FAV_TABLE_NAME + " (" +
NETWORK_FAV_URI + " TEXT PRIMARY KEY NOT NULL, " +
- NETWORK_FAV_TITLE + " TEXT NOT NULL" +
+ NETWORK_FAV_TITLE + " TEXT NOT NULL, " +
+ NETWORK_FAV_ICON_URL + " TEXT" +
");";
db.execSQL(createMrlTableQuery);
}
@@ -400,6 +403,10 @@ public class MediaDatabase {
break;
case 23:
createHistoryTableQuery(db);
+ break;
+ case 24:
+ dropNetworkFavTableQuery(db);
+ createNetworkFavTableQuery(db);
default:
break;
}
@@ -1193,10 +1200,11 @@ public class MediaDatabase {
* Network favorites management
*/
- public synchronized void addNetworkFavItem(Uri uri, String title) {
+ public synchronized void addNetworkFavItem(Uri uri, String title, String iconUrl) {
ContentValues values = new ContentValues();
values.put(NETWORK_FAV_URI, uri.toString());
values.put(NETWORK_FAV_TITLE, Uri.encode(title));
+ values.put(NETWORK_FAV_ICON_URL, Uri.encode(iconUrl));
mDb.replace(NETWORK_FAV_TABLE_NAME, null, values);
}
@@ -1219,13 +1227,16 @@ public class MediaDatabase {
MediaWrapper mw;
Cursor cursor = mDb.query(NETWORK_FAV_TABLE_NAME,
- new String[] { NETWORK_FAV_URI , NETWORK_FAV_TITLE},
+ new String[] { NETWORK_FAV_URI , NETWORK_FAV_TITLE, NETWORK_FAV_ICON_URL},
null, null, null, null, null);
if (cursor != null) {
while (cursor.moveToNext()) {
mw = new MediaWrapper(Uri.parse(cursor.getString(0)));
mw.setDisplayTitle(Uri.decode(cursor.getString(1)));
mw.setType(MediaWrapper.TYPE_DIR);
+ String url = cursor.getString(2);
+ if (!TextUtils.isEmpty(url))
+ mw.setArtworkURL(Uri.decode(url));
favs.add(mw);
}
cursor.close();
More information about the Android
mailing list