[Android] Use SimpleArrayMap when possible

Geoffrey Métais git at videolan.org
Thu Nov 17 17:59:54 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Nov 17 16:53:06 2016 +0100| [2bb101e950360964f28ffccac3e09f73f9908c3c] | committer: Geoffrey Métais

Use SimpleArrayMap when possible

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

 vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java       | 8 ++++----
 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java | 5 ++---
 vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java  | 4 ++--
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
index 5ca5de5..e29c122 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
@@ -42,7 +42,7 @@ import android.support.v17.leanback.widget.OnItemViewSelectedListener;
 import android.support.v17.leanback.widget.Presenter;
 import android.support.v17.leanback.widget.Row;
 import android.support.v17.leanback.widget.RowPresenter;
-import android.support.v4.util.ArrayMap;
+import android.support.v4.util.SimpleArrayMap;
 import android.view.KeyEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -104,9 +104,9 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
     ArrayObjectAdapter mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
     ArrayObjectAdapter mVideoAdapter, mCategoriesAdapter, mHistoryAdapter, mBrowserAdapter, mOtherAdapter;
     View mRootContainer;
-    final ArrayMap<String, Integer> mVideoIndex = new ArrayMap<>(), mHistoryIndex = new ArrayMap<>();
-    Drawable mDefaultBackground;
-    Activity mContext;
+    final SimpleArrayMap<String, Integer> mVideoIndex = new SimpleArrayMap<>(), mHistoryIndex = new SimpleArrayMap<>();
+    private Drawable mDefaultBackground;
+    private Activity mContext;
     private Object mSelectedItem;
     private AsyncUpdate mUpdateTask;
     private CardPresenter.SimpleCard mNowPlayingCard;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index 6bc8a96..d640bc8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -33,6 +33,7 @@ import android.os.Handler;
 import android.preference.PreferenceManager;
 import android.support.annotation.MainThread;
 import android.support.v4.content.LocalBroadcastManager;
+import android.support.v4.util.SimpleArrayMap;
 import android.support.v7.view.ActionMode;
 import android.util.DisplayMetrics;
 import android.util.Log;
@@ -70,9 +71,7 @@ import org.videolan.vlc.util.FileUtils;
 import org.videolan.vlc.util.VLCInstance;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 public class VideoGridFragment extends MediaBrowserFragment implements MediaUpdatedCb, ISortable, SwipeRefreshLayout.OnRefreshListener, DevicesDiscoveryCb, MediaAddedCb, Filterable {
 
@@ -206,7 +205,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
             @Override
             public void run() {
                 MediaWrapper[] videos = mMediaLibrary.getVideos();
-                final Map<Long, Long> times = new HashMap<>(videos.length);
+                final SimpleArrayMap<Long, Long> times = new SimpleArrayMap<>(videos.length);
                 for (MediaWrapper mw : videos)
                     times.put(mw.getId(), mw.getTime());
                 mHandler.post(new Runnable() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index 6eb1a03..509509e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -28,6 +28,7 @@ import android.databinding.ViewDataBinding;
 import android.preference.PreferenceManager;
 import android.support.annotation.MainThread;
 import android.support.annotation.Nullable;
+import android.support.v4.util.SimpleArrayMap;
 import android.support.v7.util.SortedList;
 import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.RecyclerView;
@@ -55,7 +56,6 @@ import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 
 public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.ViewHolder> implements Filterable {
 
@@ -108,7 +108,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
     }
 
     @MainThread
-    void setTimes( Map<Long, Long> times) {
+    void setTimes( SimpleArrayMap<Long, Long> times) {
         // update times
         for (int i = 0; i < getItemCount(); ++i) {
             MediaWrapper media = mVideos.get(i);



More information about the Android mailing list