New buy tickets.

This commit is contained in:
Lars Jansøn Engvik committed 2011-12-05 21:30:42 +01:00
1 parent 1152cd2475
commit a3a982892d
5 files changed
+128 -47

No files matched your search

+1
View File
@@ -20,6 +20,7 @@
<activity android:name=".ui.EventViewActivity"></activity>
<activity android:name=".ui.JoinUsActivity"></activity>
<activity android:name=".ui.EventListActivity"></activity>
<activity android:name=".ui.EventListTicketsActivity"></activity>
</application>
</manifest>
+11
View File
@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-8
@@ -150,8 +150,9 @@ public class DnsActivity extends BaseDnsActivity {
public void ticketButton(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://m.billettservice.no/ticket/search.do?articles=tmno&query=studentersamfundet&submit=S%C3%B8k"));
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.setClass(this, EventListTicketsActivity.class);
startActivity(intent);
}
@@ -5,6 +5,7 @@ import java.text.SimpleDateFormat;
import org.w3c.dom.NodeList;
import android.R.bool;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
@@ -36,9 +37,9 @@ import com.studentersamfundet.app.ui.ChooseCategoryDialog.Callback;
public class EventListActivity extends BaseDnsActivity {
public static final String feedURL = "http://studentersamfundet.no/rss/lars_program_feed.php";
private FeedFetcher feed;
private RSSParserProgram parser;
private DataHandler dataHandler;
protected FeedFetcher feed;
protected RSSParserProgram parser;
protected DataHandler dataHandler;
private String currentCategory = Event.ALL;
@@ -50,7 +51,7 @@ public class EventListActivity extends BaseDnsActivity {
this.feed = new FeedFetcher(this, feedURL);
this.parser = new RSSParserProgram();
ListCreator lc = new ListCreator(Event.ALL, false);
ListCreator lc = getListCreator(Event.ALL, false);
lc.execute();
}
@@ -66,7 +67,7 @@ public class EventListActivity extends BaseDnsActivity {
switch (item.getItemId()) {
case R.id.menu_refresh:
ListCreator lc = new ListCreator(Event.ALL, true);
ListCreator lc = getListCreator(Event.ALL, true);
lc.execute();
return true;
@@ -84,14 +85,13 @@ public class EventListActivity extends BaseDnsActivity {
if (currentCategory.equals(Event.ALL)) {
super.onBackPressed();
} else {
ListCreator lc = new ListCreator(Event.ALL, false);
ListCreator lc = getListCreator(Event.ALL, false);
lc.execute();
}
}
protected ListAdapter createAdapter(String category) {
Event[] events = dataHandler.getEvents(category);
protected ListAdapter createAdapter(Event[] events) {
ListAdapter adapter = new ArrayAdapter<Event>(this, R.layout.event_list_row, R.id.event_list_row_text, events) {
@Override
@@ -129,41 +129,8 @@ public class EventListActivity extends BaseDnsActivity {
priceView.setTextAppearance(EventListActivity.this, R.style.ListItemTextDate);
/* Add onClickListeners: */
row.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(EventListActivity.this, EventViewActivity.class);
intent.putExtra("event", e);
startActivity(intent);
}
});
row.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
if (e.getDate() == null)
return false;
long startDate = e.getDate().getTime();
try {
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("title", e.title);
intent.putExtra("beginTime", startDate);
intent.putExtra("endTime", startDate + (2*60*60*1000)); // Two hours
intent.putExtra("allDay", false);
intent.putExtra("eventLocation", e.getLocation());
intent.putExtra("reminder", false);
startActivity(intent);
return true;
} catch (ActivityNotFoundException e) {
return false;
}
}
});
row.setOnClickListener(getShortClickListener(e));
row.setOnLongClickListener(getLongClickListener(e));
return row;
}
@@ -179,7 +146,7 @@ public class EventListActivity extends BaseDnsActivity {
if (message.length < 1)
message = new String[] { Event.ALL };
ListCreator lc = new ListCreator(message[0], false);
ListCreator lc = getListCreator(message[0], false);
lc.execute();
}
};
@@ -235,7 +202,8 @@ public class EventListActivity extends BaseDnsActivity {
protected void onPostExecute(Boolean result) {
if (result) {
ListView list = (ListView)findViewById(R.id.event_list);
ListAdapter adapter = createAdapter(this.category);
Event[] events = getEvents();
ListAdapter adapter = createAdapter(events);
list.setAdapter(adapter);
list.setVisibility(View.VISIBLE);
@@ -248,5 +216,53 @@ public class EventListActivity extends BaseDnsActivity {
toast.show();
}
}
protected Event[] getEvents() {
return dataHandler.getEvents(this.category);
}
}
protected ListCreator getListCreator(String category, boolean forcedUpdate) {
return new ListCreator(category, forcedUpdate);
}
protected OnClickListener getShortClickListener (final Event e) {
return new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(EventListActivity.this, EventViewActivity.class);
intent.putExtra("event", e);
startActivity(intent);
}
};
}
protected OnLongClickListener getLongClickListener (final Event e) {
return new OnLongClickListener() {
public boolean onLongClick(View v) {
if (e.getDate() == null)
return false;
long startDate = e.getDate().getTime();
try {
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("title", e.title);
intent.putExtra("beginTime", startDate);
intent.putExtra("endTime", startDate + (2*60*60*1000)); // Two hours
intent.putExtra("allDay", false);
intent.putExtra("eventLocation", e.getLocation());
intent.putExtra("reminder", false);
startActivity(intent);
return true;
} catch (ActivityNotFoundException e) {
return false;
}
}
};
}
}
@@ -0,0 +1,52 @@
package com.studentersamfundet.app.ui;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import com.studentersamfundet.app.Event;
public class EventListTicketsActivity extends EventListActivity {
class TicketListCreator extends ListCreator {
public TicketListCreator(String category, boolean forcedUpdate) {
super(category, forcedUpdate);
}
@Override
protected Event[] getEvents() {
return dataHandler.getEventsWithTickets();
}
}
@Override
protected ListCreator getListCreator(String category, boolean forcedUpdate) {
return new TicketListCreator(category, forcedUpdate);
}
protected OnClickListener getShortClickListener (final Event e) {
return new OnClickListener() {
@Override
public void onClick(View v) {
Uri webDestination = e.getTicketUri();
Intent webIntent = new Intent(Intent.ACTION_VIEW, webDestination);
startActivity(webIntent);
}
};
}
protected OnLongClickListener getLongClickListener (final Event e) {
return new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return false;
}
};
}
}