diff --git a/src/com/onirica/carrousel/Configuration.java b/src/com/onirica/carrousel/Configuration.java index 83ced7f..c869291 100644 --- a/src/com/onirica/carrousel/Configuration.java +++ b/src/com/onirica/carrousel/Configuration.java @@ -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 matches = mResults.getMatches(); + } } \ No newline at end of file diff --git a/src/com/onirica/carrousel/Match.java b/src/com/onirica/carrousel/Match.java new file mode 100644 index 0000000..4f84555 --- /dev/null +++ b/src/com/onirica/carrousel/Match.java @@ -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 goals; + + public Match(String localTeam, String visitorTeam) { + this.localTeam = localTeam; + this.visitorTeam = visitorTeam; + state = State.MATCH_NO_STARTED; + min = 0; + goals = new ArrayList(); + } + + 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(); + } + + public void addGoal(Goal goal) { + goals.add(goal); + } + +} diff --git a/src/com/onirica/carrousel/Results.java b/src/com/onirica/carrousel/Results.java index ebab264..611af6b 100644 --- a/src/com/onirica/carrousel/Results.java +++ b/src/com/onirica/carrousel/Results.java @@ -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 getMatches() { + ArrayList matches = new ArrayList(); + + 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 } - } + } }