[Android] Move dataset operations in main thread

Geoffrey Métais git at videolan.org
Tue Jan 3 17:13:10 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan  3 14:34:48 2017 +0100| [e238abb8a6bccc1772a83cdb756ccd62fc88f440] | committer: Geoffrey Métais

Move dataset operations in main thread

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

 .../vlc/gui/audio/AudioBrowserAdapter.java         | 36 +++++-----------------
 1 file changed, 8 insertions(+), 28 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
index 1cf15b6..e9fbe9c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -205,37 +205,17 @@ public class AudioBrowserAdapter extends RecyclerView.Adapter<AudioBrowserAdapte
     }
 
     public void remove(final int position) {
-        VLCApplication.runBackground(new Runnable() {
-            @Override
-            public void run() {
-                final MediaLibraryItem[] dataList = new MediaLibraryItem[getItemCount()-1];
-                Util.removePositionInArray(mDataList, position, dataList);
-                mContext.runOnUiThread(new Runnable() {
-                    @Override
-                    public void run() {
-                        mDataList = dataList;
-                        notifyItemRemoved(position);
-                    }
-                });
-            }
-        });
+        final MediaLibraryItem[] dataList = new MediaLibraryItem[getItemCount()-1];
+        Util.removePositionInArray(mDataList, position, dataList);
+        mDataList = dataList;
+        notifyItemRemoved(position);
     }
 
     public void addItem(final int position, final MediaLibraryItem item) {
-        VLCApplication.runBackground(new Runnable() {
-            @Override
-            public void run() {
-                final MediaLibraryItem[] dataList = new MediaLibraryItem[getItemCount()+1];
-                Util.addItemInArray(mDataList, position, item, dataList);
-                mContext.runOnUiThread(new Runnable() {
-                    @Override
-                    public void run() {
-                        mDataList = dataList;
-                        notifyItemInserted(position);
-                    }
-                });
-            }
-        });
+        final MediaLibraryItem[] dataList = new MediaLibraryItem[getItemCount()+1];
+        Util.addItemInArray(mDataList, position, item, dataList);
+        mDataList = dataList;
+        notifyItemInserted(position);
     }
 
     public void restoreList() {



More information about the Android mailing list