[Android] [PATCH] Get rid of GridFragment and SherlockGridFragment
Geoffrey Métais
geoffrey.metais at gmail.com
Sun Jan 4 20:24:21 CET 2015
---
.../src/org/videolan/android/ui/GridFragment.java | 395 ---------------------
.../videolan/android/ui/SherlockGridFragment.java | 63 ----
.../videolan/vlc/gui/video/VideoGridFragment.java | 75 ++--
.../videolan/vlc/gui/video/VideoListAdapter.java | 7 +-
4 files changed, 46 insertions(+), 494 deletions(-)
delete mode 100644 vlc-android/src/org/videolan/android/ui/GridFragment.java
delete mode 100644 vlc-android/src/org/videolan/android/ui/SherlockGridFragment.java
diff --git a/vlc-android/src/org/videolan/android/ui/GridFragment.java b/vlc-android/src/org/videolan/android/ui/GridFragment.java
deleted file mode 100644
index 92b6977..0000000
--- a/vlc-android/src/org/videolan/android/ui/GridFragment.java
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- * Copyright (C) 2011 Peter Kuterna
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.videolan.android.ui;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.v4.app.Fragment;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.AnimationUtils;
-import android.widget.AdapterView;
-import android.widget.FrameLayout;
-import android.widget.GridView;
-import android.widget.LinearLayout;
-import android.widget.ListAdapter;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-/**
- * Copy a the static library support version of the framework's
- * {@link android.app.ListFragment}, but then targeted for a {@link GridView}.
- */
-public class GridFragment extends Fragment {
- static final int INTERNAL_EMPTY_ID = 0x00ff0001;
- static final int INTERNAL_PROGRESS_CONTAINER_ID = 0x00ff0002;
- static final int INTERNAL_GRID_CONTAINER_ID = 0x00ff0003;
-
- final private Handler mHandler = new Handler();
-
- final private Runnable mRequestFocus = new Runnable() {
- public void run() {
- mGrid.focusableViewAvailable(mGrid);
- }
- };
-
- final private AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView<?> parent, View v, int position,
- long id) {
- onGridItemClick((GridView) parent, v, position, id);
- }
- };
-
- ListAdapter mAdapter;
- GridView mGrid;
- View mEmptyView;
- TextView mStandardEmptyView;
- View mProgressContainer;
- View mGridContainer;
- CharSequence mEmptyText;
- boolean mGridShown;
-
- public GridFragment() {
- }
-
- /**
- * Provide default implementation to return a simple grid view. Subclasses
- * can override to replace with their own layout. If doing so, the returned
- * view hierarchy <em>must</em> have a GridView whose id is
- * {@link android.R.id#list android.R.id.list} and can optionally have a
- * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
- * be shown when the list is empty.
- *
- * <p>
- * If you are overriding this method with your own custom content, consider
- * including the standard layout {@link android.R.layout#list_content} in
- * your layout file, so that you continue to retain all of the standard
- * behavior of GridFragment. In particular, this is currently the only way
- * to have the built-in indeterminant progress state be shown.
- */
- @SuppressWarnings("deprecation")
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- final Context context = getActivity();
-
- FrameLayout root = new FrameLayout(context);
-
- // ------------------------------------------------------------------
-
- LinearLayout pframe = new LinearLayout(context);
- pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
- pframe.setOrientation(LinearLayout.VERTICAL);
- pframe.setVisibility(View.GONE);
- pframe.setGravity(Gravity.CENTER);
-
- ProgressBar progress = new ProgressBar(context, null,
- android.R.attr.progressBarStyleLarge);
- pframe.addView(progress, new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.WRAP_CONTENT));
-
- root.addView(pframe, new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.FILL_PARENT,
- ViewGroup.LayoutParams.FILL_PARENT));
-
- // ------------------------------------------------------------------
-
- FrameLayout gframe = new FrameLayout(context);
- gframe.setId(INTERNAL_GRID_CONTAINER_ID);
-
- TextView tv = new TextView(context);
- tv.setId(INTERNAL_EMPTY_ID);
- tv.setGravity(Gravity.CENTER);
- gframe.addView(tv, new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.FILL_PARENT,
- ViewGroup.LayoutParams.FILL_PARENT));
-
- GridView gv = new GridView(context);
- gv.setId(android.R.id.list);
- gv.setDrawSelectorOnTop(false);
- gframe.addView(gv, new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.FILL_PARENT,
- ViewGroup.LayoutParams.FILL_PARENT));
-
- root.addView(gframe, new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.FILL_PARENT,
- ViewGroup.LayoutParams.FILL_PARENT));
-
- // ------------------------------------------------------------------
-
- root.setLayoutParams(new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.FILL_PARENT,
- ViewGroup.LayoutParams.FILL_PARENT));
-
- return root;
- }
-
- /**
- * Attach to grid view once the view hierarchy has been created.
- */
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- ensureGrid();
- }
-
- /**
- * Detach from grid view.
- */
- @Override
- public void onDestroyView() {
- mHandler.removeCallbacks(mRequestFocus);
- mGrid = null;
- mGridShown = false;
- mEmptyView = mProgressContainer = mGridContainer = null;
- mStandardEmptyView = null;
- super.onDestroyView();
- }
-
- /**
- * This method will be called when an item in the grid is selected.
- * Subclasses should override. Subclasses can call
- * getGridView().getItemAtPosition(position) if they need to access the data
- * associated with the selected item.
- *
- * @param gv
- * The GridView where the click happened
- * @param v
- * The view that was clicked within the GridView
- * @param position
- * The position of the view in the grid
- * @param id
- * The row id of the item that was clicked
- */
- public void onGridItemClick(GridView gv, View v, int position, long id) {
- }
-
- /**
- * Provide the cursor for the grid view.
- */
- public void setListAdapter(ListAdapter adapter) {
- boolean hadAdapter = mAdapter != null;
- mAdapter = adapter;
- if (mGrid != null) {
- mGrid.setAdapter(adapter);
- if (!mGridShown && !hadAdapter) {
- // The grid was hidden, and previously didn't have an
- // adapter. It is now time to show it.
- setGridShown(true, getView().getWindowToken() != null);
- }
- }
- }
-
- /**
- * Set the currently selected grid item to the specified position with the
- * adapter's data
- *
- * @param position
- */
- public void setSelection(int position) {
- ensureGrid();
- mGrid.setSelection(position);
- }
-
- /**
- * Get the position of the currently selected grid item.
- */
- public int getSelectedItemPosition() {
- ensureGrid();
- return mGrid.getSelectedItemPosition();
- }
-
- /**
- * Get the cursor row ID of the currently selected grid item.
- */
- public long getSelectedItemId() {
- ensureGrid();
- return mGrid.getSelectedItemId();
- }
-
- /**
- * Get the activity's grid view widget.
- */
- public GridView getGridView() {
- ensureGrid();
- return mGrid;
- }
-
- /**
- * The default content for a GridFragment has a TextView that can be shown
- * when the grid is empty. If you would like to have it shown, call this
- * method to supply the text it should use.
- */
- public void setEmptyText(CharSequence text) {
- ensureGrid();
- if (mStandardEmptyView == null) {
- throw new IllegalStateException(
- "Can't be used with a custom content view");
- }
- mStandardEmptyView.setText(text);
- if (mEmptyText == null) {
- mGrid.setEmptyView(mStandardEmptyView);
- }
- mEmptyText = text;
- }
-
- /**
- * Control whether the grid is being displayed. You can make it not
- * displayed if you are waiting for the initial data to show in it. During
- * this time an indeterminant progress indicator will be shown instead.
- *
- * <p>
- * Applications do not normally need to use this themselves. The default
- * behavior of GridFragment is to start with the grid not being shown, only
- * showing it once an adapter is given with
- * {@link #setListAdapter(ListAdapter)}. If the grid at that point had not
- * been shown, when it does get shown it will be do without the user ever
- * seeing the hidden state.
- *
- * @param shown
- * If true, the grid view is shown; if false, the progress
- * indicator. The initial value is true.
- */
- public void setGridShown(boolean shown) {
- setGridShown(shown, true);
- }
-
- /**
- * Like {@link #setGridShown(boolean)}, but no animation is used when
- * transitioning from the previous state.
- */
- public void setGridShownNoAnimation(boolean shown) {
- setGridShown(shown, false);
- }
-
- /**
- * Control whether the grid is being displayed. You can make it not
- * displayed if you are waiting for the initial data to show in it. During
- * this time an indeterminant progress indicator will be shown instead.
- *
- * @param shown
- * If true, the grid view is shown; if false, the progress
- * indicator. The initial value is true.
- * @param animate
- * If true, an animation will be used to transition to the new
- * state.
- */
- private void setGridShown(boolean shown, boolean animate) {
- ensureGrid();
- if (mProgressContainer == null) {
- throw new IllegalStateException(
- "Can't be used with a custom content view");
- }
- if (mGridShown == shown) {
- return;
- }
- mGridShown = shown;
- if (shown) {
- if (animate) {
- mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
- getActivity(), android.R.anim.fade_out));
- mGridContainer.startAnimation(AnimationUtils.loadAnimation(
- getActivity(), android.R.anim.fade_in));
- } else {
- mProgressContainer.clearAnimation();
- mGridContainer.clearAnimation();
- }
- mProgressContainer.setVisibility(View.GONE);
- mGridContainer.setVisibility(View.VISIBLE);
- } else {
- if (animate) {
- mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
- getActivity(), android.R.anim.fade_in));
- mGridContainer.startAnimation(AnimationUtils.loadAnimation(
- getActivity(), android.R.anim.fade_out));
- } else {
- mProgressContainer.clearAnimation();
- mGridContainer.clearAnimation();
- }
- mProgressContainer.setVisibility(View.VISIBLE);
- mGridContainer.setVisibility(View.GONE);
- }
- }
-
- /**
- * Get the ListAdapter associated with this activity's GridView.
- */
- public ListAdapter getListAdapter() {
- return mAdapter;
- }
-
- private void ensureGrid() {
- if (mGrid != null) {
- return;
- }
- View root = getView();
- if (root == null) {
- throw new IllegalStateException("Content view not yet created");
- }
- if (root instanceof GridView) {
- mGrid = (GridView) root;
- } else {
- mStandardEmptyView = (TextView) root
- .findViewById(INTERNAL_EMPTY_ID);
- if (mStandardEmptyView == null) {
- mEmptyView = root.findViewById(android.R.id.empty);
- } else {
- mStandardEmptyView.setVisibility(View.GONE);
- }
- mProgressContainer = root
- .findViewById(INTERNAL_PROGRESS_CONTAINER_ID);
- mGridContainer = root.findViewById(INTERNAL_GRID_CONTAINER_ID);
- View rawGridView = root.findViewById(android.R.id.list);
- if (!(rawGridView instanceof GridView)) {
- if (rawGridView == null) {
- throw new RuntimeException(
- "Your content must have a GridView whose id attribute is "
- + "'android.R.id.list'");
- }
- throw new RuntimeException(
- "Content has view with id attribute 'android.R.id.list' "
- + "that is not a GridView class");
- }
- mGrid = (GridView) rawGridView;
- if (mEmptyView != null) {
- mGrid.setEmptyView(mEmptyView);
- } else if (mEmptyText != null && mStandardEmptyView != null) {
- mStandardEmptyView.setText(mEmptyText);
- mGrid.setEmptyView(mStandardEmptyView);
- }
- }
- mGridShown = true;
- mGrid.setOnItemClickListener(mOnClickListener);
- if (mAdapter != null) {
- ListAdapter adapter = mAdapter;
- mAdapter = null;
- setListAdapter(adapter);
- } else {
- // We are starting without an adapter, so assume we won't
- // have our data right away and start with the progress indicator.
- if (mProgressContainer != null) {
- setGridShown(false, false);
- }
- }
- mHandler.post(mRequestFocus);
- }
-}
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/android/ui/SherlockGridFragment.java b/vlc-android/src/org/videolan/android/ui/SherlockGridFragment.java
deleted file mode 100644
index 4178ce8..0000000
--- a/vlc-android/src/org/videolan/android/ui/SherlockGridFragment.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2012 Jake Wharton
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.videolan.android.ui;
-
-import android.app.Activity;
-import android.support.v4.app.FragmentActivity;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-
-public class SherlockGridFragment extends GridFragment {
- private FragmentActivity mActivity;
-
- public FragmentActivity getSherlockActivity() {
- return mActivity;
- }
-
- @Override
- public void onAttach(Activity activity) {
- if (!(activity instanceof FragmentActivity)) {
- throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
- }
- mActivity = (FragmentActivity)activity;
-
- super.onAttach(activity);
- }
-
- @Override
- public void onDetach() {
- mActivity = null;
- super.onDetach();
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- //Nothing to see here.
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- //Nothing to see here.
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- //Nothing to see here.
- return false;
- }
-}
\ No newline at end of file
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 1f091d5..1cb3233 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -20,30 +20,6 @@
package org.videolan.vlc.gui.video;
-import java.util.HashMap;
-import java.util.List;
-import java.util.concurrent.BrokenBarrierException;
-import java.util.concurrent.CyclicBarrier;
-
-import org.videolan.android.ui.SherlockGridFragment;
-import org.videolan.libvlc.LibVLC;
-import org.videolan.libvlc.LibVlcException;
-import org.videolan.libvlc.LibVlcUtil;
-import org.videolan.libvlc.Media;
-import org.videolan.libvlc.TrackInfo;
-import org.videolan.vlc.MediaDatabase;
-import org.videolan.vlc.MediaGroup;
-import org.videolan.vlc.MediaLibrary;
-import org.videolan.vlc.R;
-import org.videolan.vlc.Thumbnailer;
-import org.videolan.vlc.audio.AudioServiceController;
-import org.videolan.vlc.interfaces.IBrowser;
-import org.videolan.vlc.gui.CommonDialogs;
-import org.videolan.vlc.gui.MainActivity;
-import org.videolan.vlc.interfaces.ISortable;
-import org.videolan.vlc.util.Util;
-import org.videolan.vlc.util.VLCRunnable;
-
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
@@ -56,6 +32,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
+import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
@@ -71,6 +48,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
+import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.GridView;
import android.widget.LinearLayout;
@@ -78,7 +56,30 @@ import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.TextView;
-public class VideoGridFragment extends SherlockGridFragment implements IBrowser, ISortable, VideoBrowserInterface, SwipeRefreshLayout.OnRefreshListener {
+import org.videolan.libvlc.LibVLC;
+import org.videolan.libvlc.LibVlcException;
+import org.videolan.libvlc.LibVlcUtil;
+import org.videolan.libvlc.Media;
+import org.videolan.libvlc.TrackInfo;
+import org.videolan.vlc.MediaDatabase;
+import org.videolan.vlc.MediaGroup;
+import org.videolan.vlc.MediaLibrary;
+import org.videolan.vlc.R;
+import org.videolan.vlc.Thumbnailer;
+import org.videolan.vlc.audio.AudioServiceController;
+import org.videolan.vlc.gui.CommonDialogs;
+import org.videolan.vlc.gui.MainActivity;
+import org.videolan.vlc.interfaces.IBrowser;
+import org.videolan.vlc.interfaces.ISortable;
+import org.videolan.vlc.util.Util;
+import org.videolan.vlc.util.VLCRunnable;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+public class VideoGridFragment extends Fragment implements IBrowser, ISortable, VideoBrowserInterface, SwipeRefreshLayout.OnRefreshListener, AdapterView.OnItemClickListener {
public final static String TAG = "VLC/VideoListFragment";
@@ -94,6 +95,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
protected LinearLayout mLayoutFlipperLoading;
protected GridView mGridView;
protected TextView mTextViewNomedia;
+ protected View mViewNomedia;
protected Media mItemToUpdate;
protected String mGroup;
protected final CyclicBarrier mBarrier = new CyclicBarrier(2);
@@ -122,7 +124,6 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
mVideoAdapter = new VideoListAdapter(getActivity(), this);
mMediaLibrary = MediaLibrary.getInstance();
- setListAdapter(mVideoAdapter);
/* Load the thumbnailer */
FragmentActivity activity = getActivity();
@@ -134,8 +135,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
- {
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar();
if (mGroup == null)
actionBar.setTitle(R.string.video);
@@ -147,6 +147,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
// init the information for the scan (1/2)
mLayoutFlipperLoading = (LinearLayout) v.findViewById(R.id.layout_flipper_loading);
mTextViewNomedia = (TextView) v.findViewById(R.id.textview_nomedia);
+ mViewNomedia = v.findViewById(android.R.id.empty);
mGridView = (GridView) v.findViewById(android.R.id.list);
mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeLayout);
@@ -156,18 +157,21 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {}
+
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
mSwipeRefreshLayout.setEnabled(firstVisibleItem == 0);
}
});
+ mGridView.setAdapter(mVideoAdapter);
+ mGridView.setOnItemClickListener(this);
return v;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- registerForContextMenu(getGridView());
+ registerForContextMenu(mGridView);
// init the information for the scan (2/2)
IntentFilter filter = new IntentFilter();
@@ -179,7 +183,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
Util.actionScanStart();
}
- mAnimator = new VideoGridAnimator(getGridView());
+ mAnimator = new VideoGridAnimator(mGridView);
}
@Override
@@ -200,10 +204,11 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
final boolean refresh = mVideoAdapter.isEmpty();
if (refresh)
updateList();
+ else
+ mViewNomedia.setVisibility(View.GONE);
//Get & set times
HashMap<String, Long> times = MediaDatabase.getInstance().getVideoTimes(getActivity());
mVideoAdapter.setTimes(times);
- mVideoAdapter.notifyDataSetChanged();
mGridView.setSelection(mGVFirstVisiblePos);
updateViewMode();
if (refresh)
@@ -247,7 +252,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
sidePadding, mGridView.getPaddingBottom());
// Select between grid or list
- if (!listMode) {
+ if (!listMode) {
mGridView.setNumColumns(GridView.AUTO_FIT);
mGridView.setStretchMode(GRID_STRETCH_MODE);
mGridView.setColumnWidth(res.getDimensionPixelSize(R.dimen.grid_card_width));
@@ -275,8 +280,8 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
}
@Override
- public void onGridItemClick(GridView l, View v, int position, long id) {
- Media media = (Media) getListAdapter().getItem(position);
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ Media media = mVideoAdapter.getItem(position);
if (media instanceof MediaGroup) {
MainActivity activity = (MainActivity)getActivity();
VideoGridFragment frag = (VideoGridFragment)activity.showSecondaryFragment("videoGroupList");
@@ -286,7 +291,6 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
}
else
playVideo(media, false);
- super.onGridItemClick(l, v, position, id);
}
protected void playVideo(Media media, boolean fromStart) {
@@ -537,6 +541,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
+ mViewNomedia.setVisibility(mVideoAdapter.getCount()>0 ? View.GONE : View.VISIBLE);
mReady = true;
mVideoAdapter.sort();
mVideoAdapter.notifyDataSetChanged();
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 269f2e5..7d29359 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -73,13 +73,18 @@ public class VideoListAdapter extends ArrayAdapter<Media>
}
public void setTimes(HashMap<String, Long> times) {
+ boolean notify = false;
// update times
for (int i = 0; i < getCount(); ++i) {
Media media = getItem(i);
Long time = times.get(media.getLocation());
- if (time != null)
+ if (time != null) {
media.setTime(time);
+ notify = true;
+ }
}
+ if (notify)
+ notifyDataSetChanged();
}
public void sortBy(int sortby) {
--
2.1.0
More information about the Android
mailing list