[Android] Extension items pass image Uri instead of String

Geoffrey Métais git at videolan.org
Mon Feb 1 15:17:04 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb  1 15:07:58 2016 +0100| [9214aa5a4cbc6db3543e058355a284cca10689d3] | committer: Geoffrey Métais

Extension items pass image Uri instead of String

Will be compliant with 'content://' Uris

> https://code.videolan.org/videolan/vlc-android/commit/9214aa5a4cbc6db3543e058355a284cca10689d3
---

 .../videolan/vlc/extensions/api/VLCExtensionItem.java   | 17 +++++++++--------
 .../org/videolan/vlc/gui/browser/ExtensionAdapter.java  |  7 ++++---
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/api/src/main/java/org/videolan/vlc/extensions/api/VLCExtensionItem.java b/api/src/main/java/org/videolan/vlc/extensions/api/VLCExtensionItem.java
index e7651af..fe2b12e 100644
--- a/api/src/main/java/org/videolan/vlc/extensions/api/VLCExtensionItem.java
+++ b/api/src/main/java/org/videolan/vlc/extensions/api/VLCExtensionItem.java
@@ -23,6 +23,7 @@
 
 package org.videolan.vlc.extensions.api;
 
+import android.net.Uri;
 import android.os.Parcel;
 import android.os.Parcelable;
 
@@ -77,7 +78,7 @@ public class VLCExtensionItem implements Parcelable {
     public String title;
     public String subTitle;
 
-    public String imageLink; // for content provider
+    public Uri imageUri; // for content provider
     public int type; // Using VLC icons. maybe with iconRes?
 
     /**
@@ -152,17 +153,17 @@ public class VLCExtensionItem implements Parcelable {
     /**
      * Returns the {#link VLCExtensionItem} icon image link
      */
-    public String getImageLink() {
-        return imageLink;
+    public Uri getImageUri() {
+        return imageUri;
     }
 
     /**
      * Sets the uri string of the {#link VLCExtensionItem} icon image.
      *
-     * @param imageLink The uri string to set.
+     * @param imageUri The uri string to set.
      */
-    public VLCExtensionItem setImageLink(String imageLink) {
-        this.imageLink = imageLink;
+    public VLCExtensionItem setImageUri(Uri imageUri) {
+        this.imageUri = imageUri;
         return this;
     }
 
@@ -208,7 +209,7 @@ public class VLCExtensionItem implements Parcelable {
         dest.writeString(link);
         dest.writeString(title);
         dest.writeString(subTitle);
-        dest.writeString(imageLink);
+        dest.writeParcelable(imageUri, 0);
         dest.writeInt(type);
     }
 
@@ -218,7 +219,7 @@ public class VLCExtensionItem implements Parcelable {
         link = in.readString();
         title = in.readString();
         subTitle = in.readString();
-        imageLink = in.readString();
+        imageUri = in.readParcelable(null);
         type = in.readInt();
     }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionAdapter.java
index 3e9a22d..71612f3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionAdapter.java
@@ -96,9 +96,10 @@ public class ExtensionAdapter extends RecyclerView.Adapter<ExtensionAdapter.View
         vh.binding.executePendingBindings();
         Resources res = holder.itemView.getContext().getResources();
         vh.binding.setImage(new BitmapDrawable(res, BitmapFactory.decodeResource(res, getIconResId(item))));
-
-        if (!TextUtils.isEmpty(item.imageLink) && item.imageLink.startsWith("http://"))
-            AsyncImageLoader.LoadImage(new HttpImageFetcher(holder.binding, item.imageLink), null);
+        if (item.imageUri != null) {
+            if (TextUtils.equals("http", item.imageUri.getScheme()))
+                AsyncImageLoader.LoadImage(new HttpImageFetcher(holder.binding, item.getImageUri().toString()), null);
+        }
     }
 
     private static class HttpImageFetcher extends AsyncImageLoader.CoverFetcher {



More information about the Android mailing list