1
0
mirror of https://github.com/balkian/Carrousel-Android.git synced 2024-12-22 21:18:13 +00:00

Iteracion 5: Match y getMaches.

This commit is contained in:
Fernando Herrera 2011-03-09 23:33:35 +01:00
parent 98e7c5208b
commit 698302cccc
3 changed files with 81 additions and 6 deletions

View File

@ -1,5 +1,7 @@
package com.onirica.carrousel;
import java.util.ArrayList;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
@ -9,26 +11,31 @@ import android.os.IBinder;
public class Configuration extends Activity {
private Results mResults;
private Intent intent;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = new Intent(getBaseContext(), Results.class);
intent = new Intent(getBaseContext(), Results.class);
startService(intent);
ServiceConnection conn = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
mResults = ((Results.LocalBinder)service).getService();
populateMatches();
}
@Override
public void onServiceDisconnected(ComponentName className) {
mResults = null;
stopService(intent);
finish();
}
};
bindService(intent, conn, BIND_AUTO_CREATE);
}
private void populateMatches() {
ArrayList<Match> matches = mResults.getMatches();
}
}

View File

@ -0,0 +1,50 @@
package com.onirica.carrousel;
import java.util.ArrayList;
public class Match {
public class Goal {
public int min;
public boolean isLocal;
public String who;
public Goal (int min, boolean isLocal, String who) {
this.min = min;
this.isLocal = isLocal;
this.who = who;
}
}
public enum State {
MATCH_NO_STARTED,
MATCH_FIRST_ROUND,
MATCH_HALF_TIME,
MATCH_SECOND_ROUND,
MATCH_ENDED;
}
public String localTeam;
public String visitorTeam;
public State state;
public int min;
public ArrayList<Goal> goals;
public Match(String localTeam, String visitorTeam) {
this.localTeam = localTeam;
this.visitorTeam = visitorTeam;
state = State.MATCH_NO_STARTED;
min = 0;
goals = new ArrayList<Goal>();
}
public Match(String localTeam, String visitorTeam, State state, int min) {
this.localTeam = localTeam;
this.visitorTeam = visitorTeam;
this.state = state;
this.min = min;
goals = new ArrayList<Goal>();
}
public void addGoal(Goal goal) {
goals.add(goal);
}
}

View File

@ -1,5 +1,6 @@
package com.onirica.carrousel;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
@ -25,13 +26,30 @@ public class Results extends Service {
pollingTask task = new pollingTask();
Timer timer = new Timer(true);
timer.scheduleAtFixedRate(task, 0, 60000);
}
}
public ArrayList<Match> getMatches() {
ArrayList<Match> matches = new ArrayList<Match>();
Match match = new Match("Deportivo", "Atelico de Madrid");
matches.add(match);
match = new Match("Betis", "Sevilla");
matches.add(match);
match = new Match("Madrid", "Barcelona", Match.State.MATCH_FIRST_ROUND, 13);
Match.Goal goal = match.new Goal(12, true, "Cristiano Ronaldo");
match.addGoal(goal);
matches.add(match);
return matches;
}
private class pollingTask extends TimerTask {
private class pollingTask extends TimerTask {
@Override
public void run() {
// Aqui descargaremos los resultados
}
}
}
}