Fix fast scroll

This commit is contained in:
Victor Shcherb 2014-06-09 15:05:44 +02:00
parent 0d75998f70
commit e2406d4ea4

View file

@ -214,6 +214,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
private ExpandableListView expandableListView; private ExpandableListView expandableListView;
private boolean manualScroll; private boolean manualScroll;
private int maxNumberOfSections = 1; private int maxNumberOfSections = 1;
private double positionsInGroup;
public SelectedGPXAdapter(ExpandableListView lv) { public SelectedGPXAdapter(ExpandableListView lv) {
this.expandableListView = lv; this.expandableListView = lv;
@ -239,7 +240,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
} else { } else {
// return expandableListView.getFlatListPosition( // return expandableListView.getFlatListPosition(
// ExpandableListView.getPackedPositionForGroup(section)); // ExpandableListView.getPackedPositionForGroup(section));
return section * maxNumberOfSections; return (int) (section * positionsInGroup);
} }
} }
@ -249,7 +250,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
// Get the packed position of the provided flat one and find the corresponding group // Get the packed position of the provided flat one and find the corresponding group
// return ExpandableListView.getPackedPositionChild(expandableListView // return ExpandableListView.getPackedPositionChild(expandableListView
// .getExpandableListPosition(position)); // .getExpandableListPosition(position));
return position / maxNumberOfSections; return Math.min(maxNumberOfSections - 1, (int) (position / positionsInGroup));
} }
@Override @Override
public Object[] getSections() { public Object[] getSections() {
@ -260,6 +261,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
} }
} }
maxNumberOfSections = Math.max(1, Math.min(25, total)); maxNumberOfSections = Math.max(1, Math.min(25, total));
positionsInGroup = ((double)total) / maxNumberOfSections;
String[] ar = new String[maxNumberOfSections]; String[] ar = new String[maxNumberOfSections];
for(int i = 0; i < ar.length; i++) { for(int i = 0; i < ar.length; i++) {
ar[i] = ((i + 1) * 100 / maxNumberOfSections) + "%"; ar[i] = ((i + 1) * 100 / maxNumberOfSections) + "%";