diff --git a/.gitignore b/.gitignore
index ff4a396..18c743c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.DS_Store
# built application files
*.apk
*.ap_
@@ -19,3 +20,12 @@ local.properties
.classpath
.project
*.~
+ant.properties
+cinequest.keystore
+abc.txt
+
+build/
+.gradle
+.idea
+gradle/
+gradlew*
diff --git a/Android/Android.iml b/Android/Android.iml
new file mode 100644
index 0000000..1dafa6e
--- /dev/null
+++ b/Android/Android.iml
@@ -0,0 +1,106 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Android/AndroidManifest.xml b/Android/AndroidManifest.xml
index f26cc50..9a3eab0 100644
--- a/Android/AndroidManifest.xml
+++ b/Android/AndroidManifest.xml
@@ -1,61 +1,69 @@
-
+ package="edu.sjsu.cinequest" android:versionCode="1602081517"
+ android:versionName="16.0208.1517">
-
-
+
-
-
+
-
-
-
+
+
+ android:label="@string/app_name"
+ android:screenOrientation="portrait" >
-
-
-
+
+
+ android:label="@string/app_name"
+ android:screenOrientation="portrait" >
-
+
+
+
-
\ No newline at end of file
+
diff --git a/Android/ant.properties b/Android/ant.properties
deleted file mode 100644
index 77d40b1..0000000
--- a/Android/ant.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-key.store=/home/cay/projects/cinequest/keys/cinequest.keystore
-key.alias=cinequestkeystore
diff --git a/Android/build.gradle b/Android/build.gradle
new file mode 100644
index 0000000..2c6f4c0
--- /dev/null
+++ b/Android/build.gradle
@@ -0,0 +1,37 @@
+apply plugin: 'com.android.application'
+
+dependencies {
+ compile fileTree(dir: 'libs', include: '*.jar')
+ compile project(':JavaCommon')
+}
+
+android {
+ compileSdkVersion 15
+ buildToolsVersion '25.0.0'
+
+ sourceSets {
+ main {
+ manifest.srcFile 'AndroidManifest.xml'
+ java.srcDirs = ['src']
+ resources.srcDirs = ['src']
+ aidl.srcDirs = ['src']
+ renderscript.srcDirs = ['src']
+ res.srcDirs = ['res']
+ assets.srcDirs = ['assets']
+ }
+
+ // Move the tests to tests/java, tests/res, etc...
+ instrumentTest.setRoot('tests')
+
+ // Move the build types to build-types/
+ // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
+ // This moves them out of them default location under src//... which would
+ // conflict with src/ being used by the main source set.
+ // Adding new build types or product flavors should be accompanied
+ // by a similar customization.
+ debug.setRoot('build-types/debug')
+ release.setRoot('build-types/release')
+ }
+
+ android.enforceUniquePackageName = false
+}
diff --git a/Android/project.properties b/Android/project.properties
index d6e65f7..4bf2be7 100644
--- a/Android/project.properties
+++ b/Android/project.properties
@@ -9,6 +9,6 @@
android.library=false
# Project target.
-target=android-18
+target=android-15
android.library.reference.1=../JavaCommon
android.library.reference.2=../facebook
diff --git a/Android/res/drawable-hdpi/events_icon_grey.png b/Android/res/drawable-hdpi/events_icon_grey.png
new file mode 100644
index 0000000..958bab5
Binary files /dev/null and b/Android/res/drawable-hdpi/events_icon_grey.png differ
diff --git a/Android/res/drawable-hdpi/events_icon_white_retina.png b/Android/res/drawable-hdpi/events_icon_white_retina.png
new file mode 100644
index 0000000..f695a83
Binary files /dev/null and b/Android/res/drawable-hdpi/events_icon_white_retina.png differ
diff --git a/Android/res/drawable-hdpi/film_icon2_grey.png b/Android/res/drawable-hdpi/film_icon2_grey.png
new file mode 100644
index 0000000..afea34c
Binary files /dev/null and b/Android/res/drawable-hdpi/film_icon2_grey.png differ
diff --git a/Android/res/drawable-hdpi/film_icon2_white_retina.png b/Android/res/drawable-hdpi/film_icon2_white_retina.png
new file mode 100644
index 0000000..bc5e0fe
Binary files /dev/null and b/Android/res/drawable-hdpi/film_icon2_white_retina.png differ
diff --git a/Android/res/drawable-hdpi/ic_action_remove.png b/Android/res/drawable-hdpi/ic_action_remove.png
new file mode 100644
index 0000000..f889617
Binary files /dev/null and b/Android/res/drawable-hdpi/ic_action_remove.png differ
diff --git a/Android/res/drawable-hdpi/news_2x_grey.png b/Android/res/drawable-hdpi/news_2x_grey.png
new file mode 100644
index 0000000..9346739
Binary files /dev/null and b/Android/res/drawable-hdpi/news_2x_grey.png differ
diff --git a/Android/res/drawable-hdpi/news_2x_white.png b/Android/res/drawable-hdpi/news_2x_white.png
new file mode 100644
index 0000000..12dcf59
Binary files /dev/null and b/Android/res/drawable-hdpi/news_2x_white.png differ
diff --git a/Android/res/drawable-hdpi/schedule_grey.png b/Android/res/drawable-hdpi/schedule_grey.png
new file mode 100644
index 0000000..d71ea51
Binary files /dev/null and b/Android/res/drawable-hdpi/schedule_grey.png differ
diff --git a/Android/res/drawable-hdpi/schedule_white_retina.png b/Android/res/drawable-hdpi/schedule_white_retina.png
new file mode 100644
index 0000000..076417c
Binary files /dev/null and b/Android/res/drawable-hdpi/schedule_white_retina.png differ
diff --git a/Android/res/drawable-hdpi/twitter.png b/Android/res/drawable-hdpi/twitter.png
new file mode 100644
index 0000000..732d233
Binary files /dev/null and b/Android/res/drawable-hdpi/twitter.png differ
diff --git a/Android/res/drawable-hdpi/youtube.png b/Android/res/drawable-hdpi/youtube.png
deleted file mode 100644
index ec44243..0000000
Binary files a/Android/res/drawable-hdpi/youtube.png and /dev/null differ
diff --git a/Android/res/drawable-mdpi/forums_icon.png b/Android/res/drawable-mdpi/forums_icon.png
deleted file mode 100644
index d58c77f..0000000
Binary files a/Android/res/drawable-mdpi/forums_icon.png and /dev/null differ
diff --git a/Android/res/drawable/androidsplash.png b/Android/res/drawable/androidsplash.png
new file mode 100644
index 0000000..58de079
Binary files /dev/null and b/Android/res/drawable/androidsplash.png differ
diff --git a/Android/res/drawable/disabledeventsbutton.xml b/Android/res/drawable/disabledeventsbutton.xml
new file mode 100644
index 0000000..a57da3a
--- /dev/null
+++ b/Android/res/drawable/disabledeventsbutton.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/Android/res/drawable/disabledfilmsbutton.xml b/Android/res/drawable/disabledfilmsbutton.xml
new file mode 100644
index 0000000..cda2d36
--- /dev/null
+++ b/Android/res/drawable/disabledfilmsbutton.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/Android/res/drawable/enabledeventsbutton.xml b/Android/res/drawable/enabledeventsbutton.xml
new file mode 100644
index 0000000..769cec6
--- /dev/null
+++ b/Android/res/drawable/enabledeventsbutton.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/Android/res/drawable/enabledfilmsbutton.xml b/Android/res/drawable/enabledfilmsbutton.xml
new file mode 100644
index 0000000..8bd3f00
--- /dev/null
+++ b/Android/res/drawable/enabledfilmsbutton.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/Android/res/drawable/filmreel.png b/Android/res/drawable/filmreel.png
index 05bec5a..9a21c08 100644
Binary files a/Android/res/drawable/filmreel.png and b/Android/res/drawable/filmreel.png differ
diff --git a/Android/res/drawable/ic_tab_event.xml b/Android/res/drawable/ic_tab_event.xml
new file mode 100644
index 0000000..87e9b9e
--- /dev/null
+++ b/Android/res/drawable/ic_tab_event.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
diff --git a/Android/res/drawable/ic_tab_film.xml b/Android/res/drawable/ic_tab_film.xml
new file mode 100644
index 0000000..0c3c96b
--- /dev/null
+++ b/Android/res/drawable/ic_tab_film.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Android/res/drawable/ic_tab_news.xml b/Android/res/drawable/ic_tab_news.xml
new file mode 100644
index 0000000..673df1a
--- /dev/null
+++ b/Android/res/drawable/ic_tab_news.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
diff --git a/Android/res/drawable/ic_tab_schedule.xml b/Android/res/drawable/ic_tab_schedule.xml
new file mode 100644
index 0000000..445692c
--- /dev/null
+++ b/Android/res/drawable/ic_tab_schedule.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
diff --git a/Android/res/drawable/splash.png b/Android/res/drawable/splash.png
deleted file mode 100644
index cfd19f9..0000000
Binary files a/Android/res/drawable/splash.png and /dev/null differ
diff --git a/Android/res/layout/activity_splash_screen.xml b/Android/res/layout/activity_splash_screen.xml
index 9b9dc87..9567cda 100644
--- a/Android/res/layout/activity_splash_screen.xml
+++ b/Android/res/layout/activity_splash_screen.xml
@@ -8,7 +8,7 @@
android:id="@+id/login_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:background="@drawable/splash" >
+ android:background="@drawable/androidsplash" >
+
+
-
-
-
-
diff --git a/Android/res/layout/facebookviewport.xml b/Android/res/layout/facebookviewport.xml
new file mode 100644
index 0000000..47b3f38
--- /dev/null
+++ b/Android/res/layout/facebookviewport.xml
@@ -0,0 +1,6 @@
+
+
\ No newline at end of file
diff --git a/Android/res/layout/filmdetail.xml b/Android/res/layout/filmdetail.xml
index 9709d6f..6fd9530 100644
--- a/Android/res/layout/filmdetail.xml
+++ b/Android/res/layout/filmdetail.xml
@@ -6,6 +6,5 @@
android:layout_height="fill_parent"
android:id="@+id/ScheduleList"
android:clickable="true"
-
+ android:listSelector="#FF0000"
/>
-
\ No newline at end of file
diff --git a/Android/res/layout/home_layout.xml b/Android/res/layout/home_layout.xml
index 51eb752..6e7f89a 100644
--- a/Android/res/layout/home_layout.xml
+++ b/Android/res/layout/home_layout.xml
@@ -14,7 +14,7 @@
android:layout_height="wrap_content"
android:background="#6D7B8D"
android:visibility="visible"
- >
+ >
+ android:background="#ff0000"/>
\ No newline at end of file
diff --git a/Android/res/layout/hotpicks_activity_layout.xml b/Android/res/layout/hotpicks_activity_layout.xml
new file mode 100644
index 0000000..ffc5785
--- /dev/null
+++ b/Android/res/layout/hotpicks_activity_layout.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Android/res/layout/index_activity_layout.xml b/Android/res/layout/index_activity_layout.xml
new file mode 100644
index 0000000..02b8431
--- /dev/null
+++ b/Android/res/layout/index_activity_layout.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Android/res/layout/list_header.xml b/Android/res/layout/list_header.xml
index 857a3b9..231d1f5 100644
--- a/Android/res/layout/list_header.xml
+++ b/Android/res/layout/list_header.xml
@@ -7,5 +7,5 @@
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:paddingLeft="5dip"
- android:background="#6D7B8D"
+ android:background="#ff0000"
style="?android:attr/listSeparatorTextViewStyle" />
diff --git a/Android/res/layout/listitem_titletimevenue.xml b/Android/res/layout/listitem_titletimevenue.xml
index 76edb17..02edcec 100644
--- a/Android/res/layout/listitem_titletimevenue.xml
+++ b/Android/res/layout/listitem_titletimevenue.xml
@@ -5,15 +5,6 @@
android:padding="6dip"
>
-
-
-
diff --git a/Android/res/layout/listitem_titletimevenuebuttons.xml b/Android/res/layout/listitem_titletimevenuebuttons.xml
new file mode 100644
index 0000000..76edb17
--- /dev/null
+++ b/Android/res/layout/listitem_titletimevenuebuttons.xml
@@ -0,0 +1,136 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Android/res/layout/main.xml b/Android/res/layout/main.xml
index 1d0e21b..04f56b4 100644
--- a/Android/res/layout/main.xml
+++ b/Android/res/layout/main.xml
@@ -11,7 +11,12 @@
+ android:layout_height="wrap_content"
+ android:tabStripEnabled="false" />
+
diff --git a/Android/res/layout/schedulelayout.xml b/Android/res/layout/schedulelayout.xml
index be828f0..0ec5044 100644
--- a/Android/res/layout/schedulelayout.xml
+++ b/Android/res/layout/schedulelayout.xml
@@ -4,6 +4,17 @@
android:layout_height="fill_parent"
android:orientation="vertical" >
+
+
-
-
-
-
-
diff --git a/Android/res/layout/shareoptions.xml b/Android/res/layout/shareoptions.xml
index a8d6087..5785642 100644
--- a/Android/res/layout/shareoptions.xml
+++ b/Android/res/layout/shareoptions.xml
@@ -12,7 +12,7 @@
style="?android:attr/listSeparatorTextViewStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:background="#6D7B8D"
+ android:background="#ff0000"
android:paddingBottom="2dip"
android:paddingLeft="5dip"
android:paddingTop="2dip"
@@ -55,11 +55,11 @@
android:textColor="#FFFFFF"
android:background="@drawable/background" />
diff --git a/Android/res/values/strings.xml b/Android/res/values/strings.xml
index 9249079..3f25445 100644
--- a/Android/res/values/strings.xml
+++ b/Android/res/values/strings.xml
@@ -12,6 +12,7 @@
Password
Sync
Cancel
+
Sign up
Conflicting schedule on server. Which one to keep?
Schedule Successfully Saved!
@@ -21,6 +22,7 @@
Logged in. Schedule Successfully Synced!
Logged in. Schedule Successfully Saved!
Logged in. Schedule Successfully Retrieved!!
+
No network connection available. Please connect to Internet first!
Network connection is unavailable!
@@ -30,7 +32,8 @@
Rohit Vobbilisetty\n
Tanuvir Singh\n
Lou Bash\n
- Matt Opsal\n
+ Matt Opsal\n
+ Dmitri Dimov\n
GetSchedule
diff --git a/Android/src/edu/sjsu/cinequest/CheckBoxMap.java b/Android/src/edu/sjsu/cinequest/CheckBoxMap.java
index a6e2fe8..ea4d76c 100644
--- a/Android/src/edu/sjsu/cinequest/CheckBoxMap.java
+++ b/Android/src/edu/sjsu/cinequest/CheckBoxMap.java
@@ -1,6 +1,7 @@
package edu.sjsu.cinequest;
import java.util.ArrayList;
+import java.util.List;
import android.content.Context;
import android.widget.CheckBox;
@@ -18,9 +19,9 @@
*/
public class CheckBoxMap {
//ArrayLists for holding the data
- private ArrayList schdList = new ArrayList();
- private ArrayList idList = new ArrayList(); //key list
- private ArrayList cboxList = new ArrayList(); //value list
+ private List schdList = new ArrayList();
+ private List idList = new ArrayList(); //key list
+ private List cboxList = new ArrayList(); //value list
CompoundButton.OnCheckedChangeListener mCheckboxClickListener;
Context context;
@@ -101,7 +102,7 @@ public boolean containsKey(int key){
* Returns an ArrayList containing all the keys for the collection
* @return the arraylist containing all the keys
*/
- public ArrayList keySet(){
+ public List keySet(){
return new ArrayList(idList);
}
@@ -109,7 +110,7 @@ public ArrayList keySet(){
* Returns an ArrayList containing all the values for the collection
* @return the arraylist containing all the values
*/
- public ArrayList values(){
+ public List values(){
return new ArrayList(cboxList);
}
@@ -117,7 +118,7 @@ public ArrayList values(){
* Returns an ArrayList containing all the values of tags that came with checkboxes
* @return the arraylist containing all the tags
*/
- public ArrayList allTags(){
+ public List allTags(){
return new ArrayList(schdList);
}
diff --git a/Android/src/edu/sjsu/cinequest/CinequestActivity.java b/Android/src/edu/sjsu/cinequest/CinequestActivity.java
index 9e26143..f336ccb 100644
--- a/Android/src/edu/sjsu/cinequest/CinequestActivity.java
+++ b/Android/src/edu/sjsu/cinequest/CinequestActivity.java
@@ -34,74 +34,49 @@
import edu.sjsu.cinequest.comm.cinequestitem.CommonItem;
import edu.sjsu.cinequest.comm.cinequestitem.Schedule;
-/*
+/**
* This superclass has convenience methods for making lists of schedules and
* filmlets.
+ *
+ * It also contains ListAdapters ScheduleListAdapter and FilmletListAdapter. It
+ * handles MenuOptions: Home, Schedule, and About
+ *
*/
-public class CinequestActivity extends Activity
-{
+public class CinequestActivity extends Activity {
private static final int HOME_MENUOPTION_ID = Menu.FIRST + 11;
private static final int SCHEDULE_MENUOPTION_ID = Menu.FIRST + 12;
- private static final int ABOUT_MENUOPTION_ID = Menu.FIRST + 13;
- public static String calendarName="Cinequest Calendar";
+ private static final int ABOUT_MENUOPTION_ID = Menu.FIRST + 13;
+ public static String calendarName = "Cinequest Calendar";
public static String m_selectedCalendarId = "Cinequest Calendar";
/**
* Launches the FilmDetail activity for the given object.
- * @param result Object; Can be Schedule, Filmlet etc
+ *
+ * @param result
+ * Object; Can be Schedule, Filmlet etc
*/
protected void launchFilmDetail(Object result) {
Intent intent = new Intent();
intent.setClass(this, FilmDetail.class);
intent.putExtra("target", (Serializable) result);
- startActivity(intent);
+ startActivity(intent);
}
/**
* Creates a list of schedules
- * @param listItems the list items
- * @param isChecked a function to determine when to check a checkbox, or null for no checkboxes
- * @param listener the listener for checkboxes, or null for no checkboxes
+ *
+ * @param listItems
+ * the list items
* @return the list adapter
*/
-
- /*protected ListAdapter createScheduleList(List listItems) {
+ protected ListAdapter createFilmletList(List extends CommonItem> listItems) {
if (listItems.size() == 0) {
return new SeparatedListAdapter(this);
}
- SeparatedListIndexedAdapter adapter = new SeparatedListIndexedAdapter(this);
-
-
- TreeMap> filmsMap
- = new TreeMap>();
-
- for(Schedule s : listItems) {
- String day = s.getStartTime().substring(0, 10);
-
- if (!filmsMap.containsKey(day))
- filmsMap.put(day, new ArrayList());
- filmsMap.get(day).add(s);
- }
-
- DateUtils du = new DateUtils();
- for (String day : filmsMap.keySet()) {
- ArrayList filmsForDay = filmsMap.get(day);
- String header = du.format(day, DateUtils.DATE_DEFAULT);
- String key = du.format(day, DateUtils.DAY_ONLY);
- adapter.addSection(header, key, new ScheduleListAdapter(this, filmsForDay));
- }
- return adapter;
- }
- */
- //protected ListAdapter createFilmletList(List extends Filmlet> listItems) {
- protected ListAdapter createFilmletList(List extends CommonItem> listItems) {
- if (listItems.size() == 0) {
- return new SeparatedListAdapter(this);
- }
- SeparatedListIndexedAdapter adapter = new SeparatedListIndexedAdapter(this);
- TreeMap> filmsTitleMap
- = new TreeMap>();
+ SeparatedListIndexedAdapter adapter = new SeparatedListIndexedAdapter(
+ this);
+ TreeMap> filmsTitleMap = new TreeMap>();
String titleInitial = "";
for (CommonItem f : listItems) {
titleInitial = getTitleInitial(f.getTitle(), titleInitial);
@@ -111,101 +86,195 @@ protected ListAdapter createFilmletList(List extends CommonItem> listItems) {
filmsTitleMap.get(titleInitial).add(f);
}
- for (String titleInit : filmsTitleMap.keySet()) {
- adapter.addSection(
- titleInit, titleInit,
- new FilmletListAdapter(this, filmsTitleMap.get(titleInit)));
- }
+ for (String titleInit : filmsTitleMap.keySet()) {
+ adapter.addSection(titleInit, titleInit, new FilmletListAdapter(
+ this, filmsTitleMap.get(titleInit)));
+ }
return adapter;
}
+ protected ListAdapter createListWithIcons(List extends CommonItem> listItems) {
+ int size = listItems.size();
+ String[] imageURLs = new String[size];
+ String[] titles = new String[size];
+ for (int i = 0; i < size; i++) {
+ CommonItem item = listItems.get(i);
+ imageURLs[i] = item.getThumbImageURL();
+ titles[i] = item.getTitle();
+ }
+ return new LazyAdapter(this, imageURLs, titles);
+ }
+
+ /**
+ * A method to get the first (relevant) letter of a title
+ *
+ * @param title
+ * The title of the film
+ * @param previousInitial
+ * the previous initital
+ * @return The initial of the movie title
+ */
private static String getTitleInitial(String title, String previousInitial) {
String ucTitle = title.toUpperCase();
- if (ucTitle.startsWith("A ") || ucTitle.startsWith("AN ") || ucTitle.startsWith("THE "))
+ if (ucTitle.startsWith("A ") || ucTitle.startsWith("AN ")
+ || ucTitle.startsWith("THE "))
ucTitle = ucTitle.substring(ucTitle.indexOf(' ') + 1);
- String initial = ucTitle.substring(0,1);
- if (initial.compareTo(previousInitial) < 0) Platform.getInstance().log("Didn't expect " + title + " after section " + previousInitial);
+ String initial = ucTitle.substring(0, 1);
+ if (initial.compareTo(previousInitial) < 0)
+ Platform.getInstance().log(
+ "Didn't expect " + title + " after section "
+ + previousInitial);
return initial;
}
/**
- * An adapter for a list of schedule items. These lists occur (1) in the Films tab
- * (when sorted by date), Events and Forums tabs, (2) in each film detail,
- * and (3) in the Schedule tab.
+ * An adapter for a list of schedule items without buttons, used in FilmsActivity1.
*/
- protected class ScheduleListAdapter extends ArrayAdapter {
+ protected class ScheduleListAdapter1 extends ArrayAdapter {
private static final int RESOURCE_ID = R.layout.listitem_titletimevenue;
private DateUtils du = new DateUtils();
- boolean is24HourFormat=android.text.format.DateFormat.is24HourFormat(getContext());
+ boolean is24HourFormat = android.text.format.DateFormat
+ .is24HourFormat(getContext());
- public ScheduleListAdapter(Context context, List list)
- {
+ public ScheduleListAdapter1(Context context, List list) {
super(context, RESOURCE_ID, list);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see android.widget.ArrayAdapter#getView(int, android.view.View,
+ * android.view.ViewGroup)
+ */
@Override
- public View getView(int position, View v, ViewGroup parent) {
+ public View getView(int position, View v, ViewGroup parent) {
if (v == null) {
- LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LayoutInflater inflater = (LayoutInflater) getContext()
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(RESOURCE_ID, null);
}
TextView title = (TextView) v.findViewById(R.id.titletext);
TextView time = (TextView) v.findViewById(R.id.timetext);
TextView venue = (TextView) v.findViewById(R.id.venuetext);
- //CheckBox checkbox = (CheckBox) v.findViewById(R.id.myschedule_checkbox);
- Button button = (Button) v.findViewById(R.id.myschedule_checkbox);
- final Schedule result = getItem(position);
- title.setText(result.getTitle());
- if (result.isSpecialItem())
- title.setTypeface(null, Typeface.ITALIC);
- String startTime = du.format(result.getStartTime(), DateUtils.TIME_SHORT);
- String endTime = du.format(result.getEndTime(), DateUtils.TIME_SHORT);
- if(!is24HourFormat)
- {
- startTime=du.formatTime(startTime);
- if (startTime.length()==7) startTime="0"+startTime;
- endTime=du.formatTime(endTime);
- if (endTime.length()==7) endTime="0"+endTime;
+ final Schedule result = getItem(position);
+ title.setText(result.getTitle());
+ String startTime = du.format(result.getStartTime(),
+ DateUtils.TIME_SHORT);
+ String endTime = du.format(result.getEndTime(),
+ DateUtils.TIME_SHORT);
+ if (!is24HourFormat) {
+ startTime = du.formatTime(startTime);
+ if (startTime.length() == 7)
+ startTime = "0" + startTime;
+ endTime = du.formatTime(endTime);
+ if (endTime.length() == 7)
+ endTime = "0" + endTime;
}
time.setText("Time: " + startTime + " - " + endTime);
venue.setText("Venue: " + result.getVenue());
- formatContents(v, title, time, venue, du, result);
- button.setTag(result);
- button.setText("-");
- populateCalendarID();
- configureCalendarIcon(v, button, result);
- Button directions = (Button) v.findViewById(R.id.directionsURL);
- directions.setTag(result);
- directions.setOnClickListener(new OnClickListener() {
+ return v;
+ }
+ }
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
+ /**
+ * An adapter for a list of schedule items. These lists occur (1) in the
+ * Films tab (when sorted by date), Events and Forums tabs, (2) in each film
+ * detail, and (3) in the Schedule tab.
+ */
+ protected class ScheduleListAdapter extends ArrayAdapter {
+ private static final int RESOURCE_ID = R.layout.listitem_titletimevenuebuttons;
+ private DateUtils du = new DateUtils();
+ boolean is24HourFormat = android.text.format.DateFormat
+ .is24HourFormat(getContext());
+
+ public ScheduleListAdapter(Context context, List list) {
+ super(context, RESOURCE_ID, list);
+ }
- Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
- Uri.parse(result.getDirectionsURL()));
- startActivity(intent);
+ /*
+ * (non-Javadoc)
+ *
+ * @see android.widget.ArrayAdapter#getView(int, android.view.View,
+ * android.view.ViewGroup)
+ */
+ @Override
+ public View getView(int position, View v, ViewGroup parent) {
+ if (v == null) {
+ LayoutInflater inflater = (LayoutInflater) getContext()
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ v = inflater.inflate(RESOURCE_ID, null);
}
- });
- return v;
- }
+ TextView title = (TextView) v.findViewById(R.id.titletext);
+ TextView time = (TextView) v.findViewById(R.id.timetext);
+ TextView venue = (TextView) v.findViewById(R.id.venuetext);
+ Button button = (Button) v.findViewById(R.id.myschedule_checkbox);
+ final Schedule result = getItem(position);
+ title.setText(result.getTitle());
+ if (result.isSpecialItem())
+ title.setTypeface(null, Typeface.ITALIC);
+ String startTime = du.format(result.getStartTime(),
+ DateUtils.TIME_SHORT);
+ String endTime = du.format(result.getEndTime(),
+ DateUtils.TIME_SHORT);
+ if (!is24HourFormat) {
+ startTime = du.formatTime(startTime);
+ if (startTime.length() == 7)
+ startTime = "0" + startTime;
+ endTime = du.formatTime(endTime);
+ if (endTime.length() == 7)
+ endTime = "0" + endTime;
+ }
+ time.setText("Time: " + startTime + " - " + endTime);
+ venue.setText("Venue: " + result.getVenue());
+ formatContents(v, title, time, venue, du, result);
+ v.setTag(result);
+ button.setTag(result);
+ button.setText("-");
+ populateCalendarID();
+ configureCalendarIcon(v, button, result);
+ Button directions = (Button) v.findViewById(R.id.directionsURL);
+ directions.setTag(result);
+ directions.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(
+ android.content.Intent.ACTION_VIEW, Uri
+ .parse(result.getDirectionsURL()));
+ startActivity(intent);
+ }
+ });
+ return v;
+ }
/**
* Override to change the formatting of the contents
+ *
+ * @param View
+ * to be formated, title, time, venue, du, result
*/
- protected void formatContents(View v, TextView title, TextView time, TextView venue, DateUtils du, Schedule result) {
+ protected void formatContents(View v, TextView title, TextView time,
+ TextView venue, DateUtils du, Schedule result) {
}
- //Calendar code for adding/removing events from Device Calendar
- protected void configureCalendarIcon(View v, final Button button, Schedule result) {
+ // Calendar code for adding/removing events from Device Calendar
+ /**
+ * Configures the Calendar code for adding/removing events from Device
+ * Calendar
+ *
+ * @param The
+ * View to configure the button and Schedule
+ */
+ protected void configureCalendarIcon(View v, final Button button,
+ Schedule result) {
button.setVisibility(View.VISIBLE);
- Schedule s = result;
-
- SimpleDateFormat formatter;
- if (s.getStartTime().charAt(10)=='T')
+ Schedule s = result;
+
+ SimpleDateFormat formatter;
+ if (s.getStartTime().charAt(10) == 'T')
formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
else
formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
@@ -216,66 +285,210 @@ protected void configureCalendarIcon(View v, final Button button, Schedule resul
startDate = (Date) formatter.parse(s.getStartTime());
endDate = (Date) formatter.parse(s.getEndTime());
} catch (ParseException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
- }
+ }
long begin = startDate.getTime();
long end = endDate.getTime();
- String[] proj = new String[]{
- "_id",
- "title",
- "dtstart",
- "dtend"};
-
- String calSelection = "((calendar_id= ?) " +
- "AND (" +
- "((dtstart= ?) " +
- "AND (dtend= ?) " +
- "AND (title= ?) " +
- ") " +
- ")" +
- ")";
- String[] calSelectionArgs = new String[] {
- m_selectedCalendarId, begin+"", end+"", s.getTitle()
- };
-
- Uri event=null;
- Cursor l_managedCursor=null;
-
+ String[] proj = new String[] { "_id", "title", "dtstart", "dtend" };
+
+ String calSelection = "((calendar_id= ?) " + "AND ("
+ + "((dtstart= ?) " + "AND (dtend= ?) " + "AND (title= ?) "
+ + ") " + ")" + ")";
+ String[] calSelectionArgs = new String[] { m_selectedCalendarId,
+ begin + "", end + "", s.getTitle() };
+
+ Uri event = null;
+ Cursor l_managedCursor = null;
+
if (Build.VERSION.SDK_INT >= 8) {
event = Uri.parse("content://com.android.calendar/events");
} else {
- //Calendar code for API level < 8, needs lot of testing.
- //May be some of the paramters (that we are populating above), have different naming conventions in different API Levels
+ // Calendar code for API level < 8, needs lot of testing.
+ // May be some of the paramters (that we are populating above),
+ // have different naming conventions in different API Levels
event = Uri.parse("content://calendar/events");
}
- try{
- l_managedCursor = getContentResolver().query(event, proj, calSelection, calSelectionArgs, "dtstart DESC, dtend DESC");
- }
- catch (Exception e){
- Log.i("CinequestActivity:configureCalendarIcon","Error while retrieving Event details from Calendar");
+ try {
+ l_managedCursor = getContentResolver().query(event, proj,
+ calSelection, calSelectionArgs,
+ "dtstart DESC, dtend DESC");
+ } catch (Exception e) {
+ Log.i("CinequestActivity:configureCalendarIcon",
+ "Error while retrieving Event details from Calendar");
}
-
- if (l_managedCursor.getCount()>0) {
+
+ if (l_managedCursor.getCount() > 0) {
button.setBackgroundResource(R.drawable.incalendar);
- button.setHint("exists");
- }
- else
- {
+ button.setHint("exists");
+ } else {
button.setBackgroundResource(R.drawable.notincalendar);
button.setHint("notexist");
}
+ v.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Schedule s = (Schedule) v.getTag();
+ SimpleDateFormat formatter;
+ if (s.getStartTime().charAt(10) == 'T')
+ formatter = new SimpleDateFormat(
+ "yyyy-MM-dd'T'hh:mm:ss");
+ else
+ formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+
+ Date startDate = null;
+ Date endDate = null;
+
+ try {
+ startDate = (Date) formatter.parse(s.getStartTime());
+ endDate = (Date) formatter.parse(s.getEndTime());
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ long begin = startDate.getTime();
+ long end = endDate.getTime();
+
+ if (button.getHint().toString() == "exists") {
+ String[] proj = new String[] { "_id", "title",
+ "dtstart", "dtend" };
+
+ String calSelection = "((calendar_id= ?) " + "AND ("
+ + "((dtstart= ?) " + "AND (dtend= ?) "
+ + "AND (title= ?) " + ") " + ")" + ")";
+ String[] calSelectionArgs = new String[] {
+ m_selectedCalendarId, begin + "", end + "",
+ s.getTitle() };
+
+ Uri event = null;
+ Cursor l_managedCursor = null;
+ if (Build.VERSION.SDK_INT >= 8) {
+ event = Uri
+ .parse("content://com.android.calendar/events");
+ } else {
+ // Calendar code for API level < 8, needs lot of
+ // testing.
+ // May be some of the paramters (that we are
+ // populating above), have different naming
+ // conventions in different API Levels
+ event = Uri.parse("content://calendar/events");
+ }
+ try {
+ l_managedCursor = getContentResolver().query(event,
+ proj, calSelection, calSelectionArgs,
+ "dtstart DESC, dtend DESC");
+ } catch (Exception e) {
+ Log.i("CinequestActivity:configureCalendarIcon",
+ "Error while retrieving Event details from Calendar");
+ }
+
+ int e_id = 0;
+ if (l_managedCursor.moveToFirst()) {
+ int l_colid = l_managedCursor
+ .getColumnIndex(proj[0]);
+ do {
+ e_id = l_managedCursor.getInt(l_colid);
+ } while (l_managedCursor.moveToNext());
+ }
+ Uri eventUri;
+ if (Build.VERSION.SDK_INT >= 8) {
+ eventUri = Uri
+ .parse("content://com.android.calendar/events");
+ } else {
+ // Calendar code for API level < 8, needs lot of
+ // testing.
+ // May be some of the paramters (that we are
+ // populating above), have different naming
+ // conventions in different API Levels
+ eventUri = Uri.parse("content://calendar/events");
+ }
+ Uri deleteUri = ContentUris.withAppendedId(eventUri,
+ e_id);
+ try {
+ int rows = getContentResolver().delete(deleteUri,
+ null, null);
+ if (rows == 1) {
+ button.setBackgroundResource(R.drawable.notincalendar);
+ button.setHint("notexist");
+ Toast toast = Toast.makeText(getContext(),
+ "Event removed from calendar",
+ Toast.LENGTH_SHORT);
+ toast.show();
+ }
+ } catch (Exception e) {
+ Log.i("CinequestActivity:configureCalendarIcon",
+ "Error while removing Events from Calendar");
+ }
+ l_managedCursor.close();
+ l_managedCursor = null;
+ }
+
+ else {
+ ContentValues l_event = new ContentValues();
+ l_event.put("calendar_id", m_selectedCalendarId);
+ l_event.put("title", s.getTitle());
+ l_event.put("description", s.getTitle());
+ l_event.put("eventLocation", s.getVenue());
+ // l_event.put("dtstart", System.currentTimeMillis());
+ // l_event.put("dtend", System.currentTimeMillis() +
+ // 1800*1000);
+ l_event.put("dtstart", begin);
+ l_event.put("dtend", end);
+ l_event.put("allDay", 0);
+ // status: 0~ tentative; 1~ confirmed; 2~ canceled
+ l_event.put("eventStatus", 1);
+ // 0~ default; 1~ confidential; 2~ private; 3~ public
+ // l_event.put("visibility", 1);
+ // 0~ opaque, no timing conflict is allowed; 1~
+ // transparency, allow overlap of scheduling
+ // l_event.put("transparency", 0);
+ // 0~ false; 1~ true
+ l_event.put("hasAlarm", 1);
+ l_event.put("eventTimezone", TimeZone.getDefault()
+ .getID());
+ Uri l_eventUri;
+ if (Build.VERSION.SDK_INT >= 8) {
+ l_eventUri = Uri
+ .parse("content://com.android.calendar/events");
+ } else {
+ // Calendar code for API level < 8, needs lot of
+ // testing.
+ // May be some of the paramters (that we are
+ // populating above), have different naming
+ // conventions in different API Levels
+ l_eventUri = Uri.parse("content://calendar/events");
+ }
+ try {
+ Uri l_uri = getContentResolver().insert(l_eventUri,
+ l_event);
+ Toast toast = Toast.makeText(getContext(),
+ "Event added to calendar",
+ Toast.LENGTH_SHORT);
+ toast.show();
+ button.setBackgroundResource(R.drawable.incalendar);
+ button.setHint("exists");
+ } catch (Exception e) {
+ Log.i("CinAct:configureCalIcon",
+ "Error while adding Events in Calendar");
+ }
+ }
+
+ }
+
+ });
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
- Schedule s = (Schedule) v.getTag();
+ Schedule s = (Schedule) v.getTag();
SimpleDateFormat formatter;
- if (s.getStartTime().charAt(10)=='T')
- formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
+ if (s.getStartTime().charAt(10) == 'T')
+ formatter = new SimpleDateFormat(
+ "yyyy-MM-dd'T'hh:mm:ss");
else
formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
@@ -289,152 +502,184 @@ public void onClick(View v) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
long begin = startDate.getTime();
- long end = endDate.getTime();
-
- if (button.getHint().toString()=="exists")
- {
- String[] proj = new String[]{
- "_id",
- "title",
- "dtstart",
- "dtend"};
-
- String calSelection = "((calendar_id= ?) " +
- "AND (" +
- "((dtstart= ?) " +
- "AND (dtend= ?) " +
- "AND (title= ?) " +
- ") " +
- ")" +
- ")";
+ long end = endDate.getTime();
+
+ if (button.getHint().toString() == "exists") {
+ String[] proj = new String[] { "_id", "title",
+ "dtstart", "dtend" };
+
+ String calSelection = "((calendar_id= ?) " + "AND ("
+ + "((dtstart= ?) " + "AND (dtend= ?) "
+ + "AND (title= ?) " + ") " + ")" + ")";
String[] calSelectionArgs = new String[] {
- m_selectedCalendarId, begin+"", end+"", s.getTitle()
- };
+ m_selectedCalendarId, begin + "", end + "",
+ s.getTitle() };
- Uri event=null;
- Cursor l_managedCursor=null;
+ Uri event = null;
+ Cursor l_managedCursor = null;
if (Build.VERSION.SDK_INT >= 8) {
- event = Uri.parse("content://com.android.calendar/events");
+ event = Uri
+ .parse("content://com.android.calendar/events");
} else {
- //Calendar code for API level < 8, needs lot of testing.
- //May be some of the paramters (that we are populating above), have different naming conventions in different API Levels
+ // Calendar code for API level < 8, needs lot of
+ // testing.
+ // May be some of the paramters (that we are
+ // populating above), have different naming
+ // conventions in different API Levels
event = Uri.parse("content://calendar/events");
}
- try{
- l_managedCursor = getContentResolver().query(event, proj, calSelection, calSelectionArgs, "dtstart DESC, dtend DESC");
+ try {
+ l_managedCursor = getContentResolver().query(event,
+ proj, calSelection, calSelectionArgs,
+ "dtstart DESC, dtend DESC");
+ } catch (Exception e) {
+ Log.i("CinequestActivity:configureCalendarIcon",
+ "Error while retrieving Event details from Calendar");
}
- catch (Exception e){
- Log.i("CinequestActivity:configureCalendarIcon","Error while retrieving Event details from Calendar");
- }
-
+
int e_id = 0;
- if (l_managedCursor.moveToFirst()) {
- int l_colid = l_managedCursor.getColumnIndex(proj[0]);
+ if (l_managedCursor.moveToFirst()) {
+ int l_colid = l_managedCursor
+ .getColumnIndex(proj[0]);
do {
- e_id = l_managedCursor.getInt(l_colid);
- }
- while (l_managedCursor.moveToNext());
+ e_id = l_managedCursor.getInt(l_colid);
+ } while (l_managedCursor.moveToNext());
}
- Uri eventUri;
+ Uri eventUri;
if (Build.VERSION.SDK_INT >= 8) {
- eventUri = Uri.parse("content://com.android.calendar/events");
+ eventUri = Uri
+ .parse("content://com.android.calendar/events");
} else {
- //Calendar code for API level < 8, needs lot of testing.
- //May be some of the paramters (that we are populating above), have different naming conventions in different API Levels
+ // Calendar code for API level < 8, needs lot of
+ // testing.
+ // May be some of the paramters (that we are
+ // populating above), have different naming
+ // conventions in different API Levels
eventUri = Uri.parse("content://calendar/events");
- }
- Uri deleteUri = ContentUris.withAppendedId(eventUri, e_id);
- try
- {
- int rows = getContentResolver().delete(deleteUri, null, null);
- if (rows==1){
+ }
+ Uri deleteUri = ContentUris.withAppendedId(eventUri,
+ e_id);
+ try {
+ int rows = getContentResolver().delete(deleteUri,
+ null, null);
+ if (rows == 1) {
button.setBackgroundResource(R.drawable.notincalendar);
button.setHint("notexist");
- Toast toast = Toast.makeText(getContext(), "Event removed from calendar", Toast.LENGTH_SHORT);
- toast.show();
+ Toast toast = Toast.makeText(getContext(),
+ "Event removed from calendar",
+ Toast.LENGTH_SHORT);
+ toast.show();
}
- }
- catch (Exception e){
- Log.i("CinequestActivity:configureCalendarIcon","Error while removing Events from Calendar");
+ } catch (Exception e) {
+ Log.i("CinequestActivity:configureCalendarIcon",
+ "Error while removing Events from Calendar");
}
l_managedCursor.close();
- l_managedCursor=null;
+ l_managedCursor = null;
}
- else{
+ else {
ContentValues l_event = new ContentValues();
l_event.put("calendar_id", m_selectedCalendarId);
l_event.put("title", s.getTitle());
l_event.put("description", s.getTitle());
l_event.put("eventLocation", s.getVenue());
- //l_event.put("dtstart", System.currentTimeMillis());
- //l_event.put("dtend", System.currentTimeMillis() + 1800*1000);
+ // l_event.put("dtstart", System.currentTimeMillis());
+ // l_event.put("dtend", System.currentTimeMillis() +
+ // 1800*1000);
l_event.put("dtstart", begin);
l_event.put("dtend", end);
l_event.put("allDay", 0);
- //status: 0~ tentative; 1~ confirmed; 2~ canceled
+ // status: 0~ tentative; 1~ confirmed; 2~ canceled
l_event.put("eventStatus", 1);
- //0~ default; 1~ confidential; 2~ private; 3~ public
- //l_event.put("visibility", 1);
- //0~ opaque, no timing conflict is allowed; 1~ transparency, allow overlap of scheduling
- //l_event.put("transparency", 0);
- //0~ false; 1~ true
+ // 0~ default; 1~ confidential; 2~ private; 3~ public
+ // l_event.put("visibility", 1);
+ // 0~ opaque, no timing conflict is allowed; 1~
+ // transparency, allow overlap of scheduling
+ // l_event.put("transparency", 0);
+ // 0~ false; 1~ true
l_event.put("hasAlarm", 1);
- l_event.put("eventTimezone", TimeZone.getDefault().getID());
+ l_event.put("eventTimezone", TimeZone.getDefault()
+ .getID());
Uri l_eventUri;
if (Build.VERSION.SDK_INT >= 8) {
- l_eventUri = Uri.parse("content://com.android.calendar/events");
+ l_eventUri = Uri
+ .parse("content://com.android.calendar/events");
} else {
- //Calendar code for API level < 8, needs lot of testing.
- //May be some of the paramters (that we are populating above), have different naming conventions in different API Levels
+ // Calendar code for API level < 8, needs lot of
+ // testing.
+ // May be some of the paramters (that we are
+ // populating above), have different naming
+ // conventions in different API Levels
l_eventUri = Uri.parse("content://calendar/events");
}
- try{
- Uri l_uri = getContentResolver().insert(l_eventUri, l_event);
- Toast toast = Toast.makeText(getContext(), "Event added to calendar", Toast.LENGTH_SHORT);
+ try {
+ Uri l_uri = getContentResolver().insert(l_eventUri,
+ l_event);
+ Toast toast = Toast.makeText(getContext(),
+ "Event added to calendar",
+ Toast.LENGTH_SHORT);
toast.show();
button.setBackgroundResource(R.drawable.incalendar);
button.setHint("exists");
- }
- catch (Exception e){
- Log.i("CinequestActivity:configureCalendarIcon","Error while adding Events in Calendar");
+ } catch (Exception e) {
+ Log.i("CinequestActivity:configureCalendarIcon",
+ "Error while adding Events in Calendar");
}
}
-
+
}
});
}
- }
+ }
/**
- * An adapter for a list of films. These lists occur (1) in the Films tab
+ * An adapter for a list of films. These lists occur (1) in the Films tab
* (when sorted by name) (2) in the DVDs tab and (3) in the detail view of a
* program item with multiple films.
*/
protected static class FilmletListAdapter extends ArrayAdapter {
private static final int RESOURCE_ID = R.layout.listitem_title_only;
-
- public FilmletListAdapter(Context context, List extends CommonItem> list)
+ private static List referenceToList;
+ public FilmletListAdapter(Context context,
+ List accumulate) {
+ super(context, RESOURCE_ID, referenceToList = (List) accumulate);
+ }
+
+ /**
+ * Returns the list that was passed
+ * */
+ public List getList()
{
- super(context, RESOURCE_ID, (List) list);
+ return referenceToList;
}
-
+ /*
+ * (non-Javadoc)
+ *
+ * @see android.widget.ArrayAdapter#getView(int, android.view.View,
+ * android.view.ViewGroup)
+ *
+ * @param position (int), view, and the parent ViewGroup
+ *
+ * @return the view
+ */
@Override
- public View getView(int position, View v, ViewGroup parent) {
+ public View getView(int position, View v, ViewGroup parent) {
if (v == null) {
- LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LayoutInflater inflater = (LayoutInflater) getContext()
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(RESOURCE_ID, null);
}
- CommonItem result = getItem(position);
+ CommonItem result = getItem(position);
TextView title = (TextView) v.findViewById(R.id.listitem_titletext);
- title.setText(result.getTitle());
- formatContents(v, title, result);
- return v;
+ title.setText(result.getTitle());
+ formatContents(v, title, result);
+ return v;
}
/**
@@ -442,22 +687,26 @@ public View getView(int position, View v, ViewGroup parent) {
*/
protected void formatContents(View v, TextView title, CommonItem result) {
}
- }
+ }
/**
- * Take the user to home activity
+ * Takes the user to home activity from the current activity.
*/
- private void goHome(){
+ private void goHome() {
Intent i = new Intent();
- i.setClass(this, MainTab.class);
+ i.setClass(this, MainTab.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
- private void goSchedule(){
- Intent i = new Intent();
- i.setClass(this, MainTab.class);
- i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+
+ /**
+ * Takes the user to the schedule activity from the current activity.
+ */
+ private void goSchedule() {
+ Intent i = new Intent();
+ i.setClass(this, ScheduleActivity.class);
+ i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.putExtra("open_tab", 4);
startActivity(i);
}
@@ -468,14 +717,15 @@ private void goSchedule(){
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(0, HOME_MENUOPTION_ID, 0,"Home").setIcon(R.drawable.home);
- menu.add(0, SCHEDULE_MENUOPTION_ID, 0,"Schedule").setIcon(R.drawable.schedule_icon);
- menu.add(0, ABOUT_MENUOPTION_ID, 0,"About").setIcon(R.drawable.about);
+ menu.add(0, HOME_MENUOPTION_ID, 0, "Home").setIcon(R.drawable.home);
+ menu.add(0, SCHEDULE_MENUOPTION_ID, 0, "Schedule").setIcon(
+ R.drawable.schedule_icon);
+ menu.add(0, ABOUT_MENUOPTION_ID, 0, "About").setIcon(R.drawable.about);
return true;
}
- /** Menu Item Click Listener*/
+ /** Menu Item Click Listener */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
@@ -496,37 +746,42 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
}
- //gets the calendar id for Cinequest
- public void populateCalendarID(){
- String[] proj = new String[]{"_id", "calendar_displayName"};
+
+ /**
+ * Gets the calendar id for Cinequest and populates it.
+ */
+ public void populateCalendarID() {
+ String[] proj = new String[] { "_id", "calendar_displayName" };
String calSelection = "(calendar_displayName= ?) ";
- String[] calSelectionArgs = new String[] {calendarName};
-
- Uri event=null;
-
+ String[] calSelectionArgs = new String[] { calendarName };
+
+ Uri event = null;
+
if (Build.VERSION.SDK_INT >= 8) {
event = Uri.parse("content://com.android.calendar/calendars");
} else {
- //Calendar code for API level < 8, needs lot of testing.
- //May be some of the paramters (that we are populating above), have different naming conventions in different API Levels
+ // Calendar code for API level < 8, needs lot of testing.
+ // May be some of the paramters (that we are populating above), have
+ // different naming conventions in different API Levels
event = Uri.parse("content://calendar/calendars");
- }
+ }
Cursor l_managedCursor = null;
- try{
- l_managedCursor = getContentResolver().query(event, proj, calSelection, calSelectionArgs, null );
+ try {
+ l_managedCursor = getContentResolver().query(event, proj,
+ calSelection, calSelectionArgs, null);
- if (l_managedCursor.moveToFirst()) {
+ if (l_managedCursor.moveToFirst()) {
int l_idCol = l_managedCursor.getColumnIndex(proj[0]);
- do {
- m_selectedCalendarId = l_managedCursor.getString(l_idCol);
- } while (l_managedCursor.moveToNext());
+ do {
+ m_selectedCalendarId = l_managedCursor.getString(l_idCol);
+ } while (l_managedCursor.moveToNext());
}
- }
- catch (Exception e){
- Log.i("CinequestActivity:populateCalendarID","Error while retrieving Cinequest Calendar ID from device Calendar");
+ } catch (Exception e) {
+ Log.i("CinequestActivity:populateCalendarID",
+ "Error while retrieving Cinequest Calendar ID from device Calendar");
}
l_managedCursor.close();
- l_managedCursor=null;
+ l_managedCursor = null;
}
}
diff --git a/Android/src/edu/sjsu/cinequest/ClearableEditText.java b/Android/src/edu/sjsu/cinequest/ClearableEditText.java
new file mode 100644
index 0000000..da3ab1c
--- /dev/null
+++ b/Android/src/edu/sjsu/cinequest/ClearableEditText.java
@@ -0,0 +1,104 @@
+package edu.sjsu.cinequest;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.EditText;
+
+
+public class ClearableEditText extends EditText {
+
+ public String defaultValue = "";
+ //final Drawable imgX = getResources().getDrawable(android.R.drawable.presence_offline); // X image
+ final Drawable imgX = getResources().getDrawable(R.drawable.ic_action_remove); // X image
+
+ public ClearableEditText(Context context) {
+ super(context);
+
+ init();
+ }
+
+ public ClearableEditText(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ init();
+ }
+
+ public ClearableEditText(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ init();
+ }
+
+
+ @SuppressLint("ClickableViewAccessibility")
+ void init() {
+
+ // Set bounds of our X button
+ imgX.setBounds(0, 0, imgX.getIntrinsicWidth(), imgX.getIntrinsicHeight());
+
+ // There may be initial text in the field, so we may need to display the button
+ manageClearButton();
+
+ this.setOnTouchListener(new OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+
+ ClearableEditText et = ClearableEditText.this;
+
+ // Is there an X showing?
+ if (et.getCompoundDrawables()[2] == null) return false;
+ // Only do this for up touches
+ if (event.getAction() != MotionEvent.ACTION_UP) return false;
+ // Is touch on our clear button?
+ if (event.getX() > et.getWidth() - et.getPaddingRight() - imgX.getIntrinsicWidth()) {
+ et.setText("");
+ ClearableEditText.this.removeClearButton();
+ }
+ return false;
+ }
+ });
+
+ this.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ ClearableEditText.this.manageClearButton();
+ }
+
+ @Override
+ public void afterTextChanged(Editable arg0) {
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+ });
+ }
+
+ void manageClearButton() {
+ if (this.getText().toString().equals("") )
+ removeClearButton();
+ else
+ addClearButton();
+ }
+ void addClearButton() {
+ this.setCompoundDrawables(this.getCompoundDrawables()[0],
+ this.getCompoundDrawables()[1],
+ imgX,
+ this.getCompoundDrawables()[3]);
+ }
+ void removeClearButton() {
+ this.setCompoundDrawables(this.getCompoundDrawables()[0],
+ this.getCompoundDrawables()[1],
+ null,
+ this.getCompoundDrawables()[3]);
+ }
+
+}
+
diff --git a/Android/src/edu/sjsu/cinequest/DialogPrompt.java b/Android/src/edu/sjsu/cinequest/DialogPrompt.java
index 23fa106..481b97f 100644
--- a/Android/src/edu/sjsu/cinequest/DialogPrompt.java
+++ b/Android/src/edu/sjsu/cinequest/DialogPrompt.java
@@ -14,7 +14,7 @@
import android.widget.Toast;
/**
- * The class with static methods to show varios classes of dialogs
+ * The class with static methods to show various classes of dialogs
* @author Prabhjeet Ghuman
*
*/
diff --git a/Android/src/edu/sjsu/cinequest/FilmDetail.java b/Android/src/edu/sjsu/cinequest/FilmDetail.java
index bd98d78..005ea4b 100644
--- a/Android/src/edu/sjsu/cinequest/FilmDetail.java
+++ b/Android/src/edu/sjsu/cinequest/FilmDetail.java
@@ -1,9 +1,9 @@
package edu.sjsu.cinequest;
+//credit goes to:http://stackoverflow.com/questions/2077008/android-intent-for-twitter-application
-import java.util.ArrayList;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.util.List;
-import java.util.Vector;
-
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
@@ -24,18 +24,7 @@
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
-
import com.commonsware.cwac.merge.MergeAdapter;
-import com.facebook.FacebookException;
-import com.facebook.FacebookOperationCanceledException;
-import com.facebook.Request;
-import com.facebook.Response;
-import com.facebook.Session;
-import com.facebook.SessionState;
-import com.facebook.model.GraphUser;
-import com.facebook.widget.WebDialog;
-import com.facebook.widget.WebDialog.OnCompleteListener;
-
import edu.sjsu.cinequest.comm.Callback;
import edu.sjsu.cinequest.comm.HParser;
import edu.sjsu.cinequest.comm.Platform;
@@ -43,6 +32,7 @@
import edu.sjsu.cinequest.comm.cinequestitem.Schedule;
public class FilmDetail extends CinequestActivity {
+ private static final String TAG = "Twitter Page!";
public static enum ItemType {FILM, PROGRAM_ITEM, DVD}
private ListView scheduleList;
private ListView includeList;
@@ -50,6 +40,7 @@ public static enum ItemType {FILM, PROGRAM_ITEM, DVD}
private String fbImage;
private String fbUrl;
private MergeAdapter myMergeAdapter;
+
private int includescnt;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -59,7 +50,7 @@ public void onCreate(Bundle savedInstanceState) {
ListView listView = (ListView) findViewById(R.id.ScheduleList);
View headerView = getLayoutInflater().inflate(
- R.layout.detail_layout, null);
+ R.layout.detail_layout, null);
listView.addHeaderView(headerView, null, false);
View footerView = getLayoutInflater().inflate(
@@ -70,10 +61,8 @@ public void onCreate(Bundle savedInstanceState) {
fbButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- //Check if a facebook session is available from existing app if not open one. // tanuvir-12Nov13
- loginToFacebook();
- //call the graph api to post to Users wall //tanuvir-12Nov13
- postToWall();
+ //This function posts to facebook
+ postOnFacebook();
}
});
@@ -84,23 +73,22 @@ public void onClick(View v) {
sendEmail();
}
});
-
- Button infoButton = (Button) findViewById(R.id.moreinfo);
- infoButton.setOnClickListener(new OnClickListener() {
+
+ Button infoButton = (Button) findViewById(R.id.moreinfo);
+ infoButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
openWebPage();
}
});
-
- Button youtubeButton = (Button) findViewById(R.id.youtube);
- youtubeButton.setOnClickListener(new OnClickListener() {
+
+ Button twitterButton = (Button) findViewById(R.id.twitter);
+ twitterButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- checkOnYoutube();
+ checkOnTwitter();
}
});
-
fetchServerData(getIntent().getExtras());
}
@@ -110,11 +98,10 @@ private void fetchServerData(Bundle b){
if (target instanceof CommonItem) {
// This happens when showing a film inside a program item
showFilm((CommonItem) target);
- }
-
+ }
}
- private void showSchedules(Vector schedules)
+ private void showSchedules(List schedules)
{
if (schedules.size() == 0) {
scheduleList.setAdapter(new ScheduleListAdapter(this, schedules));
@@ -129,17 +116,15 @@ protected void formatContents(View v, TextView title, TextView time, TextView ve
title.setTypeface(null, Typeface.NORMAL);
}
});
-
myMergeAdapter.addAdapter(adapter);
}
- private void showIncludes(final ArrayList includes)
+ private void showIncludes(final List includes)
{
if (includes.size() == 0) {
return;
}
-
SeparatedListAdapter adapter = new SeparatedListAdapter(this);
adapter.addSection("Includes",
new FilmletListAdapter(this, includes));
@@ -147,9 +132,7 @@ private void showIncludes(final ArrayList includes)
includescnt=adapter.getCount();
}
-
-
- private void showFilms(ArrayList extends CommonItem> films)
+ private void showFilms(List extends CommonItem> films)
{
FilmletListAdapter section = new FilmletListAdapter(this, (List) films);
if (films.size() == 0) {
@@ -169,7 +152,6 @@ public void onItemClick(AdapterView> parent, View view, int position,
scheduleList.setAdapter(adapter);
}
-
private static void addEntry(SpannableStringBuilder ssb, String tag, String s) {
if (s == null || s.equals("")) return;
ssb.append(tag);
@@ -181,9 +163,9 @@ private static void addEntry(SpannableStringBuilder ssb, String tag, String s) {
ssb.append("\n");
}
- private void showImage(final String imageURL, Vector urls) {
+ private void showImage(final String imageURL, List urls) {
if (imageURL == null) return;
- Bitmap bmp = (Bitmap) HomeActivity.getImageManager().getImage(imageURL, new Callback() {
+ Bitmap bmp = (Bitmap) SplashScreenActivity.getImageManager().getImage(imageURL, new Callback() {
@Override
public void invoke(Object result) {
Bitmap bmp = (Bitmap) result;
@@ -198,7 +180,7 @@ public void starting() {
public void failure(Throwable t) {
Platform.getInstance().log(t);
// Try once more
- HomeActivity.getImageManager().getImage(imageURL, new Callback() {
+ SplashScreenActivity.getImageManager().getImage(imageURL, new Callback() {
@Override
public void invoke(Object result) {
Bitmap bmp = (Bitmap) result;
@@ -241,8 +223,6 @@ private SpannableString createSpannableString(HParser parser)
return spstr;
}
-
-
public void showFilm(CommonItem in) {
fbTitle = in.getTitle();
fbImage = in.getImageURL();
@@ -257,7 +237,7 @@ public void showFilm(CommonItem in) {
tv.setText(createSpannableString(parser));
- showImage(in.getImageURL(), parser.getImageURLs());
+ showImage(in.getImageURL(), parser.getImageURLs()); // TODO: Are these image URLs still used?
SpannableStringBuilder ssb = new SpannableStringBuilder();
@@ -271,18 +251,17 @@ public void showFilm(CommonItem in) {
addEntry(ssb, "Country", in.getCountry());
addEntry(ssb, "Language", in.getLanguage());
addEntry(ssb, "Genre", in.getGenre());
- addEntry(ssb, "Film Info", in.getFilmInfo());
((TextView) findViewById(R.id.Properties)).setText(ssb);
- showIncludes(in.getCommonItems());
+ showIncludes(in.getChildItems());
showSchedules(in.getSchedules());
scheduleList.setAdapter(myMergeAdapter);
scheduleList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view, int position,
long id) {
- if (position>0 && position <=includescnt){
+ if (position>0 && position <=includescnt){
Object result = scheduleList.getItemAtPosition( position );
launchFilmDetail(result);
}
@@ -290,140 +269,62 @@ public void onItemClick(AdapterView> parent, View view, int position,
});
}
- //New function to login to facebook // tanuvir-12Nov13
- void loginToFacebook(){
- try {
- Log.d("MyFunc", "Before Login");
- Session.openActiveSession(this, true, new Session.StatusCallback() {
-
- // callback when session changes state
- @Override
- public void call(Session session, SessionState state,
- Exception exception) {
-
- Log.d("MyFunc", "Session Token=" + session.getAccessToken());
- Log.d("MyFunc", "Session Open or not =" + session.isOpened());
-
- if (session.isOpened()) {
-
- // make request to the /me API
- Request.executeMeRequestAsync(session,
- new Request.GraphUserCallback() {
-
- // callback after Graph API response with user
- // object
- @Override
- public void onCompleted(GraphUser user,
- Response response) {
- Log.d("MyFunc", "Request");
- if (user != null) {
- Log.d("MyFunc", "User: "+ user.getName());
- }
- }
- });
- }
- }
- });
-
- } catch (Exception e) {
- // TODO Auto-generated catch block
- Log.e("MyFunc", e.toString());
- }
+ //New function to to post a status on facebook
+ public void postOnFacebook()
+ {
+ if(fbUrl == null || fbUrl == "")
+ fbUrl = "http://www.cinequest.org/film-festival";
+ String message = '"' + fbTitle + '"';
+ message += "\nAt the Cinequest film festival";
+ String facebookURL = "https://facebook.com/dialog/feed?%20app_id=145634995501895%20&display=popup&caption="+ message +
+ "&link="+ fbUrl + "/dialog/feed%2Fdocs%2F%20&redirect_uri=https://www.facebook.com/";
+ Intent postToFacebook = new Intent(this,PostOnFacebook.class);
+ postToFacebook.putExtra("facebookURL", facebookURL);
+ startActivity(postToFacebook);
}
- //new function to post a status on facebook //tanuvir 12Nov13
- void postToWall(){
- try{
- if(fbImage == null || fbImage == "")
- fbImage = "http://www.cinequest.org/sites/default/files/styles/highlights/public/cqff24hero_970x360.jpg";
- if(fbUrl == null || fbUrl == "")
- fbUrl = "http://www.cinequest.org/film-festival";
- Log.d("MyFunc", "Before posting");
- Bundle params = new Bundle();
- params.putString("name","Is going to " + '"' + fbTitle + '"' );
- params.putString("caption", "at the Cinequest film festival");
- params.putString("description", "Cinequest provides the finest discovery bastion of international film premieres, technology, and more.");
- params.putString("link", fbUrl);
- params.putString("picture", fbImage);
- params.putString("message", "Is going to this movie");
-
- Log.d("Myfunc", "Params Created");
-
- WebDialog feedDialog = (
- new WebDialog.FeedDialogBuilder(FilmDetail.this,
- Session.getActiveSession(),
- params))
- .setOnCompleteListener(new OnCompleteListener() {
-
- public void onComplete(Bundle values,
- FacebookException error) {
- if (error == null) {
- // When the story is posted, echo the success
- // and the post Id.
- final String postId = values.getString("post_id");
- if (postId != null) {
- Toast.makeText(FilmDetail.this,"Successfully posted to your wall." ,Toast.LENGTH_SHORT).show();
- Log.d("Myfunc", "Post Id= " + postId);
- } else {
- // User clicked the Cancel button
- Toast.makeText(FilmDetail.this,"Share cancelled",Toast.LENGTH_SHORT).show();
- Log.d("Myfunc", "Post Cancelled");
- }
- } else if (error instanceof FacebookOperationCanceledException) {
- // User clicked the "x" button
- Toast.makeText(FilmDetail.this, "Share cancelled",Toast.LENGTH_SHORT).show();
- Log.d("Myfunc", "User Closed the Dialog");
- } else {
- // Generic, ex: network error
- Toast.makeText(FilmDetail.this,"Share failed.",Toast.LENGTH_SHORT).show();
- }
- }
-
- }).build();
- feedDialog.show();
- }
- catch (Exception e) {
- // TODO Auto-generated catch block
- Log.e("MyFunc", e.toString());
- }
-
- }
- private void onSessionStateChange(Session session, SessionState state, Exception exception) {
- if (state.isOpened()) {
- Log.d("Myfunc", "Logged in...");
- } else if (state.isClosed()) {
- Log.d("MyFunc", "Logged out...");
- }
- }
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- Log.d("MyFunc", "onActivityResult");
- Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
- }
public void sendEmail(){
- Intent i = new Intent(Intent.ACTION_SEND);
+ String email="";
+ Intent i = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
i.setType("message/rfc822");
- i.putExtra(Intent.EXTRA_EMAIL , new String[]{""});
+ i.putExtra(Intent.EXTRA_EMAIL , new String[] { email });
i.putExtra(Intent.EXTRA_SUBJECT, "Cinequest Film Festival : " + fbTitle);
i.putExtra(Intent.EXTRA_TEXT , "You should check this movie out : " + fbUrl);
try {
- startActivity(Intent.createChooser(i, "Send mail..."));
+ startActivity(Intent.createChooser(i, "Email"));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
-
}
+
public void openWebPage(){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(fbUrl));
startActivity(intent);
}
- public void checkOnYoutube(){
- // Launch the Youtube view with the relevant film name searched for
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse("https://www.youtube.com/results?search_query=" + fbTitle));
- startActivity(intent);
+ public static String urlEncode(String s) {
+ try {
+ return URLEncoder.encode(s, "UTF-8");
+ }
+ catch (UnsupportedEncodingException e) {
+ Log.i(TAG, "UTF-8 should always be supported", e);
+ throw new RuntimeException("URLEncoder.encode() failed for " + s);
+ }
}
+ public void checkOnTwitter(){
+ if(fbUrl == null || fbUrl == "")
+ fbUrl = "http://www.cinequest.org/film-festival";
+
+ String message = '"' + fbTitle + '"';
+ message += "at the Cinequest film festival";
+ message += "\n" + fbUrl + "\n";
+
+ String tweetUrl =
+ String.format("https://twitter.com/intent/tweet?text=%s&url=%s",
+ urlEncode(message), urlEncode("https://www.google.com/"));
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(tweetUrl));
+ startActivity(intent);
+ }
}
diff --git a/Android/src/edu/sjsu/cinequest/FilmsActivity.java b/Android/src/edu/sjsu/cinequest/FilmsActivity.java
deleted file mode 100644
index 9428024..0000000
--- a/Android/src/edu/sjsu/cinequest/FilmsActivity.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package edu.sjsu.cinequest;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.SortedSet;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-/**
- * Films tab of the app, showing the A-Z dates and the dates.
- */
-public class FilmsActivity extends CinequestActivity {
- private ListView listview;
- private ArrayAdapter adapter;
- private String tab;
- private SortedSet dates;
- public static final String ALPHA = "A - Z";
- DateUtils du = new DateUtils();
-
- // TODO: move menus down to CinequestActivity
-
- public void onCreate(Bundle savedInstanceState) {
- tab = getIntent().getExtras().getString("tab");
- super.onCreate(savedInstanceState);
- setContentView(R.layout.cinequest_tab_activity_layout);
- listview = (ListView) findViewById(R.id.cinequest_tabactivity_listview);
- adapter = new ArrayAdapter(this, R.layout.listitem_title_only);
- }
- private void displayList()
- {
- listview.setAdapter(adapter);
- listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position,
- long id) {
- String result;
- if (position > 0)
- result = (String) (dates.toArray())[position - 1];
- else
- result = ALPHA;
- Intent intent = new Intent();
- intent.setClass(FilmsActivity.this, FilmsActivity1.class);
- intent.putExtra("target", result);
- intent.putExtra("tab", tab);
- startActivity(intent);
- }
- });
-
- }
- public void onResume(){
- super.onResume();
- adapter.clear();
- if (tab.equalsIgnoreCase("films"))
- {
- HomeActivity.getQueryManager().getFilmDates (new ProgressMonitorCallback(this) {
- public void invoke(Object result) {
- super.invoke(result);
- dates = (SortedSet) result;
- adapter.add(ALPHA);
- for (String date : dates)
- {
- adapter.add(localizeDate(date));
- }
- }
- });
- displayList();
-
- }
- else if (tab.equalsIgnoreCase("events"))
- {
- HomeActivity.getQueryManager().getEventDates(new ProgressMonitorCallback(this) {
- public void invoke(Object result) {
- super.invoke(result);
- dates = (SortedSet) result;
- adapter.add(ALPHA);
- for (String date : dates)
- {
- adapter.add(localizeDate(date));
- }
- }
- });
- displayList();
-
- }
- else if (tab.equalsIgnoreCase("forums"))
- {
- HomeActivity.getQueryManager().getForumDates (new ProgressMonitorCallback(this) {
- public void invoke(Object result) {
- super.invoke(result);
- dates = (SortedSet) result;
- adapter.add(ALPHA);
- for (String date : dates)
- {
- adapter.add(localizeDate(date));
- }
-
- }
- });
- displayList();
- }
-
- }
-
- /**
- * This method will localize the given date according the device locale.
- *
- * @param inputDate The input date.
- * @return The equivalent date in device locale
- */
- private String localizeDate( String inputDate ) {
-
- SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
-
- Date date = null;
- try {
- date = fmt.parse(inputDate);
- } catch (ParseException e) {
- return inputDate;
- }
-
- DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
- return dateFormat.format(date);
- }
-}
diff --git a/Android/src/edu/sjsu/cinequest/FilmsActivity1.java b/Android/src/edu/sjsu/cinequest/FilmsActivity1.java
index ee62e1b..950ea38 100644
--- a/Android/src/edu/sjsu/cinequest/FilmsActivity1.java
+++ b/Android/src/edu/sjsu/cinequest/FilmsActivity1.java
@@ -1,34 +1,83 @@
package edu.sjsu.cinequest;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
import java.util.List;
+import java.util.Map.Entry;
+import java.util.SortedMap;
+import java.util.SortedSet;
import java.util.TreeMap;
-import java.util.Vector;
+import java.util.TreeSet;
+import android.annotation.SuppressLint;
import android.os.Bundle;
+import android.view.View;
+import android.widget.AbsListView;
+import android.widget.AbsListView.OnScrollListener;
+import android.widget.AdapterView;
+import android.widget.ListView;
+import android.widget.TextView;
import edu.sjsu.cinequest.comm.cinequestitem.CommonItem;
+import edu.sjsu.cinequest.comm.cinequestitem.Schedule;
/**
* Films tab of the app, showing the films for a given date.
* @author Prabhjeet Ghuman
* @author Chao
+ * @author Dmitri Dimov, Brian Guilardi, Charmi Shah
*/
-public class FilmsActivity1 extends CinequestTabActivity {
- private String target;
- private String tab;
- private static Vector mFilms_byTitle;
- private static TreeMap> mSchedule_byDate;
- private DateUtils du;
- //unique id's for menu options
- // private static final int SORT_MENUOPTION_ID = Menu.FIRST;
- //private static final int ADD_CONTEXTMENU_ID = Menu.FIRST + 1;
- private boolean isByDate() { return !target.equals(FilmsActivity.ALPHA); }
+public class FilmsActivity1 extends CinequestActivity
+{
+ private TextView nothingToday;
+ private TextView header;
+ private SortedMap> mSchedule_byDate;
+ private SeparatedListIndexedAdapter eventsAdapter;
+ private DateUtils du;
+ private ListView listview;
- public void onCreate(Bundle savedInstanceState) {
- target = getIntent().getExtras().getString("target");
- tab = getIntent().getExtras().getString("tab");
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setContentView(R.layout.cinequest_tab_activity_layout);
du = new DateUtils();
+ nothingToday = (TextView)FilmsActivity1.this.findViewById(R.id.msg_for_empty_schedyle);
+ listview = (ListView) FilmsActivity1.this.findViewById(R.id.cinequest_tabactivity_listview);
+ header = (TextView) FilmsActivity1.this.findViewById(R.id.textView1);
+ header.setVisibility(View.GONE);
+ registerForContextMenu(listview);
+ fetchServerData();
+ eventsAdapter = new SeparatedListIndexedAdapter(FilmsActivity1.this);
+ listview.setOnScrollListener(new OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {
+ }
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem,
+ int visibleItemCount, int totalItemCount) {
+ if(firstVisibleItem > 0)
+ {
+ Object[] temp = eventsAdapter.sections.keySet().toArray();
+ header.setVisibility(View.VISIBLE);
+ header.setText((String)temp[eventsAdapter.getPositionForSection(firstVisibleItem)]);
+ }
+ else
+ {
+ header.setVisibility(View.GONE);
+ }
+ }
+ });
+ listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position,
+ long id) {
+ Schedule result = (Schedule) listview.getItemAtPosition( position );
+ launchFilmDetail(result.getItem());
+ }
+ });
}
/**
@@ -39,111 +88,63 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onResume(){
super.onResume();
-
- //refresh the listview
- if(target.equals(FilmsActivity.ALPHA)) {
- refreshListContents(mFilms_byTitle);
- } else {
- refreshListContents(mSchedule_byDate);
- }
+ //We do not want to refresh, otherwise, user has to scroll all the way up,
+ //maybe the user wants to keep checking the list.
}
- @Override
protected void fetchServerData() {
- if(isByDate()) {
- if (tab.equalsIgnoreCase("films")){
- HomeActivity.getQueryManager().getFilmsByDate(target, new ProgressMonitorCallback(this) {
- @Override
- public void invoke(Object result) {
- super.invoke(result);
- mSchedule_byDate = (TreeMap>) result;
- refreshListContents(mSchedule_byDate);
- }
- });
- }
- else if(tab.equalsIgnoreCase("events")){
- HomeActivity.getQueryManager().getEventsByDate(target, new ProgressMonitorCallback(this) {
- @Override
- public void invoke(Object result) {
- super.invoke(result);
- mSchedule_byDate = (TreeMap>) result;
- refreshListContents(mSchedule_byDate);
- }
- });
- }
- else if(tab.equalsIgnoreCase("forums"))
- {
- HomeActivity.getQueryManager().getForumsByDate(target, new ProgressMonitorCallback(this) {
- @Override
- public void invoke(Object result) {
- super.invoke(result);
- mSchedule_byDate = (TreeMap>) result;
- refreshListContents(mSchedule_byDate);
- }
- });
- }
- }
- else
- {
- if (tab.equalsIgnoreCase("films")){
- HomeActivity.getQueryManager().getAllFilms (new ProgressMonitorCallback(this) {
- public void invoke(Object result) {
- super.invoke(result);
- mFilms_byTitle = (Vector) result;
- refreshListContents(mFilms_byTitle);
- }
- });
- }
- else if(tab.equalsIgnoreCase("events"))
- {
- HomeActivity.getQueryManager().getAllEvents (new ProgressMonitorCallback(this) {
- public void invoke(Object result) {
- super.invoke(result);
- mFilms_byTitle = (Vector) result;
- refreshListContents(mFilms_byTitle);
- }
- });
- }
- else if(tab.equalsIgnoreCase("forums"))
- {
- HomeActivity.getQueryManager().getAllForums (new ProgressMonitorCallback(this) {
- public void invoke(Object result) {
- super.invoke(result);
- mFilms_byTitle = (Vector) result;
- refreshListContents(mFilms_byTitle);
- }
- });
- }
- }
- }
+ SplashScreenActivity.getQueryManager().getSchedulesByDate(new ProgressMonitorCallback(this) {
+ public void invoke(Object result) {
+ super.invoke(result);
+ mSchedule_byDate = (SortedMap>) result;
+
+ for (final String date : mSchedule_byDate.keySet()) {
+ //List items = new ArrayList();
+ //for (Schedule s : mSchedule_byDate.get(date))
+ // items.add(s.getItem());
+ // FilmletListAdapter a = new FilmletListAdapter(FilmsActivity1.this, items);
+ List items = new ArrayList(mSchedule_byDate.get(date));
+ ScheduleListAdapter1 a = new ScheduleListAdapter1(FilmsActivity1.this, items);
+ eventsAdapter.addSection(localizeHumanFormat(date), "", a);
+ //Then show it once everything has been added!
+ eventsAdapter.setAsAdapterFor(listview);
+ if (eventsAdapter.getCount() == 0) {
+ listview.setVisibility(View.GONE);
+ nothingToday.setVisibility(View.VISIBLE);
+ } else {
+ listview.setVisibility(View.VISIBLE);
+ nothingToday.setVisibility(View.GONE);
+ }
+ }
+ }
+ });
+ }
- @Override
- protected void refreshListContents(List> listItems) {
- if (listItems == null) return;
- setListViewAdapter(createFilmletList((List) listItems));
+ /**
+ * Sets the message to show to user when listview is empty
+ * @param message String
+ */
+ protected final void setEmptyListviewMessage(String message){
+ nothingToday.setText(message);
}
- protected void refreshListContents(TreeMap> listItems) {
- boolean is24HourFormat=android.text.format.DateFormat.is24HourFormat(this);
- if (listItems == null) return;
- SeparatedListIndexedAdapter adapter = new SeparatedListIndexedAdapter(this);
- String formattedTime="";
- for (String titleInit : listItems.keySet()) {
- if(!is24HourFormat)
- {
- formattedTime=du.formatTime(titleInit);
- }
- else
- {
- formattedTime=titleInit;
- }
- adapter.addSection(
- formattedTime, titleInit,
- //titleInit, titleInit,
- new FilmletListAdapter(this, listItems.get(titleInit)));
- }
- setListViewAdapter(adapter);
+ /**
+ * This method returns date in Verbal Format
+ * */
+ private String localizeHumanFormat(String inputDate)
+ {
+ SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
+ Date date = null;
+ try {
+ date = fmt.parse(inputDate);
+ } catch (ParseException e1) {
+ e1.printStackTrace();
+ }
+ String dateInHumForm = (String)android.text.format.DateFormat.format("EEEE, MMMM dd", date);
+ String[] temp = dateInHumForm.split(" ");
+ int dayOfMonth = Integer.parseInt(temp[2]);
+ return temp[0] + " " + temp[1] + " " + dayOfMonth;
}
}
diff --git a/Android/src/edu/sjsu/cinequest/HomeActivity.java b/Android/src/edu/sjsu/cinequest/HomeActivity.java
deleted file mode 100644
index dd654a2..0000000
--- a/Android/src/edu/sjsu/cinequest/HomeActivity.java
+++ /dev/null
@@ -1,194 +0,0 @@
-package edu.sjsu.cinequest;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.net.Uri;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ImageView;
-import android.widget.ListView;
-import edu.sjsu.cinequest.comm.Callback;
-import edu.sjsu.cinequest.comm.ImageManager;
-import edu.sjsu.cinequest.comm.Platform;
-import edu.sjsu.cinequest.comm.QueryManager;
-import edu.sjsu.cinequest.comm.cinequestitem.News;
-import edu.sjsu.cinequest.comm.cinequestitem.NewsFeed;
-import edu.sjsu.cinequest.comm.cinequestitem.User;
-
-// TODO: Add click for each item; show the section info
-
-/**
- * The home screen of the app
- *
- * @author Prabhjeet Ghuman
- *
- */
-public class HomeActivity extends Activity {
- private ListView list;
- private String target;
- ImageView title_image;
-
- private static QueryManager queryManager;
- private static ImageManager imageManager;
- LazyAdapter adapter;
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.home_layout);
-
- // TODO: Remove this to turn on test mode
- // DateUtils.setMode(DateUtils.FESTIVAL_TEST_MODE);
- Context context = getApplicationContext();
- try {
- PackageInfo pi = context.getPackageManager().getPackageInfo(getPackageName(), 0);
- String version = pi.versionName;
- setTitle("Cinequest" + (version == null ? "" : " " + version));
- } catch (NameNotFoundException ex) {
- // We tried...
- }
-
- if (queryManager == null)
- {
- queryManager = new QueryManager();
- }
- imageManager = new ImageManager();
-
- list = (ListView)this.findViewById(R.id.home_newslist);
- }
-
- /**
- * Called when activity resumes
- */
- @Override
- public void onResume(){
- super.onResume();
- queryManager.getSpecialScreen("ihome", new Callback(){
- @Override
- public void invoke(Object result) {
- populateNewsEventsList((NewsFeed) result);
- // TODO: Why doesn't this work???
- if (!((NewsFeed) result).getLastUpdated().equalsIgnoreCase(queryManager.getlastUpdated()))
- queryManager.prefetchFestival();
- }
- @Override public void starting() {}
- @Override public void failure(Throwable t) {
- Platform.getInstance().log(t);
- }
- });
- }
-
- protected void onStop(){
- imageManager.close();
- Platform.getInstance().close();
- super.onStop();
- }
-
- /**
- * Display the header image and schedule to the user with
- * section-title being separator-header.
- */
-
- private void populateNewsEventsList(NewsFeed newsSections)
- {
- final List news=newsSections.getNewsList();
- ArrayList imgURL = new ArrayList();
- for (int i=0;i parent, View view, int position,
- long id) {
-
- final Intent intent;
- if (news.get(position).getInfoLink().trim().toLowerCase().startsWith("http"))
- {
-
- intent = new Intent(android.content.Intent.ACTION_VIEW,
- Uri.parse(news.get(position).getInfoLink()));
- startActivity(intent);
- }
- else
- {
- int itemId= Integer.parseInt(news.get(position).getInfoLink());
- intent = new Intent();
- intent.setClass(HomeActivity.this, FilmDetail.class);
-
- HomeActivity.getQueryManager().getCommonItem(new ProgressMonitorCallback(HomeActivity.this) {
- @Override
- public void invoke(Object result) {
- super.invoke(result);
- intent.putExtra("target", (Serializable) result);
- startActivity(intent);
-
- }
- }, itemId);
-
- }
- }
- });
- }
-
- /**
- * Get the QueryManager
- * @return queryManager
- */
- public static QueryManager getQueryManager() {
- return queryManager;
- }
-
- public static void setQueryManager(QueryManager q) {
- queryManager=q;
- }
-
- public static ImageManager getImageManager() {
- return imageManager;
- }
-
- /**
- * Create a menu to be displayed when user hits Menu key on device
- */
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.homeactivity_menu, menu);
-
- return true;
- }
-
- /** Menu Item Click Listener*/
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle item selection
- switch (item.getItemId()) {
- case R.id.menu_option_about:
- DialogPrompt.showAppAboutDialog(this);
- return true;
-
- default:
- return super.onOptionsItemSelected(item);
- }
-
- }
-}
diff --git a/Android/src/edu/sjsu/cinequest/HotPicksActivity.java b/Android/src/edu/sjsu/cinequest/HotPicksActivity.java
new file mode 100644
index 0000000..a37bc7a
--- /dev/null
+++ b/Android/src/edu/sjsu/cinequest/HotPicksActivity.java
@@ -0,0 +1,158 @@
+package edu.sjsu.cinequest;
+
+import android.content.Intent;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.Button;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import java.util.List;
+
+import edu.sjsu.cinequest.comm.cinequestitem.CommonItem;
+
+public class HotPicksActivity extends CinequestActivity {
+
+ private enum IndexType {TRENDING, VIDEOS}
+
+ private static List mTrending_byTitle;
+ private static List mVideos_byTitle;
+ private Button trendingButton;
+ private Button videosButton;
+ private ListView listview;
+ private TextView mEmptyListViewMessage;
+ private IndexType currentType;
+
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.hotpicks_activity_layout);
+ listview = (ListView) findViewById(R.id.hotpicks_activity_listview);
+ mEmptyListViewMessage = (TextView)this.findViewById(R.id.msg_for_empty_schedule);
+ listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position,
+ long id) {
+ if (currentType == IndexType.TRENDING) {
+ CommonItem result = mTrending_byTitle.get(position);
+ launchFilmDetail(result);
+ }
+ else {
+ CommonItem result = mVideos_byTitle.get(position);
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(result.getVideoURL())));
+ }
+
+ }
+ });
+
+ trendingButton = (Button) findViewById(R.id.hotpicks_activity_trending_button);
+ videosButton = (Button) findViewById(R.id.hotpicks_activity_videos_button);
+
+ trendingButton.setEnabled(true);
+ currentType = IndexType.TRENDING;
+
+ trendingButton.setBackgroundResource(R.drawable.enabledfilmsbutton);
+ trendingButton.setTextColor(Color.WHITE);
+ videosButton.setBackgroundResource(R.drawable.disabledeventsbutton);
+ videosButton.setTextColor(Color.RED);
+
+ registerForContextMenu(listview);
+
+ fetchServerData(currentType);
+ }
+
+ /**
+ * Gets called when user returns to this tab. Also gets called once after the
+ * onCreate() method too.
+ */
+
+ @Override
+ public void onResume(){
+ super.onResume();
+
+ if(currentType == IndexType.TRENDING){
+ refreshListContents(mTrending_byTitle);
+ }else{
+ refreshListContents(mVideos_byTitle);
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ // searchText.setText("");
+ };
+
+ private void fetchServerData(IndexType indexType) {
+ if (indexType == IndexType.TRENDING) {
+ SplashScreenActivity.getQueryManager().getTrending(
+ new ProgressMonitorCallback(this) {
+ public void invoke(Object result) {
+ super.invoke(result);
+ mTrending_byTitle = (List) result;
+ refreshListContents(mTrending_byTitle);
+ }
+ });
+ } else {
+ SplashScreenActivity.getQueryManager().getVideos(
+ new ProgressMonitorCallback(this) {
+ public void invoke(Object result) {
+ super.invoke(result);
+ mVideos_byTitle = (List) result;
+ refreshListContents(mVideos_byTitle);
+ }
+ });
+ }
+ }
+
+ private void refreshListContents(List> listItems) {
+ if (listItems == null)
+ return;
+ ListAdapter adp = createListWithIcons((List) listItems);
+ listview.setAdapter(adp);
+ // if there are no items in the list, hide the listview,
+ // and show the emptytextmsg, and vice versa
+ if (adp.getCount() == 0) {
+ listview.setVisibility(View.GONE);
+ mEmptyListViewMessage.setVisibility(View.VISIBLE);
+ } else {
+ listview.setVisibility(View.VISIBLE);
+ mEmptyListViewMessage.setVisibility(View.GONE);
+ }
+ }
+
+ public void trendingButtonOnClick(View view){
+ // searchText.setText("");
+ currentType = IndexType.TRENDING;
+ trendingButton.setEnabled(false);
+ videosButton.setEnabled(true);
+
+ trendingButton.setBackgroundResource(R.drawable.enabledfilmsbutton);
+ trendingButton.setTextColor(Color.WHITE);
+ videosButton.setBackgroundResource(R.drawable.disabledeventsbutton);
+ videosButton.setTextColor(Color.RED);
+
+ fetchServerData(currentType);
+ }
+
+ public void videosButtonOnclick(View view){
+ // searchText.setText("");
+ currentType = IndexType.VIDEOS;
+ videosButton.setEnabled(false);
+ trendingButton.setEnabled(true);
+
+ videosButton.setBackgroundResource(R.drawable.enabledeventsbutton);
+ videosButton.setTextColor(Color.WHITE);
+ trendingButton.setBackgroundResource(R.drawable.disabledfilmsbutton);
+ trendingButton.setTextColor(Color.RED);
+
+ fetchServerData(currentType);
+ }
+
+}
diff --git a/Android/src/edu/sjsu/cinequest/IndexActivity.java b/Android/src/edu/sjsu/cinequest/IndexActivity.java
new file mode 100644
index 0000000..ab94fdb
--- /dev/null
+++ b/Android/src/edu/sjsu/cinequest/IndexActivity.java
@@ -0,0 +1,212 @@
+package edu.sjsu.cinequest;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.View;
+import android.widget.Adapter;
+import android.widget.AdapterView;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.TextView;
+import edu.sjsu.cinequest.comm.cinequestitem.CommonItem;
+
+public class IndexActivity extends CinequestActivity {
+
+ private enum IndexType {FILMS, EVENTS}
+
+ private static List mFilms_byTitle;
+ private static List mEvents_byTitle;
+ private Button filmsButton;
+ private Button eventsButton;
+ private ListView listview;
+ private TextView mEmptyListViewMessage;
+ private SeparatedListIndexedAdapter adp;
+ private ClearableEditText searchText;
+ private boolean searchable = true;
+ private IndexType currentType;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.index_activity_layout);
+ listview = (ListView) findViewById(R.id.index_activity_listview);
+ mEmptyListViewMessage = (TextView)this.findViewById(R.id.msg_for_empty_schedule);
+ adp = new SeparatedListIndexedAdapter(this); //Creating the separatedListIndexedAdapter now
+ listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position,
+ long id) {
+ Object result = listview.getItemAtPosition( position );
+ launchFilmDetail(result);
+ }
+ });
+
+ filmsButton = (Button) findViewById(R.id.index_activity_films_button);
+ eventsButton = (Button) findViewById(R.id.index_activity_events_button);
+
+ filmsButton.setEnabled(true);
+ currentType = IndexType.FILMS;
+
+ filmsButton.setBackgroundResource(R.drawable.enabledfilmsbutton);
+ filmsButton.setTextColor(Color.WHITE);
+ eventsButton.setBackgroundResource(R.drawable.disabledeventsbutton);
+ eventsButton.setTextColor(Color.RED);
+
+ registerForContextMenu(listview);
+
+ fetchServerData(currentType);
+
+ listview.setTextFilterEnabled(searchable);
+
+ if (searchable) {
+
+ searchText = (ClearableEditText) findViewById(R.id.searchText);
+
+ searchText.setVisibility(View.VISIBLE);
+
+ searchText.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void afterTextChanged(Editable s) {}
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count,
+ int after) {}
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before,
+ int count) {
+ if (s.length() > 0) {
+ SeparatedListAdapter filterAdp = createFilterAdapter(s.toString());
+ listview.setAdapter(filterAdp);
+ } else {
+ adp.setAsAdapterFor(listview);
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Gets called when user returns to this tab. Also gets called once after the
+ * onCreate() method too.
+ */
+
+ @Override
+ public void onResume(){
+ super.onResume();
+
+ if(currentType == IndexType.FILMS){
+ refreshListContents(mFilms_byTitle);
+ }else{
+ refreshListContents(mEvents_byTitle);
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ searchText.setText("");
+ };
+
+ private void fetchServerData(IndexType indexType) {
+ if (indexType == IndexType.FILMS) {
+ SplashScreenActivity.getQueryManager().getAllFilms(
+ new ProgressMonitorCallback(this) {
+ public void invoke(Object result) {
+ super.invoke(result);
+ mFilms_byTitle = (List) result;
+ refreshListContents(mFilms_byTitle);
+ }
+ });
+ } else {
+ SplashScreenActivity.getQueryManager().getAllEvents(
+ new ProgressMonitorCallback(this) {
+ public void invoke(Object result) {
+ super.invoke(result);
+ mEvents_byTitle = (List) result;
+ refreshListContents(mEvents_byTitle);
+ }
+ });
+ }
+ }
+
+ private void refreshListContents(List> listItems) {
+ if (listItems == null)
+ return;
+ adp = (SeparatedListIndexedAdapter) createFilmletList((List) listItems);
+ adp.setAsAdapterFor(listview);
+ // if there are no items in the list, hide the listview,
+ // and show the emptytextmsg, and vice versa
+ if (adp.getCount() == 0) {
+ listview.setVisibility(View.GONE);
+ mEmptyListViewMessage.setVisibility(View.VISIBLE);
+ } else {
+ listview.setVisibility(View.VISIBLE);
+ mEmptyListViewMessage.setVisibility(View.GONE);
+ }
+ }
+
+ public void filmsButtonOnClick(View view){
+ searchText.setText("");
+ currentType = IndexType.FILMS;
+ filmsButton.setEnabled(false);
+ eventsButton.setEnabled(true);
+
+ filmsButton.setBackgroundResource(R.drawable.enabledfilmsbutton);
+ filmsButton.setTextColor(Color.WHITE);
+ eventsButton.setBackgroundResource(R.drawable.disabledeventsbutton);
+ eventsButton.setTextColor(Color.RED);
+
+ fetchServerData(currentType);
+ }
+
+ public void eventsButtonOnclick(View view){
+ searchText.setText("");
+ currentType = IndexType.EVENTS;
+ eventsButton.setEnabled(false);
+ filmsButton.setEnabled(true);
+
+ eventsButton.setBackgroundResource(R.drawable.enabledeventsbutton);
+ eventsButton.setTextColor(Color.WHITE);
+ filmsButton.setBackgroundResource(R.drawable.disabledfilmsbutton);
+ filmsButton.setTextColor(Color.RED);
+
+ fetchServerData(currentType);
+ }
+
+ private SeparatedListAdapter createFilterAdapter(String pattern) {
+ Map sections = adp.sections;
+ pattern = pattern.toLowerCase();
+ int count = 0, numItems = 0, i;
+ String headerTitle = "Found ";
+ CommonItem item = null;
+ List list = new ArrayList();
+ for (Adapter adapter : sections.values()) {
+ numItems = adapter.getCount();
+ for (i = 0; i < numItems; i++) {
+ item = (CommonItem) adapter.getItem(i);
+ if (item.getTitle().toLowerCase().contains(pattern)) {
+ list.add(item);
+ count++;
+ }
+ }
+ }
+
+ if (currentType == IndexType.FILMS)
+ headerTitle += count + " film(s)";
+ else
+ headerTitle += count + " event(s)";
+
+ FilmletListAdapter filmAdp = new CinequestActivity.FilmletListAdapter(this, list);
+ SeparatedListIndexedAdapter filterAdapter = new SeparatedListIndexedAdapter(this);
+ filterAdapter.addSection(headerTitle, filmAdp);
+
+ return filterAdapter;
+ }
+}
diff --git a/Android/src/edu/sjsu/cinequest/LazyAdapter.java b/Android/src/edu/sjsu/cinequest/LazyAdapter.java
index 2fca91f..8649f50 100644
--- a/Android/src/edu/sjsu/cinequest/LazyAdapter.java
+++ b/Android/src/edu/sjsu/cinequest/LazyAdapter.java
@@ -4,57 +4,87 @@
import android.app.Activity;
import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
+import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
-import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
-import edu.sjsu.cinequest.comm.cinequestitem.News;
-import edu.sjsu.cinequest.imageutils.ImageLoader;
+
+import edu.sjsu.cinequest.comm.Callback;
+import edu.sjsu.cinequest.comm.Platform;
public class LazyAdapter extends BaseAdapter {
-
- private Activity activity;
- private String[] data;
- private List news;
+ private String[] imageURLs;
+ private String[] itemStrings;
+
private static LayoutInflater inflater=null;
- public ImageLoader imageLoader;
+ // public ImageLoader imageLoader;
- public LazyAdapter(Activity a, String[] d, List news) {
- activity = a;
- data=d;
- this.news=news;
+ public LazyAdapter(Activity activity, String[] imageURLs, String[] itemStrings) {
+ this.imageURLs = imageURLs;
+ this.itemStrings = itemStrings;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- imageLoader=new ImageLoader(activity.getApplicationContext());
+ // imageLoader=new ImageLoader(activity.getApplicationContext());
}
+ /**
+ * @return the length of the String array imageURLs
+ */
public int getCount() {
- return data.length;
+ return imageURLs.length;
}
+ /**
+ * @return the position of a particular element
+ */
public Object getItem(int position) {
return position;
}
+ /**
+ * @return the associated Item ID of a particular element
+ */
public long getItemId(int position) {
return position;
}
+ /**
+ * @return a converts a View into TextView and an ImageView a specified location
+ */
public View getView(final int position, View convertView, ViewGroup parent) {
View vi=convertView;
+ //if the passed convertView doesn't exist, this will create a new instance
if(convertView==null)
vi = inflater.inflate(R.layout.row_listview_item, null);
+ //Generate the correct Views for the activity
TextView text=(TextView)vi.findViewById(R.id.text);;
- ImageView image=(ImageView)vi.findViewById(R.id.image);
- text.setText(news.get(position).getName());
- imageLoader.DisplayImage(data[position], image);
+ final ImageView image=(ImageView)vi.findViewById(R.id.image);
+ text.setText(itemStrings[position]);
+ //loads an image from the requested location
+
+ // TODO: Either go back to using ImageLoader and eliminate ImageManager, or the other way around
+
+ // imageLoader.displayImage(imageURLs[position], image);
+ SplashScreenActivity.getImageManager().getImage(imageURLs[position], new Callback() {
+ @Override
+ public void invoke(Object result) {
+ Bitmap bmp = (Bitmap) result;
+ image.setImageBitmap(bmp);
+ }
+
+ @Override
+ public void starting() {
+ }
+
+ @Override
+ public void failure(Throwable t) {
+ Platform.getInstance().log(t);
+ }
+ }, null, true);
return vi;
}
}
\ No newline at end of file
diff --git a/Android/src/edu/sjsu/cinequest/MainTab.java b/Android/src/edu/sjsu/cinequest/MainTab.java
index 34f6717..40b5787 100644
--- a/Android/src/edu/sjsu/cinequest/MainTab.java
+++ b/Android/src/edu/sjsu/cinequest/MainTab.java
@@ -1,50 +1,95 @@
package edu.sjsu.cinequest;
import android.app.TabActivity;
+import android.widget.TabHost.OnTabChangeListener;
+import android.widget.TextView;
import android.content.Intent;
+import android.graphics.Color;
import android.os.Bundle;
import android.widget.TabHost;
+/**
+ * Main tab is a tab that displays contents of Hot Picks, Films, Events, Forums,
+ * Schedule to the consumer. For easy navigation and information lookup. This
+ * tab is the head tab from which consumer can navigate all necessary film
+ * related information.
+ */
public class MainTab extends TabActivity {
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Get host object from super class
- TabHost tabHost = getTabHost();
+ final TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
- intent = new Intent().setClass(this, HomeActivity.class);
- spec = tabHost.newTabSpec("news").setIndicator("News",getResources().getDrawable(R.drawable.news)).setContent(intent);
+ intent = new Intent().setClass(this, HotPicksActivity.class);
+ spec = tabHost
+ .newTabSpec("hotpicks")
+ .setIndicator("Hot Picks", // TODO: Localize
+ getResources().getDrawable(R.drawable.ic_tab_news)) // TODO: New image?
+ .setContent(intent);
tabHost.addTab(spec);
// Create the intent associated with the activity
- intent = new Intent().setClass(this, FilmsActivity.class);
- intent.putExtra("tab", "films");
+ intent = new Intent().setClass(this, IndexActivity.class);
+ intent.putExtra("tab", "index");
// Create a new TabSpec with a name, an icon and intent
- spec = tabHost.newTabSpec("films").setIndicator("Films",getResources().getDrawable(R.drawable.film_icon)).setContent(intent);
+ spec = tabHost
+ .newTabSpec("index")
+ .setIndicator("Index",
+ getResources().getDrawable(R.drawable.ic_tab_film))
+ .setContent(intent);
// Add it to the tab
tabHost.addTab(spec);
- intent = new Intent().setClass(this, FilmsActivity.class);
- intent.putExtra("tab", "events");
- spec = tabHost.newTabSpec("events").setIndicator("Events",getResources().getDrawable(R.drawable.events_icon)).setContent(intent);
+ intent = new Intent().setClass(this, FilmsActivity1.class);
+ intent.putExtra("tab", "schedule");
+ spec = tabHost
+ .newTabSpec("schedule")
+ .setIndicator("Schedule",
+ getResources().getDrawable(R.drawable.ic_tab_schedule))
+ .setContent(intent);
tabHost.addTab(spec);
- intent = new Intent().setClass(this, FilmsActivity.class);
- intent.putExtra("tab", "forums");
- spec = tabHost.newTabSpec("forums").setIndicator("Forums",getResources().getDrawable(R.drawable.forums_icon)).setContent(intent);
- tabHost.addTab(spec);
-
- intent = new Intent().setClass(this, ScheduleActivity.class);
- spec = tabHost.newTabSpec("schedule").setIndicator("Schedule",getResources().getDrawable(R.drawable.schedule_icon)).setContent(intent);
+ intent = new Intent().setClass(this, ScheduleActivity.class);
+ spec = tabHost
+ .newTabSpec("My Cinequest")
+ .setIndicator("My Cinequest",
+ getResources().getDrawable(R.drawable.ic_tab_event))
+ .setContent(intent);
tabHost.addTab(spec);
// Default tab is the first tab.
int tab = getIntent().getIntExtra("open_tab", 0);
- tabHost.setCurrentTab(tab);
- }
+ tabHost.setCurrentTab(tab);
+
+ tabHost.setOnTabChangedListener(new OnTabChangeListener() {
+
+ @Override
+ public void onTabChanged(String arg0) {
+ // TODO Auto-generated method stub
+ setTabColor(tabHost);
+ }
+
+ });
+ setTabColor(tabHost);
+ }
+
+ //Set tab color and text size of last tab
+ public void setTabColor(TabHost tabHost){
+ for(int i=0; i < tabHost.getTabWidget().getChildCount(); i++)
+ {
+ tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.BLACK); //inactive tabs
+
+ }
+ tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.RED); //selected, active tabs
+ int k = tabHost.getTabWidget().getChildCount() - 1;
+ TextView tv = (TextView) tabHost.getTabWidget().getChildAt(k).findViewById(android.R.id.title);
+ tv.setTextSize(12);
+ }
+
}
diff --git a/Android/src/edu/sjsu/cinequest/PostOnFacebook.java b/Android/src/edu/sjsu/cinequest/PostOnFacebook.java
new file mode 100644
index 0000000..3f770a0
--- /dev/null
+++ b/Android/src/edu/sjsu/cinequest/PostOnFacebook.java
@@ -0,0 +1,27 @@
+package edu.sjsu.cinequest;
+//credit goes to Android Application Development Cookbook, Wei-Meng Lee
+import android.app.Activity;
+import android.os.Bundle;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+
+public class PostOnFacebook extends Activity
+{
+ private WebView postOnFacebook;
+ private String facebookURL;
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.facebookviewport);
+ postOnFacebook = (WebView) findViewById(R.id.WebView01);
+ facebookURL = getIntent().getExtras().getString("facebookURL");
+ postOnFacebook.setWebViewClient(new WebViewClient() { @Override
+ public boolean shouldOverrideUrlLoading(WebView view, String url) {
+ return (false); }
+ });
+ WebSettings webSettings = postOnFacebook.getSettings();
+ webSettings.setBuiltInZoomControls(false);
+ postOnFacebook.loadUrl(facebookURL);
+ postOnFacebook.goBackOrForward(1);
+ }
+}
\ No newline at end of file
diff --git a/Android/src/edu/sjsu/cinequest/ProgressMonitorCallback.java b/Android/src/edu/sjsu/cinequest/ProgressMonitorCallback.java
index 3c96d99..8d5cfbf 100644
--- a/Android/src/edu/sjsu/cinequest/ProgressMonitorCallback.java
+++ b/Android/src/edu/sjsu/cinequest/ProgressMonitorCallback.java
@@ -6,26 +6,48 @@
import edu.sjsu.cinequest.comm.CallbackException;
import edu.sjsu.cinequest.comm.Platform;
+/**
+ * Callback implementation for the Cinequest App
+ */
+
public class ProgressMonitorCallback implements Callback {
private ProgressDialog dialog;
private Context context;
private String message;
+ /**
+ * Calls second constructor method, which sets private variables
+ * to context and "Fetching data"
+ * @param context
+ */
public ProgressMonitorCallback(Context context) {
this(context, "Fetching Data");
}
-
+
+ /**
+ * Main constructor. Sets private variables context and message
+ * with input parameters
+ * @param context variable to be used in class methods
+ * @param message message to be displayed in class methods
+ */
public ProgressMonitorCallback(Context context, String message) {
this.context = context;
this.message = message;
}
-
+
+ /**
+ * Displays information dialog. Called on start up
+ */
@Override
public void starting() {
if (dialog == null)
dialog = ProgressDialog.show(context, "Cinequest", message);
}
+ /**
+ * Dismisses dialog (if not null)
+ * @param result unused input
+ */
@Override
public void invoke(Object result) {
if (dialog != null)
@@ -33,6 +55,12 @@ public void invoke(Object result) {
dialog = null;
}
+ /**
+ * Called if failure encountered.
+ * Throwable t is converted to message and displayed using a dialog
+ * prompt
+ * @param t the thrown error/exception to be shown to the user
+ */
@Override
public void failure(Throwable t) {
if (dialog != null)
diff --git a/Android/src/edu/sjsu/cinequest/ScheduleActivity.java b/Android/src/edu/sjsu/cinequest/ScheduleActivity.java
index 8cdf1b2..b44425b 100644
--- a/Android/src/edu/sjsu/cinequest/ScheduleActivity.java
+++ b/Android/src/edu/sjsu/cinequest/ScheduleActivity.java
@@ -1,5 +1,6 @@
package edu.sjsu.cinequest;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
@@ -7,10 +8,12 @@
import java.util.Comparator;
import java.util.Date;
import java.util.List;
+import java.util.Map.Entry;
-import android.app.Activity;
+import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.database.Cursor;
+import android.graphics.Color;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
@@ -20,16 +23,19 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import android.widget.AbsListView;
+import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
+import android.widget.AbsListView.OnScrollListener;
/**
* The Schedule Tab of the app
*
* @author Sravankumar Reddy Javaji
- *
+ * @author Dmitri Dimov
*/
class EventData {
@@ -85,37 +91,55 @@ else if (arg0.getSDateInMillis() < arg1.getSDateInMillis())
}
}
}
-public class ScheduleActivity extends Activity {
+
+/**
+ * Any film related events are going to be displayed with this class.
+ * Allows consumer to view any film related information with ScheduleActivity class.
+ */
+@SuppressLint("SimpleDateFormat")
+public class ScheduleActivity extends CinequestActivity {
ListView listView;
SimpleDateFormat sdf;
private DateUtils du;
String fStartTime="";
String fEndTime="";
boolean is24HourFormat=false;
- //Configuration config;
- //DateFormat dtformat;
private static String calendarName="Cinequest Calendar";
private static String m_selectedCalendarId = "Cinequest Calendar";
private static final String DATE_TIME_FORMAT = "MMM dd, yyyy'T'HH:mm";
private List events = new ArrayList();
+ private TextView nothingToday; //Shows an empty list when the list is empty
+ private TextView header;
+
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.schedulelayout);
sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
du = new DateUtils();
- //config = getApplicationContext().getResources().getConfiguration();
- //dtformat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, config.locale);
+ header = (TextView) this.findViewById(R.id.textView1);
+ header.setVisibility(View.GONE);
+ nothingToday = (TextView) this.findViewById(R.id.msg_for_empty_schedyle);
+ listView = (ListView) findViewById(R.id.schedule_listview);
+ registerForContextMenu(listView);
+ populateSchedule();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume(); // Always call the superclass method first
+ is24HourFormat=android.text.format.DateFormat.is24HourFormat(this);
+ events.clear();
+ populateSchedule();
}
public void populateSchedule()
{
-
String[] proj = new String[]{"_id", "calendar_displayName"};
String calSelection =
"(calendar_displayName= ?) ";
String[] calSelectionArgs = new String[] {
calendarName
- };
+ };
Uri event=null;
if (Build.VERSION.SDK_INT >= 8) {
@@ -138,7 +162,7 @@ public void populateSchedule()
}
}
catch (Exception e){
- Log.i("ScheduleActivity:populateSchedule","Error while retrieving Cinequest Calendar ID from device Calendar");
+ Log.i("SchAct:populateSchedule","Error while retrieving Cinequest Calendar ID from device Calendar");
}
l_managedCursor.close();
@@ -159,7 +183,7 @@ public void populateSchedule()
l_managedCursor = this.getContentResolver().query(l_eventUri, l_projection, "calendar_id=" + m_selectedCalendarId, null, "dtstart DESC, dtend DESC");
}
catch (Exception e){
- Log.i("ScheduleActivity:populateSchedule","Error while retrieving events from Cinequest Calendar");
+ Log.i("SchAct:populateSchedule","Error while retrieving events from Cinequest Calendar");
}
if (l_managedCursor.moveToFirst()) {
String l_title;
@@ -179,7 +203,7 @@ public void populateSchedule()
StartDateInMillis = Long.parseLong(l_managedCursor.getString(l_colBegin));
EventData edata= new EventData(e_id, l_title, l_begin, l_end, StartDateInMillis);
events.add(edata);
- }
+ }
while (l_managedCursor.moveToNext());
}
@@ -187,82 +211,165 @@ public void populateSchedule()
//Collections.sort(events, new EventData.CompName());
Collections.sort(events, new EventData.CompDate());
-
- ArrayAdapter adapter = new ArrayAdapter(
- this.getApplicationContext(), R.layout.eventlistview, events) {
+ final SeparatedListIndexedAdapter separatedSchedule = new SeparatedListIndexedAdapter(this){
@Override
- public View getView(final int position, View v, ViewGroup parent) {
+ public View getView(int position, View v, ViewGroup parent){
+ int sectionnum = 0;
+ Object[] temp = sections.keySet().toArray();
+ for(Object section : this.sections.keySet()) {
+ Adapter adapter = sections.get(section);
+ int size = adapter.getCount() + 1;
- LayoutInflater inflater = LayoutInflater.from(getContext());
- final EventData q = getItem(position);
- if (v == null) v = inflater.inflate(R.layout.eventlistview, null);
- TextView textView = (TextView) v.findViewById(R.id.eventName);
- textView.setText(q.getName());
-
- String sStr[]=q.getStime().split("T");
- String eStr[]=q.getEtime().split("T");
- TextView textView1 = (TextView) v.findViewById(R.id.startTime);
- //if start date and end date of event won't match, then we will be displaying both the dates.
- //Else we will display only date once, followed by time.
- if (sStr[0].equalsIgnoreCase(eStr[0]))
- {
- if(!is24HourFormat)
+ // check if position inside this section
+ if(position == 0)
{
-
- fStartTime=du.formatTime(sStr[1]);
- fEndTime=du.formatTime(eStr[1]);
+ v = View.inflate(adapterContext, R.layout.list_header, null);
+ TextView t = (TextView) v.findViewById(R.id.list_header_title);
+ t.setText((String)temp[sectionnum]);
+ return v;
}
- else
+ else if(position < size && size > 1)
{
- fStartTime=sStr[1];
- fEndTime=eStr[1];
- }
- textView1.setText(sStr[0]+" Time: "+fStartTime+" - "+fEndTime);
- }
- else
- {
- textView1.setText(sStr[0]+" "+sStr[1]+" - "+eStr[0]+" "+eStr[1]);
- }
- textView1.setTypeface(null, Typeface.ITALIC);
+ LayoutInflater inflater = LayoutInflater.from(getBaseContext());
+ final EventData q = (EventData) adapter.getItem(position - 1);
+ if (v == null) v = inflater.inflate(R.layout.eventlistview, null);
+ TextView textView = (TextView) v.findViewById(R.id.eventName);
+ textView.setText(q.getName());
- Button button1 = (Button) v.findViewById(R.id.remove);
- button1.setOnClickListener( new OnClickListener() {
- @Override
- public void onClick(View v) {
- Uri eventUri;
- if (Build.VERSION.SDK_INT >= 8) {
- eventUri = Uri.parse("content://com.android.calendar/events");
- } else {
- //Calendar code for API level < 8, needs lot of testing.
- //May be some of the paramters (that we are populating above), have different naming conventions in different API Levels
- eventUri = Uri.parse("content://calendar/events");
- }
- Uri deleteUri = ContentUris.withAppendedId(eventUri, q.getEId());
- try{
- int rows = getContentResolver().delete(deleteUri, null, null);
- if (rows==1){
- events.remove(position);
- listView.invalidateViews();
+ String sStr[]=q.getStime().split("T");
+ String eStr[]=q.getEtime().split("T");
+
+ TextView textView1 = (TextView) v.findViewById(R.id.startTime);
+ //if start date and end date of event won't match, then we will be displaying both the dates.
+ //Else we will display only date once, followed by time.
+ if (sStr[0].equalsIgnoreCase(eStr[0]))
+ {
+ if(!is24HourFormat)
+ {
+ fStartTime=du.formatTime(sStr[1]);
+ fEndTime=du.formatTime(eStr[1]);
+ }
+ else
+ {
+ fStartTime=sStr[1];
+ fEndTime=eStr[1];
}
+ textView1.setText(sStr[0]+" Time: "+fStartTime+" - "+fEndTime);
}
- catch (Exception e){
- Log.i("ScheduleActivity:populateSchedule","Error while removing Events from Calendar");
+ else
+ {
+ textView1.setText(sStr[0]+" "+sStr[1]+" - "+eStr[0]+" "+eStr[1]);
}
-
+ textView1.setTypeface(null, Typeface.ITALIC);
+ Button button1 = (Button) v.findViewById(R.id.remove);
+ button1.setOnClickListener( new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Uri eventUri;
+ if (Build.VERSION.SDK_INT >= 8) {
+ eventUri = Uri.parse("content://com.android.calendar/events");
+ } else {
+ //Calendar code for API level < 8, needs lot of testing.
+ //May be some of the parameters (that we are populating above), have different naming conventions in different API Levels
+ eventUri = Uri.parse("content://calendar/events");
+ }
+ String day = localizeHumanFormat(q.getStime());
+ Uri deleteUri = ContentUris.withAppendedId(eventUri, q.getEId());
+ try{
+ int rows = getContentResolver().delete(deleteUri, null, null);
+ if (rows == 1){
+ //remove object from adapter
+ ((ArrayAdapter)sections.get(day)).remove(q);
+ //
+ events.remove(q);
+ if(sections.get(day).getCount() == 0)
+ { //only if there is no more objects in adapter
+ sections.remove(day);
+ }
+ notifyDataSetChanged();
+ }
+ }
+ catch (Exception e){
+ Log.i("ScheduleActivity:populateSchedule","Error while removing Events from Calendar");
+ }
+ }
+ });
+ return v;
}
- });
- return v;
- }
+ // otherwise jump into next section
+ position -= size;
+ sectionnum++;
+ }
+ v = new View(getApplicationContext());
+ v.setBackgroundColor(Color.BLACK);
+ return v;
+ }
};
- listView = (ListView) findViewById(R.id.schedule_listview);
- listView.setAdapter(adapter);
+ listView.setOnScrollListener(new OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {
+ }
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem,
+ int visibleItemCount, int totalItemCount) {
+ if(firstVisibleItem > 0)
+ {
+ Object[] temp = separatedSchedule.sections.keySet().toArray();
+ header.setVisibility(View.VISIBLE);
+ header.setText((String)temp[separatedSchedule.getPositionForSection(firstVisibleItem)]);
+ }
+ else
+ {
+ header.setVisibility(View.GONE);
+ }
+ }
+ });
+
+ for(EventData ev: events) //populates separated list indexed adapters
+ {
+ String day = localizeHumanFormat(ev.getStime());
+ if(separatedSchedule.haveSection(day))
+ {
+ ((ArrayAdapter)separatedSchedule.getAdapterForSection(day)).add(ev);
+ }
+ else
+ {
+ ArrayAdapter temp = new ArrayAdapter(this, R.layout.eventlistview);
+ temp.add(ev);
+ separatedSchedule.addSection(day, temp);
+ }
+ }
+ separatedSchedule.setAsAdapterFor(listView);
- listView.setItemsCanFocus(false);
+ if(separatedSchedule.getCount() == 0){
+ listView.setVisibility(View.GONE);
+ nothingToday.setVisibility(View.VISIBLE);
+ }else{
+ listView.setVisibility(View.VISIBLE);
+ nothingToday.setVisibility(View.GONE);
+ }
+ listView.setFocusable(false);
l_managedCursor.close();
l_managedCursor=null;
}
+ @SuppressLint("SimpleDateFormat")
+ private String localizeHumanFormat(String inputDate)
+ {
+ SimpleDateFormat fmt = new SimpleDateFormat(DATE_TIME_FORMAT);
+ Date date = null;
+ try {
+ date = fmt.parse(inputDate);
+ } catch (ParseException e1) {
+ e1.printStackTrace();
+ }
+ String dateInHumForm = (String)android.text.format.DateFormat.format("EEEE, MMMM dd", date);
+ String[] temp = dateInHumForm.split(" ");
+ int dayOfMonth = Integer.parseInt(temp[2]);
+ return temp[0] + " " + temp[1] + " " + dayOfMonth;
+ }
+ @SuppressWarnings("deprecation")
public static String getDateTimeStr(int p_delay_min) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
@@ -278,15 +385,5 @@ public static String getDateTimeStr(int p_delay_min) {
public String getDateTimeStr(String p_time_in_millis) {
Date l_time = new Date(Long.parseLong(p_time_in_millis));
return sdf.format(l_time);
- //return dtformat.format(l_time); //to get the locale date
}
-
- @Override
- protected void onResume() {
- super.onResume(); // Always call the superclass method first
- is24HourFormat=android.text.format.DateFormat.is24HourFormat(this);
- events.clear();
- populateSchedule();
- }
}
-
diff --git a/Android/src/edu/sjsu/cinequest/SectionAdapter.java b/Android/src/edu/sjsu/cinequest/SectionAdapter.java
index 6a19722..5d3d3e7 100644
--- a/Android/src/edu/sjsu/cinequest/SectionAdapter.java
+++ b/Android/src/edu/sjsu/cinequest/SectionAdapter.java
@@ -38,9 +38,7 @@ public SectionAdapter(Context context, int resourceId, List list)
layout_resourceId = resourceId;
if (list != null && list.size() > 0) {
- /*if(list.get(0) instanceof Filmlet)
- sectionType = SectionItems.TYPE_FILMLET;
- else*/ if(list.get(0) instanceof Schedule)
+ if(list.get(0) instanceof Schedule)
sectionType = SectionItems.TYPE_SCHEDULE;
}
diff --git a/Android/src/edu/sjsu/cinequest/SeparatedListAdapter.java b/Android/src/edu/sjsu/cinequest/SeparatedListAdapter.java
index 1f789ae..f1fa384 100644
--- a/Android/src/edu/sjsu/cinequest/SeparatedListAdapter.java
+++ b/Android/src/edu/sjsu/cinequest/SeparatedListAdapter.java
@@ -1,140 +1,187 @@
package edu.sjsu.cinequest;
// http://blogingtutorials.blogspot.com/2010/09/separating-lists-with-headers-in.html
+// http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/
+// just added the second link that has the same content as the first link, but it shows the image of separating lists with headers.
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Vector;
-
+import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
-import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
+import android.widget.TextView;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.TreeMap;
+
import edu.sjsu.cinequest.comm.cinequestitem.Schedule;
-public class SeparatedListAdapter extends BaseAdapter {
- public final Map sections = new LinkedHashMap();
- public final ArrayAdapter headers;
- public Vector list;
- public final static int TYPE_SECTION_HEADER = 0;
-
- public SeparatedListAdapter(Context context) {
- headers = new ArrayAdapter(context, R.layout.list_header);
- }
-
- public void setList(Vector list)
- {
- this.list = list;
- }
- public void addSection(String section, Adapter adapter) {
- this.headers.add(section);
- this.sections.put(section, adapter);
- }
-
-
+/*
+ * A separating list adapter with headers that can be used in listview.
+ */
+public class SeparatedListAdapter extends BaseAdapter
+{
+ public TreeMap sections = new TreeMap(new Comparator() {
+ public int compare(String a, String b) {
+ String[] temp1 = a.split(" ");
+ String[] temp2 = b.split(" ");
+ if(temp1.length > 1 && temp2.length > 1 && temp1[2].matches("\\d+(\\.\\d+)?") && temp2[2].matches("\\d+(\\.\\d+)?"))
+ {
+ if(temp1[1].compareTo(temp2[1]) == 0 && Integer.parseInt(temp1[2]) > Integer.parseInt(temp2[2]) ||
+ temp1[1].compareTo(temp2[1]) > 0)
+ { return 1; }
+ else if(Integer.parseInt(temp1[2]) == Integer.parseInt(temp2[2]))
+ { return 0; }
+ else { return -1; }
+ }
+ else{
+ return a.compareTo(b);
+ }
+ }
+ });
+ public List list;
+ public final static int TYPE_SECTION_HEADER = 0;
+ public Context adapterContext;
+ public SeparatedListAdapter(Context context) {
+ adapterContext = context;
+ }
+
+ public void setList(List list)
+ {
+ this.list = list;
+ }
+
+ public void addSection(String section, Adapter adapter) {
+ this.sections.put(section, adapter);
+ }
+
+ /**
+ * Removes a section from sections including headers
+ * */
+ public void removeSection(String section)
+ {
+ if(section.contains(section))
+ {
+ sections.remove(section);
+ }
+ }
+
+ /*
+ * Get the number of items in the data set represented by this adapter.
+ * @return the number of all sections in listview.
+ */
public int getCount() {
// total together all sections, plus one for each section header
- int total = 0;
- for(Adapter adapter : this.sections.values())
- total += adapter.getCount() + 1;
- return total;
+ int total = 0;
+ for(Adapter adapter : this.sections.values())
+ total += adapter.getCount() + 1;
+ return total;
}
+ /*
+ * Get the data item associated with the specified position in the data set
+ */
public Object getItem(int position) {
//If the list is used to store the sections, return from it
if(list != null){
Schedule schedule = list.get(position-1);
return schedule;
}
-
//else return from the sections Map
for(Object section : this.sections.keySet()) {
- Adapter adapter = sections.get(section);
-
- int size = adapter.getCount() + 1;
-
- // check if position inside this section
- if(position == 0) return section;
- if(position < size) return adapter.getItem(position - 1);
-
- // otherwise jump into next section
- position -= size;
- }
+ Adapter adapter = sections.get(section);
+
+ int size = adapter.getCount() + 1;
+
+ // check if position inside this section
+ if(position == 0) return section;
+ else if(position < size){ return adapter.getItem(position - 1); }
+
+ // otherwise jump into next section
+ position -= size;
+ }
return null;
-
}
+ /*
+ * Get the number of types of views that will be created by getView().
+ */
public int getViewTypeCount() {
- // assume that headers count as one, then total all sections
- int total = 1;
- for(Adapter adapter : this.sections.values())
- total += adapter.getViewTypeCount();
- return total;
- }
-
- public int getItemViewType(int position) {
- int type = 1;
- for(Object section : this.sections.keySet()) {
- Adapter adapter = sections.get(section);
- int size = adapter.getCount() + 1;
-
- // check if position inside this section
- if(position == 0) return TYPE_SECTION_HEADER;
- if(position < size) return type + adapter.getItemViewType(position - 1);
-
- // otherwise jump into next section
- position -= size;
- type += adapter.getViewTypeCount();
- }
- return -1;
- }
-
- public boolean areAllItemsSelectable() {
- return false;
- }
-
- public boolean isEnabled(int position) {
- return (getItemViewType(position) != TYPE_SECTION_HEADER);
- }
-
+ // assume that headers count as one, then total all sections
+ int total = 1;
+ for(Adapter adapter : this.sections.values())
+ total += adapter.getViewTypeCount();
+ return total;
+ }
+
+ /*
+ * Get the type of View that will be created by getView().
+ */
+ public int getItemViewType(int position)
+ {
+ int type = 1;
+ for(Object section : this.sections.keySet()) {
+ Adapter adapter = sections.get(section);
+ int size = adapter.getCount() + 1;
+
+ // check if position inside this section
+ if(position == 0) return TYPE_SECTION_HEADER;
+ else if(position < size) return type + adapter.getItemViewType(position - 1);
+
+ // otherwise jump into next section
+ position -= size;
+ type += adapter.getViewTypeCount();
+ }
+ return -1;
+ }
+
+ /*
+ * Indicates whether all the items in this adapter are selectable.
+ */
+ public boolean areAllItemsSelectable() {
+ return false;
+ }
+
+ /*
+ * Indicates whether the item at the specified position is enabled.
+ */
+ public boolean isEnabled(int position) {
+ return (getItemViewType(position) != TYPE_SECTION_HEADER);
+ }
+
+ /*
+ * Get the row id associated with the specified position in the list.
+ */
public long getItemId(int position) {
return position;
}
- /* public void bindView( View view, Context context, Cursor cursor){
- CheckBox checker = (CheckBox)view.findViewById(R.id.CheckBox);
-
- // checker.setOnCheckedChangeListener(context);
- checker.setTag(Long.valueOf(cursor.getLong(cursor.getColumnIndex(BaseColumns._ID))));
- // call super class for default binding
- super.getView(view,context,cursor);
- }
-*/
- public View getView(int position, View convertView, ViewGroup parent) {
- /* CheckBox checker = (CheckBox)convertView.findViewById(R.id.CheckBox);
-
- // checker.setOnCheckedChangeListener(context);
- checker.setTag(position);
- // call super class for default binding
- // super.getView(view,context,cursor);
- * */
-
- int sectionnum = 0;
- for(Object section : this.sections.keySet()) {
- Adapter adapter = sections.get(section);
- int size = adapter.getCount() + 1;
-
- // check if position inside this section
- if(position == 0) return headers.getView(sectionnum, convertView, parent);
- if(position < size) return adapter.getView(position - 1, convertView, parent);
-
- // otherwise jump into next section
- position -= size;
- sectionnum++;
- }
+ /*
+ * Get a view that displays the data at the specified position in the data set.
+ */
+ @SuppressLint("NewApi")
+ public View getView(int position, View convertView, ViewGroup parent){
+ int sectionnum = 0;
+ Object[] temp = sections.keySet().toArray();
+ for(Object section : this.sections.keySet()) {
+ Adapter adapter = sections.get(section);
+ int size = adapter.getCount() + 1;
+
+ if(position == 0)
+ {
+ View v = View.inflate(adapterContext, R.layout.list_header, null);
+ TextView t = (TextView) v.findViewById(R.id.list_header_title);
+ t.setText((String)temp[sectionnum]);
+ return v;
+ }
+ else if(position < size) return adapter.getView(position - 1, convertView, parent);
+
+ // otherwise jump into next section
+ position -= size;
+ sectionnum++;
+ }
return null;
}
-
}
diff --git a/Android/src/edu/sjsu/cinequest/SeparatedListIndexedAdapter.java b/Android/src/edu/sjsu/cinequest/SeparatedListIndexedAdapter.java
index 9f70fd2..2f06e2e 100644
--- a/Android/src/edu/sjsu/cinequest/SeparatedListIndexedAdapter.java
+++ b/Android/src/edu/sjsu/cinequest/SeparatedListIndexedAdapter.java
@@ -1,11 +1,17 @@
package edu.sjsu.cinequest;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
+import edu.sjsu.cinequest.comm.cinequestitem.CommonItem;
import android.content.Context;
import android.widget.Adapter;
import android.widget.LinearLayout;
@@ -43,23 +49,17 @@ public class SeparatedListIndexedAdapter extends SeparatedListAdapter
private HashMap alphaIndexer;
private String[] sectionKeys;
- ArrayList keyList = new ArrayList();
+ List keyList = new ArrayList();
private int currPosition = 0;
private boolean currWidthFillParent = true;
private ListView listview;
private boolean SortKeysFirst = false;
-
+ //SeparatedListAdapter now sorts by default
public SeparatedListIndexedAdapter(Context context) {
super(context);
alphaIndexer = new HashMap();
}
- //if you want keys sorted first, use this constructor, and set sortkeys=true
- public SeparatedListIndexedAdapter(Context context, boolean sortkeys) {
- this(context);
- SortKeysFirst = sortkeys;
- }
-
public void setAsAdapterFor(ListView listview){
this.listview = listview;
@@ -75,96 +75,65 @@ else if(booleanfromid == 1)
this.listview.setFastScrollEnabled(true);
}
-
public void addSection(String section, String sectionKey, Adapter adapter) {
super.addSection(section, adapter);
-
keyList.add(sectionKey);
alphaIndexer.put(sectionKey, currPosition);
currPosition += adapter.getCount() + 1;
}
+
+ @Override
+ public int getSectionForPosition(int position) {
+ return 0;
+ }
/**
- * build the sectionKeys array, which will hold the values of keys to
- * display on screen
- */
- public void buildIndex(){
- if(SortKeysFirst == true){
- Set keys = alphaIndexer.keySet();
- keyList = new ArrayList();
- Iterator it = keys.iterator();
- while (it.hasNext()) {
- String key = it.next();
- keyList.add(key);
- }
-
- Collections.sort(keyList);
- }
-
- //now create the array containing keys which will be returned next
- sectionKeys = new String[keyList.size()];
- keyList.toArray(sectionKeys);
-
- //fix key's screen placement bug
- fixScreenKeyPlacement();
+ * Verifies, if this sections already exists
+ * */
+ public boolean haveSection(String sectionKey)
+ {
+ return sections.containsKey(sectionKey);
}
/**
- * Using such SectionIndexer with changing data sections does not refresh the
- * sections cache and it keeps reusing the first set of sections. In order
- * to make it recreate sections, we can do listview.setFastScrollEnabled(false)
- * and then listview.setFastScrollEnabled(true), but this will start creating
- * the sections keys to appear in top left corner half-hidden. Using the method
- * below is a hard-wired fix for such issue. Any better and optimal fix is
- * yet not known.
- * The solution is - every time the data set changes, change the listview
- * width by 1pixel at least. So if it is filling screen, reduce it one pixel
- * else make it fill screen again. We are using "currWidthFillParent" boolean to
- * keep track of screen width.
- *
- * problem:
- * http://stackoverflow.com/questions/3898749/re-index-refresh-a-sectionindexer
- *
- * solution:
- * http://groups.google.com/group/android-developers/browse_thread/thread/
- * 2c24970bf355c556/a47dd42737dd5ce4?show_docid=a47dd42737dd5ce4
- */
- private void fixScreenKeyPlacement(){
-
- //this method needs to alter listview width, so if listview is null, return
- if(listview == null)
- return;
-
- int newWidth = currWidthFillParent ?
- LinearLayout.LayoutParams.FILL_PARENT : listview.getWidth() - 1;
- LinearLayout.LayoutParams l = new LinearLayout.LayoutParams(newWidth,
- LinearLayout.LayoutParams.FILL_PARENT);
- listview.setLayoutParams( l );
- //toggle our boolean
- currWidthFillParent = currWidthFillParent ? false : true;
-
- //save the current state of currWidthFillParent inside listview
- if(currWidthFillParent)
- listview.setId(1);
- else
- listview.setId(0);
+ * Returns an adapter for section
+ * */
+ public Adapter getAdapterForSection(String section)
+ {
+ return sections.get(section);
}
-
- @Override
- public int getPositionForSection(int section) {
- String letter = sectionKeys[section];
- return alphaIndexer.get(letter);
+
+ /**
+ * Replace an adapter for current Adapter
+ * */
+ public void appendAdapter(String section, Adapter adapter)
+ {
+ if(adapter != null)
+ {
+ sections.remove(section);
+ sections.put(section, adapter);
+ }
}
-
+ /**
+ * This function returns the index of section to display the appropriate header
+ * */
@Override
- public int getSectionForPosition(int position) {
- return 0;
+ public int getPositionForSection(int position) {
+ int sectionnum = 0;
+ for(Object section : this.sections.keySet()) {
+ Adapter adapter = sections.get(section);
+ int size = adapter.getCount() + 1;
+
+ // check if position inside this section
+ if(position < size){ return sectionnum; }
+ position -= size;
+ sectionnum++;
+ }
+ return sectionnum;
}
-
+
@Override
public Object[] getSections() {
- buildIndex();
- return sectionKeys;
+ return null;
}
-
}
\ No newline at end of file
diff --git a/Android/src/edu/sjsu/cinequest/SplashScreenActivity.java b/Android/src/edu/sjsu/cinequest/SplashScreenActivity.java
index 9c64d22..829bcba 100644
--- a/Android/src/edu/sjsu/cinequest/SplashScreenActivity.java
+++ b/Android/src/edu/sjsu/cinequest/SplashScreenActivity.java
@@ -7,36 +7,86 @@
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ContentValues;
+import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
+import android.text.Html;
import android.util.Log;
+import android.util.TypedValue;
+import android.view.Gravity;
import android.view.View;
import android.view.Window;
+import android.widget.ProgressBar;
+import android.widget.TextView;
import edu.sjsu.cinequest.android.AndroidPlatform;
import edu.sjsu.cinequest.comm.Callback;
+import edu.sjsu.cinequest.comm.ImageManager;
import edu.sjsu.cinequest.comm.Platform;
import edu.sjsu.cinequest.comm.QueryManager;
-
+/**
+ * SplashScreenActivity loads an authentication mechanism and displays all relevant features for
+ * registering with cinequest.
+ */
public class SplashScreenActivity extends Activity {
+ private static QueryManager queryManager;
+ private static ImageManager imageManager;
+
private LoadData loadData = null;
private View mLoginStatusView;
+ private ProgressBar progressBar; // added progress bar
+ private TextView loginStatusMessage; // added login text view
private static String calendarName="Cinequest Calendar";
+ private static String downServerMessage = "Apologies, the server is not responding.
"
+ + "Please re-open the app, or contact us for help.";
+
+ public static QueryManager getQueryManager() {
+ return queryManager;
+ }
+ public static ImageManager getImageManager() {
+ return imageManager;
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
+
+ Platform.setInstance(new AndroidPlatform(getApplicationContext()));
+ queryManager = new QueryManager();
+ imageManager = new ImageManager();
+
+ // TODO: Remove this to turn on test mode
+ // DateUtils.setMode(DateUtils.FESTIVAL_TEST_MODE);
+ Context context = getApplicationContext();
+ try {
+ PackageInfo pi = context.getPackageManager().getPackageInfo(getPackageName(), 0);
+ String version = pi.versionName;
+ setTitle("Cinequest" + (version == null ? "" : " " + version));
+ } catch (PackageManager.NameNotFoundException ex) {
+ // We tried...
+ }
+
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splash_screen);
- mLoginStatusView = findViewById(R.id.login_status);
- Platform.setInstance(new AndroidPlatform(getApplicationContext()));
- loadData = new LoadData();
+ mLoginStatusView = findViewById(R.id.login_status);
+ progressBar = (ProgressBar) findViewById(R.id.progressBar1);
+ loginStatusMessage = (TextView) findViewById(R.id.login_status_message);
+ loadData = new LoadData(); //There might be a problem in three lines
loadData.execute((Void) null);
- showProgress(true);
+ showProgress(true); //progress bar shows but nothing is shown
+ }
+ protected void onStop(){ // TODO: Is this really called when the app stops?
+ imageManager.close();
+ Platform.getInstance().close();
+ super.onStop();
}
+
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private void showProgress(final boolean show) {
// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
@@ -122,19 +172,17 @@ protected Boolean doInBackground(Void... params) {
try{
Uri uri = getContentResolver().insert(builder.build(), l_event);
if (uri == null)
- Log.i("SplashScreenActivity:LoadData","IllegalArgumentException");
+ Log.i("SplScrActivity:LoadData","IllegalArgumentException");
}
catch (Exception e){
- Log.i("SplashScreenActivity:LoadData","Error while creating Cinequest Calendar in Device Calendar");
+ Log.i("SplScrActivity:LoadData","Error while creating Cinequest Calendar in Device Calendar");
}
}
l_managedCursor.close();
l_managedCursor=null;
- //Create QueryManager Object and assign it to HomeActivity class queryManager variable.
- HomeActivity.setQueryManager(new QueryManager());
//Load News Feed, Festival & Venue Feed
- HomeActivity.getQueryManager().loadFestival(new Callback(){
+ SplashScreenActivity.getQueryManager().loadFestival(new Callback(){
@Override
public void invoke(Object result) {
showProgress(false);
@@ -145,7 +193,13 @@ public void invoke(Object result) {
}
@Override public void starting() {}
@Override public void failure(Throwable t) {
- Platform.getInstance().log(t);
+ Platform.getInstance().log(t);
+
+ // display server down instead
+ progressBar.setVisibility(View.GONE);
+ loginStatusMessage.setGravity(Gravity.CENTER);
+ loginStatusMessage.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
+ loginStatusMessage.setText(Html.fromHtml(downServerMessage));
}
});
// TODO: register the new account here.
diff --git a/Android/src/edu/sjsu/cinequest/android/AndroidPlatform.java b/Android/src/edu/sjsu/cinequest/android/AndroidPlatform.java
index 932b3d7..b96c91b 100644
--- a/Android/src/edu/sjsu/cinequest/android/AndroidPlatform.java
+++ b/Android/src/edu/sjsu/cinequest/android/AndroidPlatform.java
@@ -1,5 +1,16 @@
package edu.sjsu.cinequest.android;
+import android.content.Context;
+import android.graphics.BitmapFactory;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Handler;
+import android.util.Log;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -12,24 +23,12 @@
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.util.Collections;
import java.util.Hashtable;
-import java.util.Vector;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import android.content.Context;
-import android.graphics.BitmapFactory;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Handler;
-import android.util.Log;
import edu.sjsu.cinequest.comm.Cache;
import edu.sjsu.cinequest.comm.Callback;
import edu.sjsu.cinequest.comm.CallbackException;
@@ -101,6 +100,9 @@ public void parse(String url, DefaultHandler handler, Callback callback)
* http://www.google.com/search?q=android+XML+parser+8859-1 The parser
* can't infer the character encoding from the xml encoding attribute,
* so we have to hardwire 8859-1 here.
+ * Instead of 8859-1, I hardcoded the encoding to UTF-8, since it was
+ * previously hardcoded to ISO-8895-I for the reasons stated above
+ * - Michael Singh
*/
if (getFromCache(url, sp, handler, MAX_CACHE_AGE))
return;
@@ -115,7 +117,7 @@ public void parse(String url, DefaultHandler handler, Callback callback)
// Store the xml source
xmlRawBytesCache.put(url, xmlSource);
InputSource in = new InputSource(new InputStreamReader(
- new ByteArrayInputStream(xmlSource), "ISO-8859-1"));
+ new ByteArrayInputStream(xmlSource), "UTF-8"));
sp.parse(in, handler);
} catch (IOException e) {
Platform.getInstance().log(e);
@@ -125,7 +127,9 @@ public void parse(String url, DefaultHandler handler, Callback callback)
CallbackException.ERROR);
}
}
-
+ /*
+ * Changed encoding from ISO-8895-I to UTF-8
+ */
private boolean getFromCache(String url, SAXParser sp,
DefaultHandler handler, long maxage) throws SAXException,
IOException {
@@ -133,7 +137,7 @@ private boolean getFromCache(String url, SAXParser sp,
// XML exists in cache and isn't too old
if (bytes != null) {
InputSource in = new InputSource(new InputStreamReader(
- new ByteArrayInputStream(bytes), "ISO-8859-1"));
+ new ByteArrayInputStream(bytes), "UTF-8"));
sp.parse(in, handler);
Platform.getInstance().log(
"AndroidPlatform.getFromCache: Returned cached response for "
@@ -194,6 +198,9 @@ public void run() {
+ t.getClass().toString();
if (t.getMessage() != null)
error += ", Message=" + t.getMessage();
+ StringWriter out = new StringWriter();
+ t.printStackTrace(new PrintWriter(out));
+ error += ", Stack trace=" + out.toString();
log("AndroidPlatform.invoke: " + error);
}
@@ -246,7 +253,6 @@ public Object loadPersistentObject(long key) {
@Override
public MessageDigest getMessageDigestInstance(String name) {
- // TODO Auto-generated method stub
return null;
}
diff --git a/Android/src/edu/sjsu/cinequest/android/AndroidWebConnection.java b/Android/src/edu/sjsu/cinequest/android/AndroidWebConnection.java
index 3a473e7..97c4615 100644
--- a/Android/src/edu/sjsu/cinequest/android/AndroidWebConnection.java
+++ b/Android/src/edu/sjsu/cinequest/android/AndroidWebConnection.java
@@ -35,7 +35,9 @@
import edu.sjsu.cinequest.comm.WebConnection;
// http://android-developers.blogspot.com/2011/09/androids-http-clients.html
-
+/**
+ * AndroidWebConnection connects to internet by trying different key,value to get a response.
+ */
public class AndroidWebConnection extends WebConnection {
private String url;
private Hashtable postData;
@@ -70,7 +72,10 @@ public AndroidWebConnection(String url) throws IOException
public void setPostParameters(Hashtable postData) throws IOException {
this.postData = postData;
}
-
+ /**
+ * If there was a response, do not look for a response, continue.
+ * If there was no response, hit some hosts see who will respond.
+ */
private void execute() throws IOException
{
Platform.getInstance().log("AndroidWebConnection.execute: Opening connection to " + url);
diff --git a/Android/src/edu/sjsu/cinequest/imageutils/FileCache.java b/Android/src/edu/sjsu/cinequest/imageutils/FileCache.java
index 38f7333..3b66756 100644
--- a/Android/src/edu/sjsu/cinequest/imageutils/FileCache.java
+++ b/Android/src/edu/sjsu/cinequest/imageutils/FileCache.java
@@ -3,10 +3,17 @@
import java.io.File;
import android.content.Context;
+/*
+ Implements a simple file cache
+*/
public class FileCache {
private File cacheDir;
+ /**
+ * Constructs a new cache object and directory
+ * @param context The android context we are running the application on.
+ */
public FileCache(Context context){
//Find the dir to save cached images
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
@@ -17,6 +24,12 @@ public FileCache(Context context){
cacheDir.mkdirs();
}
+ /**
+ * Creates a File object from the cache directory
+ * and identifies it with a hashcode
+ * @param url A path to a file
+ * @return a new File from the cache
+ */
public File getFile(String url){
//I identify images by hashcode. Not a perfect solution, good for the demo.
String filename=String.valueOf(url.hashCode());
@@ -27,6 +40,9 @@ public File getFile(String url){
}
+ /**
+ * Removes all files in the cache if there is any
+ */
public void clear(){
File[] files=cacheDir.listFiles();
if(files==null)
diff --git a/Android/src/edu/sjsu/cinequest/imageutils/ImageLoader.java b/Android/src/edu/sjsu/cinequest/imageutils/ImageLoader.java
index 02abff8..d1ac6e8 100644
--- a/Android/src/edu/sjsu/cinequest/imageutils/ImageLoader.java
+++ b/Android/src/edu/sjsu/cinequest/imageutils/ImageLoader.java
@@ -37,7 +37,7 @@ public ImageLoader(Context context){
}
final int stub_id=R.drawable.ic_launcher;
- public void DisplayImage(String url, ImageView imageView)
+ public void displayImage(String url, ImageView imageView)
{
imageViews.put(imageView, url);
Bitmap bitmap=memoryCache.get(url);
diff --git a/Cinequest-Android.iml b/Cinequest-Android.iml
new file mode 100644
index 0000000..7dc5c9f
--- /dev/null
+++ b/Cinequest-Android.iml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/JavaCommon/AndroidManifest.xml b/JavaCommon/AndroidManifest.xml
index dfbbb09..40098d5 100644
--- a/JavaCommon/AndroidManifest.xml
+++ b/JavaCommon/AndroidManifest.xml
@@ -1,8 +1,12 @@
+ package="edu.sjsu.cinequest.comm">
-
+
+
diff --git a/JavaCommon/JavaCommon.iml b/JavaCommon/JavaCommon.iml
new file mode 100644
index 0000000..33593c2
--- /dev/null
+++ b/JavaCommon/JavaCommon.iml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/JavaCommon/build.gradle b/JavaCommon/build.gradle
new file mode 100644
index 0000000..c5ac1c3
--- /dev/null
+++ b/JavaCommon/build.gradle
@@ -0,0 +1,34 @@
+apply plugin: 'com.android.library'
+
+dependencies {
+ compile fileTree(dir: 'libs', include: '*.jar')
+}
+
+android {
+ compileSdkVersion 15
+ buildToolsVersion '25.0.0'
+
+ sourceSets {
+ main {
+ manifest.srcFile 'AndroidManifest.xml'
+ java.srcDirs = ['src']
+ resources.srcDirs = ['src']
+ aidl.srcDirs = ['src']
+ renderscript.srcDirs = ['src']
+ res.srcDirs = ['res']
+ assets.srcDirs = ['assets']
+ }
+
+ // Move the tests to tests/java, tests/res, etc...
+ instrumentTest.setRoot('tests')
+
+ // Move the build types to build-types/
+ // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
+ // This moves them out of them default location under src//... which would
+ // conflict with src/ being used by the main source set.
+ // Adding new build types or product flavors should be accompanied
+ // by a similar customization.
+ debug.setRoot('build-types/debug')
+ release.setRoot('build-types/release')
+ }
+}
diff --git a/JavaCommon/project.properties b/JavaCommon/project.properties
index 6905bdf..f28bc83 100644
--- a/JavaCommon/project.properties
+++ b/JavaCommon/project.properties
@@ -9,4 +9,4 @@
android.library=true
# Project target.
-target=android-18
+target=android-15
diff --git a/JavaCommon/src/edu/sjsu/cinequest/comm/HParser.java b/JavaCommon/src/edu/sjsu/cinequest/comm/HParser.java
index 2b91078..72af111 100644
--- a/JavaCommon/src/edu/sjsu/cinequest/comm/HParser.java
+++ b/JavaCommon/src/edu/sjsu/cinequest/comm/HParser.java
@@ -18,7 +18,8 @@
*/
package edu.sjsu.cinequest.comm;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
/**
* HParser converts plain strings into RichText. This follows the BlackBerry API but is also usable
@@ -40,7 +41,7 @@ public class HParser
private int[] offsets = null;
// Tracks the font by the reference byte
- private Vector images;
+ private List images;
public static final int RED = 8;
public static final int LARGE = 4;
@@ -54,17 +55,17 @@ public class HParser
*/
public void parse(String input)
{
- Vector offs = new Vector();
- Vector attrs = new Vector();
-
- images = new Vector();
+ if (input == null) input = "";
+ List offs = new ArrayList();
+ List attrs = new ArrayList();
+ images = new ArrayList();
byte font = (byte) 0;
boolean inTag = false;
int start = 0; // The start of the last tag
int end = -1; // The end of the last tag
- StringBuffer result = new StringBuffer();
- offs.addElement(new Integer(0));
+ StringBuilder result = new StringBuilder();
+ offs.add(0);
for (int i = 0; i < input.length(); i++)
{
char ch = input.charAt(i);
@@ -94,8 +95,8 @@ else if (!checkForImage(images, tag))
{
if (result.length() > 0)
{
- offs.addElement(new Integer(result.length()));
- attrs.addElement(new Byte(font));
+ offs.add(result.length());
+ attrs.add(font);
}
font = newFont;
}
@@ -105,20 +106,20 @@ else if (!checkForImage(images, tag))
if (end < input.length() - 1)
{
result.append(input.substring(end + 1, input.length()));
- offs.addElement(new Integer(result.length()));
- attrs.addElement(new Byte(font));
+ offs.add(result.length());
+ attrs.add(font);
}
attributes = new byte[attrs.size()];
for (int i = 0; i < attrs.size(); i++)
{
- attributes[i] = ((Byte) attrs.elementAt(i)).byteValue();
+ attributes[i] = attrs.get(i);
}
offsets = new int[offs.size()];
for (int i = 0; i < offs.size(); i++)
{
- offsets[i] = ((Integer) offs.elementAt(i)).intValue();
+ offsets[i] = offs.get(i);
}
resultString = result.toString();
@@ -153,9 +154,9 @@ public String getResultString()
/**
* Returns the image URLs found in the input
- * @return a vector of image URL strings
+ * @return a list of image URL strings
*/
- public Vector getImageURLs()
+ public List getImageURLs()
{
return images;
}
@@ -224,12 +225,12 @@ private byte setFont(byte font, int fontElement, boolean on)
/**
- * Scans a string for img tags and deposits the src attributes in a vector
+ * Scans a string for img tags and deposits the src attributes in a list
* @param images the vector to which the src attributes are added
* @param tagString the string to be scanned
* @return true if an image has been found
*/
- private static boolean checkForImage(Vector images, String tagString)
+ private static boolean checkForImage(List images, String tagString)
{
if (!tagString.startsWith("img"))
return false;
@@ -242,7 +243,7 @@ private static boolean checkForImage(Vector images, String tagString)
int j = tagString.indexOf("\"", i + 1);
if (j == -1)
return false;
- images.addElement(tagString.substring(i + 1, j));
+ images.add(tagString.substring(i + 1, j));
return true;
}
diff --git a/JavaCommon/src/edu/sjsu/cinequest/comm/ImageManager.java b/JavaCommon/src/edu/sjsu/cinequest/comm/ImageManager.java
index 57f5fe6..bf1601a 100644
--- a/JavaCommon/src/edu/sjsu/cinequest/comm/ImageManager.java
+++ b/JavaCommon/src/edu/sjsu/cinequest/comm/ImageManager.java
@@ -21,8 +21,9 @@
import java.io.IOException;
import java.net.HttpURLConnection;
+import java.util.ArrayList;
import java.util.Hashtable;
-import java.util.Vector;
+import java.util.List;
/**
* Set's up a HTTP connection, retrives the image from the specified URL,and
@@ -59,6 +60,13 @@ public ImageManager()
private Object fetchImage(String imageUrl, boolean usePersistentCache) throws IOException
{
Object image = null;
+ // the problem of image not loading is right here because of url encoding
+ // check if there are spaces in image url
+ if ((imageUrl.contains("image") || imageUrl.contains(".jpg")) && imageUrl.contains(" ")) {
+ // replace " " with "%20"
+ imageUrl = imageUrl.replace(" ", "%20");
+ }
+
HttpURLConnection connection = ConnectionHelper.open(imageUrl);
if (!connection.getHeaderField("content-type").startsWith("image"))
{
@@ -132,23 +140,23 @@ public void run()
* Fetches multiple images in one thread. Called from UI thread.
* @param imageUrls the image URLs
* @param callback the callback for reporting progress. Each progress call delivers one image.
- * Final callback delivers vector of all images
+ * Final callback delivers list of all images
*/
- public void getImages(final Vector imageUrls, final Callback callback)
+ public void getImages(final List imageUrls, final Callback callback)
{
callback.starting();
Thread t = new Thread(new Runnable()
{
public void run()
{
- Vector images = new Vector();
+ List