[Android] Update Extensions display

Geoffrey Métais git at videolan.org
Fri Sep 1 17:40:04 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Sep  1 17:38:40 2017 +0200| [b0cc218ab403a5a2f5e74871b95ce35d1d9aa315] | committer: Geoffrey Métais

Update Extensions display

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

 .../videolan/vlc/gui/browser/ExtensionAdapter.java    | 19 ++++---------------
 .../videolan/vlc/gui/browser/ExtensionBrowser.java    |  7 +------
 .../videolan/vlc/gui/helpers/AsyncImageLoader.java    |  2 ++
 3 files changed, 7 insertions(+), 21 deletions(-)

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 0fc40be00..8ca114114 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionAdapter.java
@@ -1,28 +1,23 @@
 package org.videolan.vlc.gui.browser;
 
-import android.content.res.Resources;
 import android.databinding.DataBindingUtil;
-import android.graphics.BitmapFactory;
-import android.graphics.drawable.BitmapDrawable;
 import android.net.Uri;
 import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 
+import org.videolan.medialibrary.media.MediaWrapper;
 import org.videolan.vlc.R;
 import org.videolan.vlc.databinding.ExtensionItemViewBinding;
 import org.videolan.vlc.extensions.api.VLCExtensionItem;
-import org.videolan.vlc.gui.helpers.AsyncImageLoader;
 import org.videolan.vlc.media.MediaUtils;
-import org.videolan.medialibrary.media.MediaWrapper;
-import org.videolan.vlc.util.HttpImageLoader;
 
 import java.util.ArrayList;
 import java.util.List;
 
 public class ExtensionAdapter extends RecyclerView.Adapter<ExtensionAdapter.ViewHolder> {
+    private static final String TAG = "VLC/ExtensionAdapter";
 
     ExtensionBrowser mFragment;
     List<VLCExtensionItem> mItemsList = new ArrayList<>();
@@ -34,7 +29,6 @@ public class ExtensionAdapter extends RecyclerView.Adapter<ExtensionAdapter.View
         public ViewHolder(ExtensionItemViewBinding binding) {
             super(binding.getRoot());
             this.binding = binding;
-            itemView.setOnLongClickListener(this);
             binding.setHolder(this);
         }
 
@@ -79,14 +73,9 @@ public class ExtensionAdapter extends RecyclerView.Adapter<ExtensionAdapter.View
 
     @Override
     public void onBindViewHolder(ViewHolder holder, int position) {
-        final ViewHolder vh = holder;
         final VLCExtensionItem item = getItem(position);
-        vh.binding.setItem(item);
-        vh.binding.executePendingBindings();
-        Resources res = holder.itemView.getContext().getResources();
-        vh.binding.setImage(new BitmapDrawable(res, BitmapFactory.decodeResource(res, getIconResId(item))));
-        if (item.imageUri != null && (TextUtils.equals("http", item.imageUri.getScheme())))
-                AsyncImageLoader.LoadImage(new HttpImageLoader(item.getImageUri().toString(), holder.binding), null);
+        holder.binding.setItem(item);
+        holder.binding.executePendingBindings();
     }
 
     private int getIconResId(VLCExtensionItem item) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java b/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java
index eb59c8b49..4cc01903d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java
@@ -7,7 +7,6 @@ import android.os.Message;
 import android.support.design.widget.FloatingActionButton;
 import android.support.v4.app.Fragment;
 import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.DividerItemDecoration;
 import android.support.v7.widget.LinearLayoutManager;
 import android.view.ContextMenu;
 import android.view.LayoutInflater;
@@ -18,7 +17,6 @@ import android.widget.TextView;
 
 import org.videolan.medialibrary.media.MediaWrapper;
 import org.videolan.vlc.R;
-import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.extensions.ExtensionListing;
 import org.videolan.vlc.extensions.ExtensionManagerService;
 import org.videolan.vlc.extensions.Utils;
@@ -49,7 +47,6 @@ public class ExtensionBrowser extends Fragment implements View.OnClickListener,
     private FloatingActionButton mAddDirectoryFAB;
     private ExtensionAdapter mAdapter;
     protected ContextMenuRecyclerView mRecyclerView;
-    protected LinearLayoutManager mLayoutManager;
     protected TextView mEmptyView;
     protected SwipeRefreshLayout mSwipeRefreshLayout;
 
@@ -85,9 +82,7 @@ public class ExtensionBrowser extends Fragment implements View.OnClickListener,
         mRecyclerView = v.findViewById(R.id.network_list);
         mEmptyView = v.findViewById(android.R.id.empty);
         mEmptyView.setText(R.string.extension_empty);
-        mLayoutManager = new LinearLayoutManager(getActivity());
-        mRecyclerView.addItemDecoration(new DividerItemDecoration(VLCApplication.getAppContext(), DividerItemDecoration.VERTICAL));
-        mRecyclerView.setLayoutManager(mLayoutManager);
+        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
         mRecyclerView.setAdapter(mAdapter);
         registerForContextMenu(mRecyclerView);
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java b/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
index ecdb5dd6c..cc9f4eb07 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
@@ -67,6 +67,8 @@ public class AsyncImageLoader {
 
     @BindingAdapter({"imageUri"})
     public static void downloadIcon(final View v, final Uri imageUri) {
+        if (imageUri == null || !imageUri.getScheme().equals("http"))
+            return;
         AsyncImageLoader.LoadImage(new CoverFetcher(null) {
             @Override
             public Bitmap getImage() {



More information about the Android mailing list