[Android] Fix loading view in audio browser
Geoffrey Métais
git at videolan.org
Mon Dec 22 19:14:47 CET 2014
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Dec 22 19:12:19 2014 +0100| [c62dfe3ecae4831e74191c8a8204f422679f5ca1] | committer: Geoffrey Métais
Fix loading view in audio browser
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=c62dfe3ecae4831e74191c8a8204f422679f5ca1
---
vlc-android/res/layout/audio_browser.xml | 9 ---------
.../videolan/vlc/gui/audio/AudioBrowserFragment.java | 18 ++++++------------
2 files changed, 6 insertions(+), 21 deletions(-)
diff --git a/vlc-android/res/layout/audio_browser.xml b/vlc-android/res/layout/audio_browser.xml
index 504e7db..8b33e26 100644
--- a/vlc-android/res/layout/audio_browser.xml
+++ b/vlc-android/res/layout/audio_browser.xml
@@ -73,15 +73,6 @@
android:layout_alignRight="@+id/header"
android:layout_alignTop="@+id/header"
android:background="?attr/header_fadeout_overlay" />
-
- <ProgressBar
- android:id="@+id/loading_view"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/header"
- android:indeterminate="true"
- android:layout_centerInParent="true"
- android:visibility="gone"/>
<TextView
android:id="@+id/no_media"
android:layout_width="fill_parent"
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index 55cf342..e71363c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -49,7 +49,6 @@ import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
-import android.widget.ProgressBar;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
@@ -85,7 +84,6 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
private AudioBrowserListAdapter mArtistsAdapter;
private AudioBrowserListAdapter mAlbumsAdapter;
private AudioBrowserListAdapter mGenresAdapter;
- private View mLoading;
private View mEmptyView;
@@ -141,7 +139,6 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
mHeader.setOnKeyListener(keyListener);
mEmptyView = v.findViewById(R.id.no_media);
- mLoading = (ProgressBar) v.findViewById(R.id.loading_view);
ListView songsList = (ListView)v.findViewById(R.id.songs_list);
ListView artistList = (ListView)v.findViewById(R.id.artists_list);
@@ -205,6 +202,8 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
mHeader.scroll(mFlingViewPosition / 3.f);
if (!mMediaLibrary.isWorking())
updateLists();
+ else
+ mHandler.sendEmptyMessageDelayed(MSG_LOADING, 300);
mMediaLibrary.addUpdateHandler(mHandler);
}
@@ -478,10 +477,7 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
@Override
public void setReadyToDisplay(boolean ready) {
- if (mLoading != null && mLoading.getVisibility() == View.VISIBLE)
- display();
- else
- mReadyToDisplay = ready;
+ mReadyToDisplay = ready;
}
@Override
@@ -491,9 +487,6 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
- mSwipeRefreshLayout.setRefreshing(false);
- mHandler.removeMessages(MSG_LOADING);
- mLoading.setVisibility(View.GONE);
mArtistsAdapter.notifyDataSetChanged();
mSongsAdapter.notifyDataSetChanged();
mAlbumsAdapter.notifyDataSetChanged();
@@ -509,6 +502,8 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
}
}
focusHelper(false, R.id.artists_list);
+ mHandler.removeMessages(MSG_LOADING);
+ mSwipeRefreshLayout.setRefreshing(false);
}
});
}
@@ -528,8 +523,7 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
fragment.updateLists();
break;
case MSG_LOADING:
- if (!fragment.mReadyToDisplay)
- fragment.mLoading.setVisibility(View.VISIBLE);
+ fragment.mSwipeRefreshLayout.setRefreshing(true);
}
}
};
More information about the Android
mailing list