diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-04-27 21:26:04 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-04-27 21:26:04 -0700 |
commit | 474371b879640121732a5803154878736dc1462d (patch) | |
tree | eb5b0cf56d42a2f8389e1cd19ea5a0107bfdcc60 /src/github | |
parent | 47e224b3e4ba01ad0d4e1eaff7f0a04ce5279c65 (diff) | |
download | dsub-474371b879640121732a5803154878736dc1462d.tar.gz dsub-474371b879640121732a5803154878736dc1462d.tar.bz2 dsub-474371b879640121732a5803154878736dc1462d.zip |
Fix pull being triggered if exactly on child's top
Diffstat (limited to 'src/github')
5 files changed, 19 insertions, 52 deletions
diff --git a/src/github/daneren2005/dsub/fragments/ChatFragment.java b/src/github/daneren2005/dsub/fragments/ChatFragment.java index 3e53f2ad..f017b632 100644 --- a/src/github/daneren2005/dsub/fragments/ChatFragment.java +++ b/src/github/daneren2005/dsub/fragments/ChatFragment.java @@ -131,17 +131,7 @@ public class ChatFragment extends SubsonicFragment { refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_layout);
refreshLayout.setOnRefreshListener(this);
-
- chatListView.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {}
-
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- int topRowVerticalPosition = (chatListView.getChildCount() == 0) ? 0 : chatListView.getChildAt(0).getTop();
- refreshLayout.setEnabled(topRowVerticalPosition >= 0);
- }
- });
+ setupScrollList(chatListView);
return rootView;
}
diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java index 9fc35cd2..0029e53a 100644 --- a/src/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java @@ -126,16 +126,7 @@ public class SearchFragment extends SubsonicFragment { }
});
registerForContextMenu(list);
- list.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {}
-
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- int topRowVerticalPosition = (list.getChildCount() == 0) ? 0 : list.getChildAt(0).getTop();
- refreshLayout.setEnabled(topRowVerticalPosition >= 0);
- }
- });
+ setupScrollList(list);
context.onNewIntent(context.getIntent());
if(searchResult != null) {
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 73a67592..1ff43b0d 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -134,17 +134,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter entryList = (ListView) rootView.findViewById(R.id.select_album_entries);
entryList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
entryList.setOnItemClickListener(this);
-
- entryList.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {}
-
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- int topRowVerticalPosition = (entryList.getChildCount() == 0) ? 0 : entryList.getChildAt(0).getTop();
- refreshLayout.setEnabled(topRowVerticalPosition >= 0);
- }
- });
+ setupScrollList(entryList);
if(albumListType == null || "starred".equals(albumListType)) {
albumList = (GridView) inflater.inflate(R.layout.unscrollable_grid_view, entryList, false);
@@ -155,16 +145,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter rootGroup.removeView(entryList);
rootGroup.addView(albumList);
- albumList.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {}
-
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- int topRowVerticalPosition = (albumList.getChildCount() == 0) ? 0 : albumList.getChildAt(0).getTop();
- refreshLayout.setEnabled(topRowVerticalPosition >= 0);
- }
- });
+ setupScrollList(albumList);
}
albumList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
diff --git a/src/github/daneren2005/dsub/fragments/SelectListFragment.java b/src/github/daneren2005/dsub/fragments/SelectListFragment.java index 35bf95c1..4938fb3b 100644 --- a/src/github/daneren2005/dsub/fragments/SelectListFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectListFragment.java @@ -82,16 +82,7 @@ public abstract class SelectListFragment<T> extends SubsonicFragment implements listView = (ListView)rootView.findViewById(R.id.fragment_list);
listView.setOnItemClickListener(this);
- listView.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {}
-
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- int topRowVerticalPosition = (listView.getChildCount() == 0) ? 0 : listView.getChildAt(0).getTop();
- refreshLayout.setEnabled(topRowVerticalPosition >= 0);
- }
- });
+ setupScrollList(listView);
registerForContextMenu(listView);
emptyView = rootView.findViewById(R.id.fragment_list_empty);
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 45ab87e5..49d6f5a2 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -38,6 +38,7 @@ import android.view.Menu; import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.widget.AbsListView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
@@ -460,6 +461,19 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR return this.title;
}
+ protected void setupScrollList(final AbsListView listView) {
+ listView.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {}
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ int topRowVerticalPosition = (listView.getChildCount() == 0) ? 0 : listView.getChildAt(0).getTop();
+ refreshLayout.setEnabled(topRowVerticalPosition >= 0 && listView.getFirstVisiblePosition() == 0);
+ }
+ });
+ }
+
protected void warnIfNetworkOrStorageUnavailable() {
if (!Util.isExternalStoragePresent()) {
Util.toast(context, R.string.select_album_no_sdcard);
|