mirror of
https://github.com/balkian/Carrousel-Android.git
synced 2024-12-22 04:58:13 +00:00
Primer commit, no carga la lista de equipos
This commit is contained in:
parent
7c1e616981
commit
3be0993d1d
12
.settings/org.eclipse.jdt.core.prefs
Normal file
12
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,12 @@
|
||||
#Thu Mar 24 20:11:09 CET 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
@ -15,6 +15,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<service android:name="Results"></service>
|
||||
<activity android:name="SelectTeam"></activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
BIN
bin/Carrousel.apk
Normal file
BIN
bin/Carrousel.apk
Normal file
Binary file not shown.
BIN
bin/classes.dex
Normal file
BIN
bin/classes.dex
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Configuration$1.class
Normal file
BIN
bin/com/onirica/carrousel/Configuration$1.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Configuration$2.class
Normal file
BIN
bin/com/onirica/carrousel/Configuration$2.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Configuration$3.class
Normal file
BIN
bin/com/onirica/carrousel/Configuration$3.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Configuration$4.class
Normal file
BIN
bin/com/onirica/carrousel/Configuration$4.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/com/onirica/carrousel/Configuration$MatchAdapter.class
Normal file
BIN
bin/com/onirica/carrousel/Configuration$MatchAdapter.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Configuration$MatchView$1.class
Normal file
BIN
bin/com/onirica/carrousel/Configuration$MatchView$1.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Configuration$MatchView.class
Normal file
BIN
bin/com/onirica/carrousel/Configuration$MatchView.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Configuration.class
Normal file
BIN
bin/com/onirica/carrousel/Configuration.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Match$Goal.class
Normal file
BIN
bin/com/onirica/carrousel/Match$Goal.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Match$State.class
Normal file
BIN
bin/com/onirica/carrousel/Match$State.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Match.class
Normal file
BIN
bin/com/onirica/carrousel/Match.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/R$attr.class
Normal file
BIN
bin/com/onirica/carrousel/R$attr.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/R$color.class
Normal file
BIN
bin/com/onirica/carrousel/R$color.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/R$drawable.class
Normal file
BIN
bin/com/onirica/carrousel/R$drawable.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/R$id.class
Normal file
BIN
bin/com/onirica/carrousel/R$id.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/R$layout.class
Normal file
BIN
bin/com/onirica/carrousel/R$layout.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/R$menu.class
Normal file
BIN
bin/com/onirica/carrousel/R$menu.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/R$string.class
Normal file
BIN
bin/com/onirica/carrousel/R$string.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/R.class
Normal file
BIN
bin/com/onirica/carrousel/R.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Results$LocalBinder.class
Normal file
BIN
bin/com/onirica/carrousel/Results$LocalBinder.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Results$pollingTask.class
Normal file
BIN
bin/com/onirica/carrousel/Results$pollingTask.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Results.class
Normal file
BIN
bin/com/onirica/carrousel/Results.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/SelectTeam$TeamAdapter$TeamView.class
Normal file
BIN
bin/com/onirica/carrousel/SelectTeam$TeamAdapter$TeamView.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/SelectTeam$TeamAdapter.class
Normal file
BIN
bin/com/onirica/carrousel/SelectTeam$TeamAdapter.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/SelectTeam.class
Normal file
BIN
bin/com/onirica/carrousel/SelectTeam.class
Normal file
Binary file not shown.
BIN
bin/com/onirica/carrousel/Team.class
Normal file
BIN
bin/com/onirica/carrousel/Team.class
Normal file
Binary file not shown.
BIN
bin/resources.ap_
Normal file
BIN
bin/resources.ap_
Normal file
Binary file not shown.
37
gen/com/onirica/carrousel/R.java
Normal file
37
gen/com/onirica/carrousel/R.java
Normal file
@ -0,0 +1,37 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package com.onirica.carrousel;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class color {
|
||||
public static final int transparent=0x7f040000;
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int icon=0x7f020000;
|
||||
public static final int realmadrid=0x7f020001;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int quit=0x7f070001;
|
||||
public static final int select_team=0x7f070002;
|
||||
public static final int subscribe=0x7f070000;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int list_item=0x7f030000;
|
||||
public static final int main=0x7f030001;
|
||||
public static final int team_selector=0x7f030002;
|
||||
}
|
||||
public static final class menu {
|
||||
public static final int configuration_menu=0x7f060000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f050001;
|
||||
public static final int hello=0x7f050000;
|
||||
}
|
||||
}
|
BIN
res/drawable-hdpi/realmadrid.png
Normal file
BIN
res/drawable-hdpi/realmadrid.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
@ -10,16 +10,14 @@
|
||||
<ListView android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:drawSelectorOnTop="false"/>
|
||||
android:drawSelectorOnTop="false"
|
||||
android:cacheColorHint="#00000000"
|
||||
/>
|
||||
</FrameLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_height="wrap_content" android:layout_width="match_parent">
|
||||
|
||||
<Button android:id="@+id/subscribe"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Subscribe to selected matches"/>
|
||||
<Button android:layout_width="wrap_content" android:text="Subscribe to selected matches" android:layout_height="wrap_content" android:id="@+id/subscribe"></Button>
|
||||
|
||||
<Button android:id="@+id/quit"
|
||||
android:layout_height="wrap_content"
|
||||
|
18
res/layout/team_selector.xml
Normal file
18
res/layout/team_selector.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1" >
|
||||
<ListView android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:drawSelectorOnTop="false"
|
||||
android:cacheColorHint="#00000000"
|
||||
/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
5
res/menu/configuration_menu.xml
Normal file
5
res/menu/configuration_menu.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:enabled="true" android:title="Select Team" android:visible="true" android:id="@+id/select_team"></item>
|
||||
</menu>
|
4
res/values/colors.xml
Normal file
4
res/values/colors.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="transparent">#fff00000</color>
|
||||
</resources>
|
@ -1,10 +1,8 @@
|
||||
package com.onirica.carrousel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ListActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ComponentName;
|
||||
@ -14,10 +12,12 @@ import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
@ -38,8 +38,9 @@ public class Configuration extends ListActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
intent = new Intent(getBaseContext(), Results.class);
|
||||
startService(intent);
|
||||
startService(intent);
|
||||
setContentView(R.layout.main);
|
||||
this.getWindow().setBackgroundDrawableResource(R.drawable.realmadrid);
|
||||
conn = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||
@ -89,7 +90,33 @@ public class Configuration extends ListActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
private void close() {
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.configuration_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle item selection
|
||||
switch (item.getItemId()) {
|
||||
case R.id.select_team:
|
||||
showSelect();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void showSelect() {
|
||||
//TODO
|
||||
Intent intent = new Intent(this, SelectTeam.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void close() {
|
||||
unbindService(conn);
|
||||
finish();
|
||||
}
|
||||
@ -114,6 +141,8 @@ public class Configuration extends ListActivity {
|
||||
public MatchView(Context context, String text, boolean isChecked) {
|
||||
super(context);
|
||||
this.setOrientation(HORIZONTAL);
|
||||
this.setBackgroundColor(R.color.transparent);
|
||||
|
||||
mTv = new TextView(context);
|
||||
mTv.setText(text);
|
||||
mCb = new CheckBox(context);
|
||||
@ -167,7 +196,9 @@ public class Configuration extends ListActivity {
|
||||
MatchView v;
|
||||
Match match = mMatches[pos];
|
||||
boolean isSubscribed = subscribedMatches.contains(match.getId());
|
||||
|
||||
if(match.localTeam.equals("Real Madrid")||match.visitorTeam.equals("Real Madrid")){
|
||||
isSubscribed=true;
|
||||
}
|
||||
if (convertView == null) {
|
||||
; v = new MatchView(parent.getContext(), match.toString(), isSubscribed);
|
||||
v.setOnMatchCheckedChanged(new OnMatchCheckedListener(pos));
|
||||
|
@ -66,7 +66,7 @@ public class Results extends Service {
|
||||
private HashMap<String, Match> retrieveMatches() {
|
||||
HashMap<String, Match> matches = new HashMap<String, Match>();
|
||||
try {
|
||||
URL url = new URL("http://192.168.1.10/matches.json");
|
||||
URL url = new URL("http://www.eurielec.etsit.upm.es/~fherrera/matches.json");
|
||||
URLConnection urlConnection = url.openConnection();
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
|
142
src/com/onirica/carrousel/SelectTeam.java
Normal file
142
src/com/onirica/carrousel/SelectTeam.java
Normal file
@ -0,0 +1,142 @@
|
||||
package com.onirica.carrousel;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SelectTeam extends ListActivity{
|
||||
public static String baseURL = "http://www.eurielec.etsit.upm.es/~cathan";
|
||||
private HashMap<String, Team> mTeams = new HashMap<String, Team>();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.team_selector);
|
||||
mTeams = retrieveTeams();
|
||||
populateTeams();
|
||||
Log.d("SelectTeam","My teams are: "+mTeams.toString());
|
||||
}
|
||||
|
||||
private void populateTeams() {
|
||||
TeamAdapter adapter = new TeamAdapter((Team[])mTeams.values().toArray(new Team[0]));
|
||||
Log.d("SelectTeam","POPULATING TEAMS");
|
||||
setListAdapter(adapter);
|
||||
}
|
||||
|
||||
private HashMap<String, Team> retrieveTeams() {
|
||||
HashMap<String, Team> teams = new HashMap<String, Team>();
|
||||
try {
|
||||
URL url = new URL(baseURL+"/teams.json");
|
||||
URLConnection urlConnection = url.openConnection();
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
urlConnection.getInputStream()));
|
||||
String line;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
while ((line = in.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
String jString = builder.toString();
|
||||
|
||||
JSONObject jObject;
|
||||
jObject = new JSONObject(jString);
|
||||
JSONArray teamsArray = jObject.getJSONArray("teams");
|
||||
Log.d("SelectTeam","TeamsArray: "+teamsArray.toString());
|
||||
|
||||
if (teamsArray == null)
|
||||
throw new Exception("No teams object in json response");
|
||||
for (int i = 0; i < teamsArray.length(); i++) {
|
||||
JSONObject teamsObject = teamsArray.getJSONObject(i);
|
||||
|
||||
String id = teamsObject.getString("id");
|
||||
String crest = teamsObject.getString("crest");
|
||||
Team team = new Team(id, crest);
|
||||
teams.put(team.getId(), team);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.v("Results", "Cannot parse matches json info: " + e.getMessage());
|
||||
}
|
||||
|
||||
return teams;
|
||||
}
|
||||
|
||||
private class TeamAdapter extends BaseAdapter {
|
||||
private Team aTeams[];
|
||||
|
||||
public TeamAdapter(Team teams[]) {
|
||||
super();
|
||||
aTeams = teams;
|
||||
}
|
||||
@Override
|
||||
public int getCount() {
|
||||
return aTeams.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int pos) {
|
||||
return (Object)aTeams[pos];
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int pos) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
private class TeamView extends LinearLayout {
|
||||
private TextView mTv;
|
||||
|
||||
public TeamView(Context context, String text) {
|
||||
super(context);
|
||||
this.setOrientation(HORIZONTAL);
|
||||
this.setBackgroundColor(R.color.transparent);
|
||||
|
||||
mTv = new TextView(context);
|
||||
mTv.setText(text);
|
||||
this.addView(mTv, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
mTv.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(int pos, View convertView, ViewGroup parent) {
|
||||
TeamView v;
|
||||
Team team= aTeams[pos];
|
||||
if (convertView == null) {
|
||||
v = new TeamView(parent.getContext(), team.toString());
|
||||
} else {
|
||||
v = (TeamView)convertView;
|
||||
v.setText(team.toString());
|
||||
// This is tricky: We are reusing the view for a different match.
|
||||
// We need to update the view checkbox state and we use setChecked,
|
||||
// but this would trigger the previous event listener, clearing
|
||||
// the model of the previous item shown with this view.
|
||||
/*v.setOnMatchCheckedChanged(null);
|
||||
v.setChecked(isSubscribed);
|
||||
v.setOnMatchCheckedChanged(new OnMatchCheckedListener(pos));*/
|
||||
}
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
29
src/com/onirica/carrousel/Team.java
Normal file
29
src/com/onirica/carrousel/Team.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.onirica.carrousel;
|
||||
|
||||
public class Team {
|
||||
private String id;
|
||||
private String crestURL;
|
||||
|
||||
public Team(String id, String crestURL) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.crestURL = crestURL;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getCrestURL() {
|
||||
return crestURL;
|
||||
}
|
||||
public void setCrestURL(String crestURL) {
|
||||
this.crestURL = crestURL;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return id;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user