1
0
mirror of https://github.com/balkian/Carrousel-Android.git synced 2024-12-23 05:28:13 +00:00
Carrousel-Android/src/com/onirica/carrousel/Configuration.java

64 lines
2.2 KiB
Java
Raw Normal View History

2011-03-09 21:41:31 +00:00
package com.onirica.carrousel;
2011-03-09 22:33:35 +00:00
import java.util.ArrayList;
2011-03-09 21:41:31 +00:00
import android.app.Activity;
2011-03-09 22:56:52 +00:00
import android.app.ListActivity;
2011-03-09 22:41:02 +00:00
import android.app.ProgressDialog;
import android.content.ComponentName;
2011-03-09 22:41:02 +00:00
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
2011-03-09 21:41:31 +00:00
import android.os.Bundle;
import android.os.IBinder;
2011-03-09 22:56:52 +00:00
import android.widget.ArrayAdapter;
2011-03-09 21:41:31 +00:00
2011-03-09 22:56:52 +00:00
public class Configuration extends ListActivity {
private Results mResults;
2011-03-09 22:33:35 +00:00
private Intent intent;
2011-03-09 22:41:02 +00:00
private ProgressDialog progressDialog;
2011-03-09 21:41:31 +00:00
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
2011-03-09 22:33:35 +00:00
intent = new Intent(getBaseContext(), Results.class);
startService(intent);
2011-03-09 23:05:11 +00:00
setContentView(R.layout.main);
ServiceConnection conn = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
mResults = ((Results.LocalBinder)service).getService();
2011-03-09 22:33:35 +00:00
populateMatches();
2011-03-09 22:41:02 +00:00
progressDialog.dismiss();
}
@Override
public void onServiceDisconnected(ComponentName className) {
mResults = null;
2011-03-09 22:33:35 +00:00
stopService(intent);
finish();
}
};
bindService(intent, conn, BIND_AUTO_CREATE);
2011-03-09 22:41:02 +00:00
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Retrieving match list");
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(true);
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
//Log.i(TAG, "dialog cancel has been invoked");
stopService(intent);
finish();
}
});
progressDialog.show();
2011-03-09 21:41:31 +00:00
}
2011-03-09 22:33:35 +00:00
private void populateMatches() {
ArrayList<Match> matches = mResults.getMatches();
2011-03-09 22:56:52 +00:00
Match[] ms = new Match[matches.size()];
matches.toArray(ms);
ArrayAdapter<Match> adapter = new ArrayAdapter<Match>(this, R.layout.list_item, ms);
setListAdapter(adapter);
2011-03-09 22:33:35 +00:00
}
2011-03-09 21:41:31 +00:00
}