Fix layout

This commit is contained in:
Victor Shcherb 2014-06-09 14:56:06 +02:00
parent 72101325e8
commit 0d75998f70
3 changed files with 37 additions and 23 deletions

View file

@ -23,8 +23,7 @@
android:layout_width="25dp" android:layout_width="25dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:paddingRight="2dp" android:layout_marginTop="2dp" />
android:paddingTop="2dp" />
<TextView <TextView
android:id="@+id/additional" android:id="@+id/additional"
@ -32,8 +31,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:paddingRight="4dp" android:layout_marginRight="3dp"
android:paddingTop="2dp" > android:layout_marginLeft="2dp" >
</TextView> </TextView>
</FrameLayout> </FrameLayout>

View file

@ -21,6 +21,8 @@ public class OsmAndFormatter {
{ {
fixed2.setMinimumFractionDigits(2); fixed2.setMinimumFractionDigits(2);
fixed1.setMinimumFractionDigits(1); fixed1.setMinimumFractionDigits(1);
fixed1.setMinimumIntegerDigits(1);
fixed2.setMinimumIntegerDigits(1);
} }
public static double calculateRoundedDist(double distInMeters, OsmandApplication ctx) { public static double calculateRoundedDist(double distInMeters, OsmandApplication ctx) {

View file

@ -52,9 +52,6 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
collator.setStrength(Collator.SECONDARY); collator.setStrength(Collator.SECONDARY);
app = (OsmandApplication) activity.getApplication(); app = (OsmandApplication) activity.getApplication();
selectedGpxHelper = app.getSelectedGpxHelper(); selectedGpxHelper = app.getSelectedGpxHelper();
adapter = new SelectedGPXAdapter();
setAdapter(adapter);
} }
@Override @Override
@ -62,7 +59,10 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
super.onResume(); super.onResume();
getListView().setFastScrollEnabled(true); getListView().setFastScrollEnabled(true);
lightContent = app.getSettings().isLightContent(); lightContent = app.getSettings().isLightContent();
adapter.setView(getExpandableListView()); if (adapter == null) {
adapter = new SelectedGPXAdapter(getListView());
setAdapter(adapter);
}
adapter.setDisplayGroups(selectedGpxHelper.getDisplayGroups()); adapter.setDisplayGroups(selectedGpxHelper.getDisplayGroups());
selectedGpxHelper.setUiListener(new Runnable() { selectedGpxHelper.setUiListener(new Runnable() {
@ -213,13 +213,12 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
private List<GpxDisplayGroup> displayGroups = new ArrayList<GpxDisplayGroup>(); private List<GpxDisplayGroup> displayGroups = new ArrayList<GpxDisplayGroup>();
private ExpandableListView expandableListView; private ExpandableListView expandableListView;
private boolean manualScroll; private boolean manualScroll;
private int maxNumberOfSections = 1;
public SelectedGPXAdapter(){ public SelectedGPXAdapter(ExpandableListView lv) {
} this.expandableListView = lv;
this.expandableListView.setOnScrollListener(this);
public void setView(ExpandableListView lv) {
this.expandableListView = lv;
this.expandableListView.setOnScrollListener(this);
} }
@Override @Override
@ -238,28 +237,42 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
if (manualScroll) { if (manualScroll) {
return section; return section;
} else { } else {
return expandableListView.getFlatListPosition( // return expandableListView.getFlatListPosition(
ExpandableListView.getPackedPositionForGroup(section)); // ExpandableListView.getPackedPositionForGroup(section));
return section * maxNumberOfSections;
} }
} }
// Gets called when scrolling the list manually // Gets called when scrolling the list manually
@Override @Override
public int getSectionForPosition(int position) { public int getSectionForPosition(int position) {
return ExpandableListView.getPackedPositionGroup( // Get the packed position of the provided flat one and find the corresponding group
expandableListView // return ExpandableListView.getPackedPositionChild(expandableListView
.getExpandableListPosition(position)); // .getExpandableListPosition(position));
return position / maxNumberOfSections;
} }
@Override
public Object[] getSections() {
int total = getGroupCount();
for(int i = 0; i < getGroupCount(); i++) {
if(expandableListView.isGroupExpanded(i)) {
total += getChildrenCount(i);
}
}
maxNumberOfSections = Math.max(1, Math.min(25, total));
String[] ar = new String[maxNumberOfSections];
for(int i = 0; i < ar.length; i++) {
ar[i] = ((i + 1) * 100 / maxNumberOfSections) + "%";
}
return ar;
}
public void setDisplayGroups(List<GpxDisplayGroup> displayGroups) { public void setDisplayGroups(List<GpxDisplayGroup> displayGroups) {
this.displayGroups = displayGroups; this.displayGroups = displayGroups;
notifyDataSetChanged(); notifyDataSetChanged();
} }
@Override
public Object[] getSections() {
return null;
}