use of com.klinker.android.twitter.data.ScheduledTweet in project Talon-for-Twitter by klinker24.
the class QueuedDataSource method getScheduledTweets.
public ArrayList<ScheduledTweet> getScheduledTweets(int currentAccount) {
ArrayList<ScheduledTweet> tweets = new ArrayList<ScheduledTweet>();
Cursor cursor = getScheduledCursor(currentAccount);
if (cursor.moveToFirst()) {
do {
String text = cursor.getString(cursor.getColumnIndex(QueuedSQLiteHelper.COLUMN_TEXT));
long time = cursor.getLong(cursor.getColumnIndex(QueuedSQLiteHelper.COLUMN_TIME));
int alarmId = cursor.getInt(cursor.getColumnIndex(QueuedSQLiteHelper.COLUMN_ALARM_ID));
tweets.add(new ScheduledTweet(text, alarmId, time, currentAccount));
} while (cursor.moveToNext());
}
cursor.close();
return tweets;
}
use of com.klinker.android.twitter.data.ScheduledTweet in project Talon-for-Twitter by klinker24.
the class QueuedDataSource method getScheduledTweets.
public ArrayList<ScheduledTweet> getScheduledTweets() {
ArrayList<ScheduledTweet> tweets = new ArrayList<ScheduledTweet>();
Cursor cursor = getAllScheduledCursor();
if (cursor.moveToFirst()) {
do {
String text = cursor.getString(cursor.getColumnIndex(QueuedSQLiteHelper.COLUMN_TEXT));
long time = cursor.getLong(cursor.getColumnIndex(QueuedSQLiteHelper.COLUMN_TIME));
int alarmId = cursor.getInt(cursor.getColumnIndex(QueuedSQLiteHelper.COLUMN_ALARM_ID));
int account = cursor.getInt(cursor.getColumnIndex(QueuedSQLiteHelper.COLUMN_ACCOUNT));
tweets.add(new ScheduledTweet(text, alarmId, time, account));
} while (cursor.moveToNext());
}
cursor.close();
return tweets;
}
use of com.klinker.android.twitter.data.ScheduledTweet in project Talon-for-Twitter by klinker24.
the class BootReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
this.context = context;
AppSettings settings = AppSettings.getInstance(context);
if (settings.timelineRefresh != 0) {
// user only wants manual
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
long now = new Date().getTime();
long alarm = now + settings.timelineRefresh;
Log.v("alarm_date", "timeline " + new Date(alarm).toString());
PendingIntent pendingIntent = PendingIntent.getService(context, HomeFragment.HOME_REFRESH_ID, new Intent(context, TimelineRefreshService.class), 0);
am.setRepeating(AlarmManager.RTC_WAKEUP, alarm, settings.timelineRefresh, pendingIntent);
}
if (settings.mentionsRefresh != 0) {
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
long now = new Date().getTime();
long alarm = now + settings.mentionsRefresh;
Log.v("alarm_date", "mentions " + new Date(alarm).toString());
PendingIntent pendingIntent = PendingIntent.getService(context, MentionsFragment.MENTIONS_REFRESH_ID, new Intent(context, MentionsRefreshService.class), 0);
am.setRepeating(AlarmManager.RTC_WAKEUP, alarm, settings.mentionsRefresh, pendingIntent);
}
if (settings.dmRefresh != 0) {
// user only wants manual
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
long now = new Date().getTime();
long alarm = now + settings.dmRefresh;
Log.v("alarm_date", "dircet message " + new Date(alarm).toString());
PendingIntent pendingIntent = PendingIntent.getService(context, DMFragment.DM_REFRESH_ID, new Intent(context, DirectMessageRefreshService.class), 0);
am.setRepeating(AlarmManager.RTC_WAKEUP, alarm, settings.dmRefresh, pendingIntent);
}
if (settings.activityRefresh != 0) {
// user only wants manual
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
long now = new Date().getTime();
long alarm = now + settings.activityRefresh;
Log.v("alarm_date", "activity " + new Date(alarm).toString());
PendingIntent pendingIntent = PendingIntent.getService(context, ActivityFragment.ACTIVITY_REFRESH_ID, new Intent(context, ActivityRefreshService.class), 0);
am.setRepeating(AlarmManager.RTC_WAKEUP, alarm, settings.activityRefresh, pendingIntent);
}
if (settings.autoTrim) {
// user only wants manual
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
long now = new Date().getTime();
long alarm = now + 1000 * 60;
Log.v("alarm_date", "auto trim " + new Date(alarm).toString());
PendingIntent pendingIntent = PendingIntent.getService(context, TRIM_ID, new Intent(context, TrimDataService.class), 0);
am.set(AlarmManager.RTC_WAKEUP, alarm, pendingIntent);
}
if (settings.pushNotifications) {
context.startService(new Intent(context, CatchupPull.class));
}
ArrayList<ScheduledTweet> tweets = QueuedDataSource.getInstance(context).getScheduledTweets();
for (ScheduledTweet s : tweets) {
Intent serviceIntent = new Intent(context.getApplicationContext(), SendScheduledTweet.class);
Log.v("talon_scheduled_tweets", "in boot text: " + s.text);
serviceIntent.putExtra(ViewScheduledTweets.EXTRA_TEXT, s.text);
serviceIntent.putExtra("account", s.account);
serviceIntent.putExtra("alarm_id", s.alarmId);
PendingIntent pi = getDistinctPendingIntent(serviceIntent, s.alarmId);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, s.time, pi);
}
}
use of com.klinker.android.twitter.data.ScheduledTweet in project Talon-for-Twitter by klinker24.
the class NewScheduledTweet method doneClick.
// this is where we will set everything up when the user has entered all the information
// including the alarm manager and writing the files to the database to save them
public boolean doneClick() {
if (!mEditText.getText().toString().equals("") && timeDone) {
ScheduledTweet tweet = new ScheduledTweet(getApplicationContext(), context, mEditText.getText().toString(), setDate.getTime(), settings.currentAccount);
tweet.createScheduledTweet();
finish();
} else {
Context context = getApplicationContext();
CharSequence text = getString(R.string.complete_form);
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
return true;
}
Aggregations