mirror of
https://github.com/bspeice/UNCCGameDay
synced 2025-01-09 23:40:04 -05:00
Add lots more skeleton
This commit is contained in:
parent
e0f029f387
commit
9fc974402b
@ -1,13 +1,8 @@
|
|||||||
package com.uncc.gameday.activities;
|
package com.uncc.gameday.activities;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import twitter4j.Status;
|
|
||||||
import twitter4j.Twitter;
|
|
||||||
import twitter4j.TwitterException;
|
|
||||||
import twitter4j.TwitterFactory;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import com.uncc.gameday.R;
|
import com.uncc.gameday.R;
|
||||||
@ -20,12 +15,23 @@ public class Home extends MenuActivity {
|
|||||||
setContentView(R.layout.activity_home);
|
setContentView(R.layout.activity_home);
|
||||||
|
|
||||||
Context ctx = getApplicationContext();
|
Context ctx = getApplicationContext();
|
||||||
|
this.onFirstRun(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onFirstRun(Context ctx) {
|
||||||
|
SharedPreferences settings = this.getPreferences(MODE_PRIVATE);
|
||||||
|
if (settings.getBoolean("FIRST_RUN", true)) {
|
||||||
|
// First run code
|
||||||
|
|
||||||
|
Editor editor = settings.edit();
|
||||||
|
editor.putBoolean("FIRST_RUN", false);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getRecentAlerts() {
|
private void getRecentAlerts() {
|
||||||
// Responsible for discovering what the most recent alerts are and showing them.
|
// Responsible for discovering what the most recent alerts are and showing them.
|
||||||
// Likely should be implemented by querying a local DB of alerts, grabbing recent 20.
|
// Likely should be implemented by querying a local DB of alerts, grabbing recent 20.
|
||||||
new AlertFetcher().fetchAlerts();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,11 @@ public class AlertDB {
|
|||||||
// Add multiple new dates to the database
|
// Add multiple new dates to the database
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Alert> fetchUnreadAlerts() {
|
public void deleteAlert(Alert alert) {
|
||||||
// Get a list of all currently unread alerts
|
// Remove a date from the database
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteAlerts(List<Alert> alerts) {
|
||||||
|
// Remove multiple dates from the database
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import twitter4j.TwitterException;
|
|||||||
import twitter4j.TwitterFactory;
|
import twitter4j.TwitterFactory;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.widget.Toast;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.uncc.gameday.R;
|
import com.uncc.gameday.R;
|
||||||
|
|
||||||
@ -22,33 +22,27 @@ public class AlertFetcher {
|
|||||||
public void fetchAlerts(Context ctx) {
|
public void fetchAlerts(Context ctx) {
|
||||||
// Fetch all alerts. Responsible for discovering what sources need to be fetched.
|
// Fetch all alerts. Responsible for discovering what sources need to be fetched.
|
||||||
|
|
||||||
|
try {
|
||||||
// Note we have to use the SharedPreferences so that we have preferences no matter what activity
|
// Note we have to use the SharedPreferences so that we have preferences no matter what activity
|
||||||
// sent us this context
|
// sent us this context
|
||||||
SharedPreferences settings = ctx.getSharedPreferences(ctx.getString(R.string.preferences_file), 0); // MODE_PRIVATE
|
SharedPreferences settings = ctx.getSharedPreferences(ctx.getString(R.string.preferences_file), 0); // MODE_PRIVATE
|
||||||
|
|
||||||
if (settings.getBoolean("ALERT_TIMED", false))
|
if (settings.getBoolean("ALERT_ORGANIZATION", false))
|
||||||
// Fetch timed alerts
|
|
||||||
this.fetchTimedAlerts(ctx);
|
|
||||||
else if (settings.getBoolean("ALERT_ORGANIZATION", false))
|
|
||||||
// Fetch organization alerts
|
// Fetch organization alerts
|
||||||
this.fetchOrganizationAlerts(ctx);
|
this.fetchOrganizationAlerts(ctx);
|
||||||
else if (settings.getBoolean("ALERT_UNIVERSITY", false))
|
if (settings.getBoolean("ALERT_UNIVERSITY", false))
|
||||||
// Fetch university alerts
|
// Fetch university alerts
|
||||||
this.fetchUniversityAlerts(ctx);
|
this.fetchUniversityAlerts(ctx);
|
||||||
|
|
||||||
// And always fetch alerts made by us. Period.
|
// And always fetch alerts made by us. Period.
|
||||||
this.fetchGamedayAlerts(ctx);
|
this.fetchGamedayAlerts(ctx);
|
||||||
|
} catch (TwitterException e) {
|
||||||
|
Log.w("AlertFetcher", "Unable to fetch alerts from Twitter...", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchTimedAlerts(Context ctx) {
|
private void fetchOrganizationAlerts(Context ctx) throws TwitterException {
|
||||||
// Process the rules for all timed alerts.
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchOrganizationAlerts(Context ctx) {
|
|
||||||
// Process fetching organization alerts (alerts retweeted by us)
|
// Process fetching organization alerts (alerts retweeted by us)
|
||||||
int duration = Toast.LENGTH_SHORT;
|
|
||||||
|
|
||||||
try {
|
|
||||||
String handle = ctx.getString(R.string.gameday_handle);
|
String handle = ctx.getString(R.string.gameday_handle);
|
||||||
Twitter twitter = TwitterFactory.getSingleton();
|
Twitter twitter = TwitterFactory.getSingleton();
|
||||||
List<Status> statuses = twitter.getUserTimeline(handle, new Paging(1, maxTweets));
|
List<Status> statuses = twitter.getUserTimeline(handle, new Paging(1, maxTweets));
|
||||||
@ -61,39 +55,19 @@ public class AlertFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List contains all valid alerts now
|
// List contains all valid alerts now
|
||||||
|
|
||||||
} catch (TwitterException e) {
|
|
||||||
Toast.makeText(ctx,
|
|
||||||
"Unable to fetch alerts for organizations!\nAre you connected to the internet?",
|
|
||||||
duration).show();
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchUniversityAlerts(Context ctx) {
|
private void fetchUniversityAlerts(Context ctx) throws TwitterException {
|
||||||
// Process fetching university alerts
|
// Process fetching university alerts
|
||||||
int duration = Toast.LENGTH_SHORT;
|
|
||||||
|
|
||||||
try {
|
|
||||||
String handle = ctx.getString(R.string.university_handle);
|
String handle = ctx.getString(R.string.university_handle);
|
||||||
Twitter twitter = TwitterFactory.getSingleton();
|
Twitter twitter = TwitterFactory.getSingleton();
|
||||||
List<Status> statuses = twitter.getUserTimeline(handle, new Paging(1, maxTweets));
|
List<Status> statuses = twitter.getUserTimeline(handle, new Paging(1, maxTweets));
|
||||||
|
|
||||||
// List contains all valid alerts now
|
// List contains all valid alerts now
|
||||||
|
|
||||||
} catch (TwitterException e) {
|
|
||||||
Toast.makeText(ctx,
|
|
||||||
"Unable to fetch alerts for the University!\nAre you connected to the internet?",
|
|
||||||
duration).show();
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchGamedayAlerts(Context ctx) {
|
private void fetchGamedayAlerts(Context ctx) throws TwitterException {
|
||||||
// Process fetching alerts generated by staff of UNCCGameDay
|
// Process fetching alerts generated by staff of UNCCGameDay
|
||||||
int duration = Toast.LENGTH_SHORT;
|
|
||||||
|
|
||||||
try {
|
|
||||||
String handle = ctx.getString(R.string.gameday_handle);
|
String handle = ctx.getString(R.string.gameday_handle);
|
||||||
Twitter twitter = TwitterFactory.getSingleton();
|
Twitter twitter = TwitterFactory.getSingleton();
|
||||||
List<Status> statuses = twitter.getUserTimeline(handle, new Paging(1, maxTweets));
|
List<Status> statuses = twitter.getUserTimeline(handle, new Paging(1, maxTweets));
|
||||||
@ -107,11 +81,10 @@ public class AlertFetcher {
|
|||||||
|
|
||||||
// List contains all valid alerts now.
|
// List contains all valid alerts now.
|
||||||
|
|
||||||
} catch (TwitterException e) {
|
|
||||||
Toast.makeText(ctx,
|
|
||||||
"Unable to fetch alerts from Gameday!\nAre you connected to the internet?",
|
|
||||||
duration).show();
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Alert> createTimedAlerts(Context ctx) {
|
||||||
|
// Create the timed alerts so we can add or remove them from the DB
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
src/com/uncc/gameday/alerts/AlertService.java
Normal file
18
src/com/uncc/gameday/alerts/AlertService.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package com.uncc.gameday.alerts;
|
||||||
|
|
||||||
|
import android.app.IntentService;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
public class AlertService extends IntentService {
|
||||||
|
private static final String name = "AlertService";
|
||||||
|
|
||||||
|
public AlertService() {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onHandleIntent(Intent intent) {
|
||||||
|
// Go fetch all the alerts!
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user