mirror of
https://github.com/bspeice/UNCCGameDay
synced 2024-11-04 23:28:12 -05:00
Add code for the SharedPreferences in determining which alerts to fetch.
This commit is contained in:
parent
bcfd88faa7
commit
e0f029f387
@ -15,5 +15,6 @@
|
|||||||
<string name="gameday_handle">UNCCGameDay</string>
|
<string name="gameday_handle">UNCCGameDay</string>
|
||||||
<string name="university_handle">unccharlotte</string>
|
<string name="university_handle">unccharlotte</string>
|
||||||
<string name="db_path">Gameday.sqlite</string>
|
<string name="db_path">Gameday.sqlite</string>
|
||||||
|
<string name="preferences_file">GamedayPreferences</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -6,6 +6,7 @@ public class Alert {
|
|||||||
|
|
||||||
private Date alarmDate;
|
private Date alarmDate;
|
||||||
private String message;
|
private String message;
|
||||||
|
private boolean shown;
|
||||||
|
|
||||||
public Date getAlarmDate() {
|
public Date getAlarmDate() {
|
||||||
return alarmDate;
|
return alarmDate;
|
||||||
@ -20,5 +21,11 @@ public class Alert {
|
|||||||
public void setMessage(String message) {
|
public void setMessage(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
public boolean isShown() {
|
||||||
|
return shown;
|
||||||
|
}
|
||||||
|
public void setShown(boolean shown) {
|
||||||
|
this.shown = shown;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,21 +19,11 @@ public class AlertDB {
|
|||||||
public void insertAlert(Alert alert) {
|
public void insertAlert(Alert alert) {
|
||||||
// Add a new date to the database
|
// Add a new date to the database
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertAlertRead(Alert alert) {
|
|
||||||
// Add a new date to the database that should not be alerted.
|
|
||||||
// This way, you can display it in the recent alerts list, but
|
|
||||||
// not show it to the user.
|
|
||||||
}
|
|
||||||
|
|
||||||
public void insertAlerts(List<Alert> alarmDates) {
|
public void insertAlerts(List<Alert> alarmDates) {
|
||||||
// Add multiple new dates to the database
|
// Add multiple new dates to the database
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertAlertsRead(List<Alert> alarmDates) {
|
|
||||||
// Add multiple new dates to the database, and mark them as read.
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Alert> fetchUnreadAlerts() {
|
public List<Alert> fetchUnreadAlerts() {
|
||||||
// Get a list of all currently unread alerts
|
// Get a list of all currently unread alerts
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import twitter4j.Twitter;
|
|||||||
import twitter4j.TwitterException;
|
import twitter4j.TwitterException;
|
||||||
import twitter4j.TwitterFactory;
|
import twitter4j.TwitterFactory;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.uncc.gameday.R;
|
import com.uncc.gameday.R;
|
||||||
@ -19,24 +20,24 @@ public class AlertFetcher {
|
|||||||
private int maxTweets = 5;
|
private int maxTweets = 5;
|
||||||
|
|
||||||
public void fetchAlerts(Context ctx) {
|
public void fetchAlerts(Context ctx) {
|
||||||
/* This method needs to be re-written to use better logic. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Fetch all alerts. Responsible for discovering what sources need to be fetched.
|
// Fetch all alerts. Responsible for discovering what sources need to be fetched.
|
||||||
|
|
||||||
if (((CheckBox)findViewById(R.id.alerts_check_timed)).isChecked())
|
// Note we have to use the SharedPreferences so that we have preferences no matter what activity
|
||||||
|
// sent us this context
|
||||||
|
SharedPreferences settings = ctx.getSharedPreferences(ctx.getString(R.string.preferences_file), 0); // MODE_PRIVATE
|
||||||
|
|
||||||
|
if (settings.getBoolean("ALERT_TIMED", false))
|
||||||
// Fetch timed alerts
|
// Fetch timed alerts
|
||||||
this.fetchTimedAlerts();
|
this.fetchTimedAlerts(ctx);
|
||||||
else if (((CheckBox)findViewById(R.id.alerts_check_organizations)).isChecked())
|
else if (settings.getBoolean("ALERT_ORGANIZATION", false))
|
||||||
// Fetch organization alerts
|
// Fetch organization alerts
|
||||||
this.fetchOrganizationAlerts();
|
this.fetchOrganizationAlerts(ctx);
|
||||||
else if (((CheckBox)findViewById(R.id.alerts_check_university)).isChecked())
|
else if (settings.getBoolean("ALERT_UNIVERSITY", false))
|
||||||
// Fetch university alerts
|
// Fetch university alerts
|
||||||
this.fetchUniversityAlerts();
|
this.fetchUniversityAlerts(ctx);
|
||||||
|
|
||||||
// And always fetch alerts made by us. Period.
|
// And always fetch alerts made by us. Period.
|
||||||
this.fetchGamedayAlerts();
|
this.fetchGamedayAlerts(ctx);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchTimedAlerts(Context ctx) {
|
private void fetchTimedAlerts(Context ctx) {
|
||||||
|
Loading…
Reference in New Issue
Block a user