mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Added TaskListener interface
This commit is contained in:
parent
0a32db5c0b
commit
26ab3faf1e
1 changed files with 16 additions and 2 deletions
|
|
@ -44,6 +44,12 @@ public class NearbyListFragment extends ListFragment {
|
||||||
public NearbyListFragment() {
|
public NearbyListFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface TaskListener {
|
||||||
|
void onTaskStarted();
|
||||||
|
|
||||||
|
void onTaskFinished(List<Place> result);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
@ -77,12 +83,10 @@ public class NearbyListFragment extends ListFragment {
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
mLatestLocation = ((NearbyActivity) getActivity()).getmLatestLocation();
|
mLatestLocation = ((NearbyActivity) getActivity()).getmLatestLocation();
|
||||||
|
|
||||||
nearbyAsyncTask = new NearbyAsyncTask();
|
nearbyAsyncTask = new NearbyAsyncTask();
|
||||||
nearbyAsyncTask.execute();
|
nearbyAsyncTask.execute();
|
||||||
|
|
||||||
Log.d(TAG, "Adapter set to ListView");
|
Log.d(TAG, "Adapter set to ListView");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -91,10 +95,19 @@ public class NearbyListFragment extends ListFragment {
|
||||||
isTaskRunning = true;
|
isTaskRunning = true;
|
||||||
progressDialog = ProgressDialog.show(getActivity(), "Loading", "Please wait a moment!");
|
progressDialog = ProgressDialog.show(getActivity(), "Loading", "Please wait a moment!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NearbyAsyncTask extends AsyncTask<Void, Integer, List<Place>> {
|
private class NearbyAsyncTask extends AsyncTask<Void, Integer, List<Place>> {
|
||||||
|
|
||||||
|
private final TaskListener listener;
|
||||||
|
|
||||||
|
public NearbyAsyncTask (TaskListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
|
listener.onTaskStarted();
|
||||||
lockScreenOrientation();
|
lockScreenOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,6 +154,7 @@ public class NearbyListFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
listener.onTaskFinished(result);
|
||||||
mAdapter.notifyDataSetChanged();
|
mAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue