Fixed ArrayAdapter.addAll for 2.3

This commit is contained in:
Alexey Kulish 2016-02-26 10:42:08 +03:00
parent c34024f7f4
commit 28a0f59bb5
7 changed files with 32 additions and 10 deletions

View file

@ -67,7 +67,9 @@ public class ActiveDownloadsDialogFragment extends DialogFragment implements Dow
if(items.isEmpty()) { if(items.isEmpty()) {
dlgFragment.dismissAllowingStateLoss(); dlgFragment.dismissAllowingStateLoss();
} }
addAll(context.getDownloadThread().getCurrentDownloadingItems()); for (IndexItem item : context.getDownloadThread().getCurrentDownloadingItems()) {
add(item);
}
} }
@Override @Override

View file

@ -62,7 +62,9 @@ public class CountrySelectionFragment extends BaseOsmAndDialogFragment {
ListView listView = (ListView) view.findViewById(android.R.id.list); ListView listView = (ListView) view.findViewById(android.R.id.list);
final ArrayAdapter<CountryItem> adapter = new ListAdapter(getListItemIcon()); final ArrayAdapter<CountryItem> adapter = new ListAdapter(getListItemIcon());
if (countryItems.size() > 0) { if (countryItems.size() > 0) {
adapter.addAll(countryItems); for (CountryItem item : countryItems) {
adapter.add(item);
}
} }
listView.setAdapter(adapter); listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

View file

@ -31,9 +31,13 @@ public abstract class SearchSelectionFragment extends BaseOsmAndDialogFragment {
ListView listView = (ListView) view.findViewById(android.R.id.list); ListView listView = (ListView) view.findViewById(android.R.id.list);
final ArrayAdapter<String> adapter = new ListAdapter(getActivity(), getListItemIcon()); final ArrayAdapter<String> adapter = new ListAdapter(getActivity(), getListItemIcon());
if (getArray() != null) { if (getArray() != null) {
adapter.addAll(getArray()); for (String s : getArray()) {
adapter.add(s);
}
} else if (getList() != null) { } else if (getList() != null) {
adapter.addAll(getList()); for (String s : getList()) {
adapter.add(s);
}
} else { } else {
throw new RuntimeException("Either getArray() or getList() must return non null value."); throw new RuntimeException("Either getArray() or getList() must return non null value.");
} }

View file

@ -41,7 +41,11 @@ public class UsersReportFragment extends BaseOsmAndDialogFragment {
@Override @Override
public void onResponse(RankingUserByMonthResponse response) { public void onResponse(RankingUserByMonthResponse response) {
adapter.addAll(Arrays.asList(response.rows)); if (response != null && response.rows != null) {
for (UserRankingByMonth rankingByMonth : response.rows) {
adapter.add(rankingByMonth);
}
}
view.findViewById(R.id.progress).setVisibility(View.GONE); view.findViewById(R.id.progress).setVisibility(View.GONE);
} }
}); });

View file

@ -676,7 +676,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
final Spinner fromSpinner = ((Spinner) view.findViewById(R.id.FromSpinner)); final Spinner fromSpinner = ((Spinner) view.findViewById(R.id.FromSpinner));
RouteSpinnerArrayAdapter fromAdapter = new RouteSpinnerArrayAdapter(view.getContext()); RouteSpinnerArrayAdapter fromAdapter = new RouteSpinnerArrayAdapter(view.getContext());
fromAdapter.addAll(fromActions); for (RouteSpinnerRow row : fromActions) {
fromAdapter.add(row);
}
fromSpinner.setAdapter(fromAdapter); fromSpinner.setAdapter(fromAdapter);
if (start != null) { if (start != null) {
fromSpinner.setSelection(startPos); fromSpinner.setSelection(startPos);
@ -730,7 +732,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
addMarkersToSpinner(toActions); addMarkersToSpinner(toActions);
RouteSpinnerArrayAdapter toAdapter = new RouteSpinnerArrayAdapter(view.getContext()); RouteSpinnerArrayAdapter toAdapter = new RouteSpinnerArrayAdapter(view.getContext());
toAdapter.addAll(toActions); for (RouteSpinnerRow row : toActions) {
toAdapter.add(row);
}
toSpinner.setAdapter(toAdapter); toSpinner.setAdapter(toAdapter);
return toSpinner; return toSpinner;
} }

View file

@ -86,7 +86,9 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
final ArrayAdapter<MapMarker> adapter = new MapMarkersListAdapter(); final ArrayAdapter<MapMarker> adapter = new MapMarkersListAdapter();
List<MapMarker> markers = getMyApplication().getMapMarkersHelper().getActiveMapMarkers(); List<MapMarker> markers = getMyApplication().getMapMarkersHelper().getActiveMapMarkers();
if (markers.size() > 0) { if (markers.size() > 0) {
adapter.addAll(markers); for (MapMarker marker : markers) {
adapter.add(marker);
}
} }
listView.setAdapter(adapter); listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

View file

@ -250,14 +250,18 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
public void setTagData(String[] tags) { public void setTagData(String[] tags) {
tagAdapter.clear(); tagAdapter.clear();
tagAdapter.addAll(tags); for (String s : tags) {
tagAdapter.add(s);
}
tagAdapter.sort(String.CASE_INSENSITIVE_ORDER); tagAdapter.sort(String.CASE_INSENSITIVE_ORDER);
tagAdapter.notifyDataSetChanged(); tagAdapter.notifyDataSetChanged();
} }
public void setValueData(String[] values) { public void setValueData(String[] values) {
valueAdapter.clear(); valueAdapter.clear();
valueAdapter.addAll(values); for (String s : values) {
valueAdapter.add(s);
}
valueAdapter.sort(String.CASE_INSENSITIVE_ORDER); valueAdapter.sort(String.CASE_INSENSITIVE_ORDER);
valueAdapter.notifyDataSetChanged(); valueAdapter.notifyDataSetChanged();
} }