mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Add indeterminate progress bar
This commit is contained in:
parent
9cea643faa
commit
344b9a50eb
3 changed files with 25 additions and 16 deletions
|
|
@ -34,6 +34,7 @@ public class NearbyListFragment extends ListFragment {
|
|||
|
||||
private List<Place> places;
|
||||
private LatLng mLatestLocation;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
private static final String TAG = "NearbyListFragment";
|
||||
|
||||
|
|
@ -45,10 +46,14 @@ public class NearbyListFragment extends ListFragment {
|
|||
Bundle savedInstanceState) {
|
||||
|
||||
Log.d(TAG, "NearbyListFragment created");
|
||||
|
||||
View view = inflater.inflate(R.layout.fragment_nearby, container, false);
|
||||
return view;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
|
||||
/*
|
||||
// Create a progress bar to display while the list loads
|
||||
ProgressBar progressBar = new ProgressBar(getActivity());
|
||||
progressBar.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
|
|
@ -59,15 +64,10 @@ public class NearbyListFragment extends ListFragment {
|
|||
ViewGroup root = (ViewGroup) view.getRootView();
|
||||
root.addView(progressBar);
|
||||
*/
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
|
||||
//Load from data source (NearbyPlaces.java)
|
||||
progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
|
||||
progressBar.setMax(10);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(0);
|
||||
|
||||
mLatestLocation = ((NearbyActivity) getActivity()).getmLatestLocation();
|
||||
//Hardcoding mLatestLocation to Michigan for testing
|
||||
|
|
@ -100,7 +100,7 @@ public class NearbyListFragment extends ListFragment {
|
|||
);
|
||||
}
|
||||
|
||||
for(int i = 0; i < places.size(); i++) {
|
||||
for(int i = 0; i < 500; i++) {
|
||||
Place place = places.get(i);
|
||||
String distance = formatDistanceBetween(mLatestLocation, place.location);
|
||||
System.out.println("Sorted " + place.name + " at " + distance + " away.");
|
||||
|
|
@ -109,15 +109,16 @@ public class NearbyListFragment extends ListFragment {
|
|||
return places;
|
||||
}
|
||||
|
||||
private class getNearbyPlaces extends AsyncTask<Void, String, List<Place>> {
|
||||
private class getNearbyPlaces extends AsyncTask<Void, Integer, List<Place>> {
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(String... values) {
|
||||
protected void onProgressUpdate(Integer... values) {
|
||||
super.onProgressUpdate(values);
|
||||
progressBar.setProgress(values[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -132,6 +133,8 @@ public class NearbyListFragment extends ListFragment {
|
|||
|
||||
mAdapter = new NearbyAdapter(getActivity(), places);
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
||||
ListView listview = (ListView) getView().findViewById(R.id.listview);
|
||||
//setListAdapter(mAdapter);
|
||||
listview.setAdapter(mAdapter);
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ public class NearbyPlaces {
|
|||
int counter = 0;
|
||||
|
||||
//TODO: Remove limit of lines after get AsyncTask done
|
||||
//while ((line = in.readLine()) != null) {
|
||||
while (in.readLine() != null && counter < 500) {
|
||||
while ((line = in.readLine()) != null) {
|
||||
//while (in.readLine() != null && counter < 1000) {
|
||||
|
||||
line = in.readLine();
|
||||
counter++;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listview"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue