diff --git a/src/com/uncc/gameday/alerts/AlertFetcher.java b/src/com/uncc/gameday/alerts/AlertFetcher.java index 90b463a..bcfbdd4 100644 --- a/src/com/uncc/gameday/alerts/AlertFetcher.java +++ b/src/com/uncc/gameday/alerts/AlertFetcher.java @@ -8,9 +8,9 @@ import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.TwitterFactory; +import android.content.Context; import android.widget.Toast; -import com.uncc.gameday.GameDay; import com.uncc.gameday.R; public class AlertFetcher { @@ -18,7 +18,7 @@ public class AlertFetcher { private int maxTweets = 5; - public void fetchAlerts() { + public void fetchAlerts(Context ctx) { /* This method needs to be re-written to use better logic. */ /* @@ -39,16 +39,16 @@ public class AlertFetcher { */ } - private void fetchTimedAlerts() { + private void fetchTimedAlerts(Context ctx) { // Process the rules for all timed alerts. } - private void fetchOrganizationAlerts() { + private void fetchOrganizationAlerts(Context ctx) { // Process fetching organization alerts (alerts retweeted by us) int duration = Toast.LENGTH_SHORT; try { - String handle = GameDay.getAppContext().getString(R.string.gameday_handle); + String handle = ctx.getString(R.string.gameday_handle); Twitter twitter = TwitterFactory.getSingleton(); List statuses = twitter.getUserTimeline(handle, new Paging(1, maxTweets)); @@ -62,38 +62,38 @@ public class AlertFetcher { // List contains all valid alerts now } catch (TwitterException e) { - Toast.makeText(GameDay.getAppContext(), + Toast.makeText(ctx, "Unable to fetch alerts for organizations!\nAre you connected to the internet?", duration).show(); e.printStackTrace(); } } - private void fetchUniversityAlerts() { + private void fetchUniversityAlerts(Context ctx) { // Process fetching university alerts int duration = Toast.LENGTH_SHORT; try { - String handle = GameDay.getAppContext().getString(R.string.university_handle); + String handle = ctx.getString(R.string.university_handle); Twitter twitter = TwitterFactory.getSingleton(); List statuses = twitter.getUserTimeline(handle, new Paging(1, maxTweets)); // List contains all valid alerts now } catch (TwitterException e) { - Toast.makeText(GameDay.getAppContext(), + Toast.makeText(ctx, "Unable to fetch alerts for the University!\nAre you connected to the internet?", duration).show(); e.printStackTrace(); } } - private void fetchGamedayAlerts() { + private void fetchGamedayAlerts(Context ctx) { // Process fetching alerts generated by staff of UNCCGameDay int duration = Toast.LENGTH_SHORT; try { - String handle = GameDay.getAppContext().getString(R.string.gameday_handle); + String handle = ctx.getString(R.string.gameday_handle); Twitter twitter = TwitterFactory.getSingleton(); List statuses = twitter.getUserTimeline(handle, new Paging(1, maxTweets)); @@ -107,7 +107,7 @@ public class AlertFetcher { // List contains all valid alerts now. } catch (TwitterException e) { - Toast.makeText(GameDay.getAppContext(), + Toast.makeText(ctx, "Unable to fetch alerts from Gameday!\nAre you connected to the internet?", duration).show(); e.printStackTrace();