use of com.klinker.android.twitter.utils.ActivityUtils in project Talon-for-Twitter by klinker24.
the class ActivityFragment method onRefreshStarted.
@Override
public void onRefreshStarted() {
new AsyncTask<Void, Void, Cursor>() {
private boolean update = false;
@Override
protected void onPreExecute() {
DrawerActivity.canSwitch = false;
}
@Override
protected Cursor doInBackground(Void... params) {
ActivityUtils utils = new ActivityUtils(getActivity());
update = utils.refreshActivity();
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
long now = new Date().getTime();
long alarm = now + DrawerActivity.settings.activityRefresh;
PendingIntent pendingIntent = PendingIntent.getService(context, ACTIVITY_REFRESH_ID, new Intent(context, ActivityRefreshService.class), 0);
if (DrawerActivity.settings.activityRefresh != 0)
am.setRepeating(AlarmManager.RTC_WAKEUP, alarm, DrawerActivity.settings.activityRefresh, pendingIntent);
else
am.cancel(pendingIntent);
if (settings.syncSecondMentions) {
context.startService(new Intent(context, SecondActivityRefreshService.class));
}
return ActivityDataSource.getInstance(context).getCursor(currentAccount);
}
@Override
protected void onPostExecute(Cursor cursor) {
Cursor c = null;
try {
c = cursorAdapter.getCursor();
} catch (Exception e) {
}
cursorAdapter = setAdapter(cursor);
try {
listView.setAdapter(cursorAdapter);
} catch (Exception e) {
}
if (cursor.getCount() == 0) {
spinner.setVisibility(View.VISIBLE);
} else {
spinner.setVisibility(View.GONE);
}
try {
if (update) {
showToastBar(getString(R.string.new_activity), getString(R.string.ok), 400, true, toTopListener);
}
} catch (Exception e) {
// user closed the app before it was done
}
refreshLayout.setRefreshing(false);
DrawerActivity.canSwitch = true;
try {
c.close();
} catch (Exception e) {
}
}
}.execute();
}
use of com.klinker.android.twitter.utils.ActivityUtils in project Talon-for-Twitter by klinker24.
the class ActivityRefreshService method onHandleIntent.
@Override
public void onHandleIntent(Intent intent) {
AppSettings settings = AppSettings.getInstance(this);
ActivityUtils utils = new ActivityUtils(this, false);
if (Utils.getConnectionStatus(this) && !settings.syncMobile) {
return;
}
boolean newActivity = utils.refreshActivity();
if (settings.notifications && settings.activityNot && newActivity) {
utils.postNotification();
}
if (settings.syncSecondMentions) {
Intent second = new Intent(this, SecondActivityRefreshService.class);
startService(second);
}
}
use of com.klinker.android.twitter.utils.ActivityUtils in project Talon-for-Twitter by klinker24.
the class SecondActivityRefreshService method onHandleIntent.
@Override
public void onHandleIntent(Intent intent) {
AppSettings settings = AppSettings.getInstance(this);
ActivityUtils utils = new ActivityUtils(this, true);
if (Utils.getConnectionStatus(this) && !settings.syncMobile) {
return;
}
boolean newActivity = utils.refreshActivity();
if (settings.notifications && settings.activityNot && newActivity) {
utils.postNotification(ActivityUtils.SECOND_NOTIFICATION_ID);
}
}
Aggregations