Skip to content

Commit

Permalink
Update to version 1.0.2
Browse files Browse the repository at this point in the history
- Add clickable hyperlinks to Laundry room list
- Fix weather icon URL due to change in openweathermap.org's system
- Change database versioning system
- Change class naming scheme again
- Update twitter4j library
- Update Android Support Library v4
- Update Google Play Services library
- Bump version number to 1.0.2
  • Loading branch information
pdpiech committed Sep 7, 2014
1 parent 0b6b69e commit 486ee6c
Show file tree
Hide file tree
Showing 114 changed files with 676 additions and 755 deletions.
11 changes: 0 additions & 11 deletions RPIMobile/.settings/org.eclipse.jdt.core.prefs

This file was deleted.

6 changes: 3 additions & 3 deletions RPIMobile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.rpi.rpimobile"
android:versionCode="8"
android:versionName="1.0.1" >
android:versionCode="9"
android:versionName="1.0.2" >

<!-- Target Version 2.3.3 and up -->
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
android:targetSdkVersion="20" />

<uses-feature
android:glEsVersion="0x00020000"
Expand Down
Binary file modified RPIMobile/libs/android-support-v4.jar
Binary file not shown.
Binary file removed RPIMobile/libs/twitter4j-core-4.0.1.jar
Binary file not shown.
Binary file added RPIMobile/libs/twitter4j-core-4.0.2.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions RPIMobile/proguard-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-libraryjars <java.home>/lib/rt.jar
-libraryjars C:\Program Files\Java\jdk1.7.0_67\lib\tools.jar
6 changes: 3 additions & 3 deletions RPIMobile/project.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
target=android-19
android.library.reference.1=../android-rss-master
android.library.reference.2=../google-play-services_lib
android.library.reference.3=../actionbarsherlock
android.library.reference.1=..\\android-rss-master
android.library.reference.2=..\\actionbarsherlock
android.library.reference.3=../google-play-services_lib
2 changes: 1 addition & 1 deletion RPIMobile/res/layout/laundry_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<TextView

android:id="@+id/building_title"
android:id="@+id/laundryroom_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
Expand Down
5 changes: 5 additions & 0 deletions RPIMobile/res/values/numeric.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="integer" format="integer" name="dbVersion">9</item>

</resources>
20 changes: 10 additions & 10 deletions RPIMobile/src/edu/rpi/rpimobile/AthleticsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.mcsoxford.rss.RSSReader;
import org.mcsoxford.rss.RSSReaderException;

import edu.rpi.rpimobile.model.RSSObject;
import edu.rpi.rpimobile.model.RSSArticle;

import android.content.SharedPreferences;
import android.os.AsyncTask;
Expand All @@ -32,10 +32,10 @@
public class AthleticsFragment extends SherlockFragment {

//All variables to be used throughout the function
private ArrayList<RSSObject> stories;
private ArrayList<RSSObject> tempstories;
private ArrayList<RSSObject> finlist = new ArrayList<RSSObject>();
private RSSObject temp;
private ArrayList<RSSArticle> stories;
private ArrayList<RSSArticle> tempstories;
private ArrayList<RSSArticle> finlist = new ArrayList<RSSArticle>();
private RSSArticle temp;
private ListView rsslist;
private RSSListAdapter rssadapter;
private MenuItem refreshbutton;
Expand All @@ -52,8 +52,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
setHasOptionsMenu(true);

//initialize data
stories = new ArrayList<RSSObject>();
tempstories = new ArrayList<RSSObject>();
stories = new ArrayList<RSSArticle>();
tempstories = new ArrayList<RSSArticle>();


//set an adapter up for the listview to handle displaying the data
Expand Down Expand Up @@ -209,7 +209,7 @@ protected Boolean doInBackground(String... params) {
logcat( "Parsing feed");
for(int i = 0; i<feedlist.size(); i++){
//for each item populate the temporary RSSObject with all data
temp = new RSSObject();
temp = new RSSArticle();
temp.setTitle(feedlist.get(i).getTitle());
temp.setLink(feedlist.get(i).getLink().toString());
temp.setTime(feedlist.get(i).getPubDate());
Expand Down Expand Up @@ -251,7 +251,7 @@ protected void onPostExecute(Boolean results) {
}

//class to add objects to the main list
private void addtolist(ArrayList<RSSObject> temp){
private void addtolist(ArrayList<RSSArticle> temp){

logcat("Combining lists");
logcat("Source list: "+stories.size()+" Temp list: "+temp.size());
Expand Down Expand Up @@ -322,7 +322,7 @@ else if (finlist.get(i).getTitle().equals(finlist.get(j).getTitle()))
//Because ArrayLists really just store pointers to their objects a deepcopy must be made of each
//item and passed to the list individually. This is much more efficient than using the
//java.serialize class to do this automatically.
private void assign(ArrayList<RSSObject> target, ArrayList<RSSObject> source){
private void assign(ArrayList<RSSArticle> target, ArrayList<RSSArticle> source){
logcat( "Starting copy source:"+source.size()+" Target:"+target.size());
target.clear();
//clear the target list
Expand Down
14 changes: 7 additions & 7 deletions RPIMobile/src/edu/rpi/rpimobile/EventsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.json.JSONException;
import org.json.JSONObject;

import edu.rpi.rpimobile.model.CalEvent;
import edu.rpi.rpimobile.model.CalendarEvent;

import android.os.AsyncTask;
import android.os.AsyncTask.Status;
Expand All @@ -31,8 +31,8 @@ public class EventsFragment extends SherlockFragment {

//All variables to be used throughout the function
private JSONObject jObj;
private ArrayList<CalEvent> events;
private CalendarListAdapter listadapter;
private ArrayList<CalendarEvent> events;
private EventsListAdapter listadapter;
private MenuItem refreshbutton;
private JSONCalendarTask downloadtask;

Expand All @@ -48,11 +48,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
setHasOptionsMenu(true);

//initialize data
events = new ArrayList<CalEvent>();
events = new ArrayList<CalendarEvent>();

//set an adapter up for the listview to handle displaying the data
ListView callist = (ListView) rootView.findViewById(R.id.calendarlist);
listadapter = new CalendarListAdapter(this.getSherlockActivity(), events);
listadapter = new EventsListAdapter(this.getSherlockActivity(), events);
callist.setAdapter(listadapter);

//Start the download of the calendar data
Expand Down Expand Up @@ -123,7 +123,7 @@ protected Boolean doInBackground(Void... params) {
}
logcat( "Begining Download");
String data;
CalEvent temp = new CalEvent();
CalendarEvent temp = new CalendarEvent();
//Try to download data
try {
data = ( (new HttpClient()).getData(events_JSON_URL));
Expand All @@ -146,7 +146,7 @@ protected Boolean doInBackground(Void... params) {
//loop through each of the event items in the array
for(int i = 0; i<items.length(); i++){
logcat( "Adding item #"+i);
temp = new CalEvent();
temp = new CalendarEvent();

tempJ = items.getJSONObject(i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.ArrayList;

import edu.rpi.rpimobile.model.CalEvent;
import edu.rpi.rpimobile.model.CalendarEvent;

import android.content.Context;
import android.content.Intent;
Expand All @@ -13,14 +13,14 @@
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CalendarListAdapter extends BaseAdapter {
public class EventsListAdapter extends BaseAdapter {

// Declare Variables
private Context context;
private ArrayList<CalEvent> events;
private ArrayList<CalendarEvent> events;
private LayoutInflater inflater;

public CalendarListAdapter(Context context, ArrayList<CalEvent> events_) {
public EventsListAdapter(Context context, ArrayList<CalendarEvent> events_) {
//Assign passed list and context to local variables in the class
this.context = context;
this.events = events_;
Expand Down Expand Up @@ -56,8 +56,7 @@ public View getView(final int position, View convertView, ViewGroup parent) {
//inflate the layout into the parent view
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.calendar_list_item, parent,
false);
View itemView = inflater.inflate(R.layout.calendar_list_item, parent, false);

//set an OnClickListener on the parent view to launch a link intent when clicked
itemView.setOnClickListener(new View.OnClickListener() {
Expand Down
66 changes: 35 additions & 31 deletions RPIMobile/src/edu/rpi/rpimobile/LaundryFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import edu.rpi.rpimobile.model.Building;
import edu.rpi.rpimobile.model.LaundryRoom;

import android.os.AsyncTask;
import android.os.AsyncTask.Status;
Expand All @@ -33,12 +33,13 @@
public class LaundryFragment extends SherlockFragment {

//All variables to be used throughout the function
private ArrayList<Building> buildings;
private ListView buildinglist;
private List<LaundryRoom> laundryrooms;
private ListView laundryroomlist;
private LaundryListAdapter listadapter;
private MenuItem refreshbutton;
private AsyncTask<Void, Void, Boolean> downloadtask;

private static String landing_page_url = "http://www.laundryalert.com/cgi-bin/rpi2012/LMPage";

//Initial function
@Override
Expand All @@ -51,13 +52,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
//Allow this fragment to interact with the menu
setHasOptionsMenu(true);

//Point the buildings variable to an arraylist of Building objects
buildings = new ArrayList<Building>();
//Point the laundryrooms variable to an ArrayList of LaundryRoom objects
laundryrooms = new ArrayList<LaundryRoom>();

//assign a list adapter to the listview to handle displaying the data
buildinglist = (ListView) rootView.findViewById(R.id.laundrylist);
listadapter = new LaundryListAdapter(this.getActivity(), buildings);
buildinglist.setAdapter(listadapter);
laundryroomlist = (ListView) rootView.findViewById(R.id.laundrylist);
listadapter = new LaundryListAdapter(this.getActivity(), laundryrooms);
laundryroomlist.setAdapter(listadapter);

//download the Laundry data
downloadtask = new LaundryFragment.Download().execute();
Expand Down Expand Up @@ -114,16 +115,16 @@ private class Download extends AsyncTask<Void, Void, Boolean>{
//before the thread is executed set the action bar to show indeterminate progress, usually a spinner
protected void onPreExecute(){
getActivity().setProgressBarIndeterminateVisibility(Boolean.TRUE);
buildings.clear(); // empty the buildings to avoid duplicates
laundryrooms.clear(); // empty the laundryrooms to avoid duplicates
}


//Class to be ran in another thread
@Override
protected Boolean doInBackground(Void... params) {

//temp variable for storing each building
Building temp = new Building();
//temp variable for storing each laundryroom
LaundryRoom temp = new LaundryRoom();
//temp variable for the website source
String source = "";

Expand All @@ -132,7 +133,7 @@ protected Boolean doInBackground(Void... params) {
try {
//try to download the source of the webpage
HttpClient httpClient = new DefaultHttpClient();
HttpGet get = new HttpGet("http://www.laundryalert.com/cgi-bin/rpi2012/LMPage?CallingPage=LMRoom&RoomPersistence=&MachinePersistenceA=023&MachinePersistenceB=");
HttpGet get = new HttpGet(landing_page_url);

HttpResponse response = httpClient.execute(get);

Expand All @@ -143,50 +144,53 @@ protected Boolean doInBackground(Void... params) {
e.printStackTrace();
}

//This code parses the webpage source and saves each building's name free washers and dryers, and used washers and dryers.
//This code parses the webpage source and saves each laundry room's name, free washers and dryers, and used washers and dryers.
//It is just a simple scrape of the webpage that will be phased out as soon as LaundryAlert has a public API, or RPIMobile
//has it's own server for data like this.

logcat( "Source download Length: "+source.length());
//logcat( source);
String[] results = source.split("\\s+");
int counter = 0;
for(int i=0; i<results.length; i++){
int j = 0; // used to enumerate the objects for URL setting
for(int i = 0; i<results.length; ++i){
if(results[i].contains("sans-serif")){
counter++;
if(counter>8&&!(results[i+1].equals("On")&&results[i+2].equals("site"))){
temp = new Building();
++counter;
if(counter > 8 && !(results[i+1].equals("On") && results[i+2].equals("site"))){
temp = new LaundryRoom();

temp.setTag(results[i].substring(12));

logcat( temp.getTag());

i++;
++i;
while(!results[i].contains("font")){
logcat( "Concatinating: "+results[i]);
temp.setTag(temp.getTag() +" "+results[i]);
i++;
++i;
}
logcat( temp.getTag());

while(!results[i].contains("sans-serif")) i++;
i++;
while(!results[i].contains("sans-serif")) ++i;
++i;
temp.setAvailableWashers(Integer.parseInt(results[i]));
logcat("" + temp.getAvailableWashers());

while(!results[i].contains("sans-serif")) i++;
i++;
while(!results[i].contains("sans-serif")) ++i;
++i;
temp.setAvailableDryers(Integer.parseInt(results[i]));

while(!results[i].contains("sans-serif")) i++;
i++;
while(!results[i].contains("sans-serif")) ++i;
++i;
temp.setUsedWashers(Integer.parseInt(results[i]));

while(!results[i].contains("sans-serif")) i++;
i++;
while(!results[i].contains("sans-serif")) ++i;
++i;
temp.setUsedDryers(Integer.parseInt(results[i]));

buildings.add(temp);
temp.setLaundryRoomURLNumber(j);
laundryrooms.add(temp);
++j;
}
}
}
Expand All @@ -198,8 +202,8 @@ protected Boolean doInBackground(Void... params) {
protected void onPostExecute(Boolean results) {
//code to be ran in the UI thread after the background thread has completed
logcat( "Notifying list");
// sort the buildings ArrayList so that it displays in alphabetical order
Collections.sort(buildings);
// sort the laundryrooms ArrayList so that it displays in alphabetical order
Collections.sort(laundryrooms);
//Set the action bar back to normal
getActivity().setProgressBarIndeterminateVisibility(Boolean.FALSE);
try{
Expand Down
Loading

0 comments on commit 486ee6c

Please sign in to comment.