Commit 9214aa5a authored by Geoffrey Métais's avatar Geoffrey Métais

Extension items pass image Uri instead of String

Will be compliant with 'content://' Uris
parent 197c9a15
......@@ -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();
}
}
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment