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:
parent
98e7c5208b
commit
698302cccc
@ -1,5 +1,7 @@
|
|||||||
package com.onirica.carrousel;
|
package com.onirica.carrousel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -9,26 +11,31 @@ import android.os.IBinder;
|
|||||||
|
|
||||||
public class Configuration extends Activity {
|
public class Configuration extends Activity {
|
||||||
private Results mResults;
|
private Results mResults;
|
||||||
|
private Intent intent;
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
Intent intent = new Intent(getBaseContext(), Results.class);
|
intent = new Intent(getBaseContext(), Results.class);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
ServiceConnection conn = new ServiceConnection() {
|
ServiceConnection conn = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||||
mResults = ((Results.LocalBinder)service).getService();
|
mResults = ((Results.LocalBinder)service).getService();
|
||||||
|
populateMatches();
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName className) {
|
public void onServiceDisconnected(ComponentName className) {
|
||||||
mResults = null;
|
mResults = null;
|
||||||
|
stopService(intent);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
bindService(intent, conn, BIND_AUTO_CREATE);
|
bindService(intent, conn, BIND_AUTO_CREATE);
|
||||||
}
|
}
|
||||||
|
private void populateMatches() {
|
||||||
|
ArrayList<Match> matches = mResults.getMatches();
|
||||||
|
}
|
||||||
}
|
}
|
50
src/com/onirica/carrousel/Match.java
Normal file
50
src/com/onirica/carrousel/Match.java
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.onirica.carrousel;
|
package com.onirica.carrousel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
@ -27,6 +28,23 @@ public class Results extends Service {
|
|||||||
timer.scheduleAtFixedRate(task, 0, 60000);
|
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
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
Loading…
Reference in New Issue
Block a user