1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-24 02:12:15 -05:00

Regularly trigger a title and folder update while activity is resumed.

This makes sure the relative times are kept up-to-date.
This commit is contained in:
Danny Baumann 2013-02-11 15:41:03 +01:00
parent 0fac8e999d
commit 7afbda9e20
4 changed files with 24 additions and 0 deletions

View File

@ -478,6 +478,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
refresh();
MessagingController.getInstance(getApplication()).addListener(mListener);
StorageManager.getInstance(getApplication()).addListener(storageListener);
mListener.onResume(this);
}
@Override
@ -485,6 +486,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
super.onPause();
MessagingController.getInstance(getApplication()).removeListener(mListener);
StorageManager.getInstance(getApplication()).removeListener(storageListener);
mListener.onPause(this);
}
/**

View File

@ -1,6 +1,9 @@
package com.fsck.k9.activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.text.format.DateUtils;
import com.fsck.k9.Account;
@ -20,6 +23,12 @@ public class ActivityListener extends MessagingListener {
private String mProcessingAccountDescription = null;
private String mProcessingCommandTitle = null;
private BroadcastReceiver mTickReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
informUserOfStatus();
}
};
public String getOperation(Context context) {
String operation;
@ -72,6 +81,14 @@ public class ActivityListener extends MessagingListener {
return operation;
}
public void onResume(Context context) {
context.registerReceiver(mTickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
}
public void onPause(Context context) {
context.unregisterReceiver(mTickReceiver);
}
public void informUserOfStatus() {
}

View File

@ -396,6 +396,7 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
@Override public void onPause() {
super.onPause();
MessagingController.getInstance(getApplication()).removeListener(mAdapter.mListener);
mAdapter.mListener.onPause(this);
}
/**
@ -424,6 +425,7 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
onRefresh(!REFRESH_REMOTE);
MessagingController.getInstance(getApplication()).notifyAccountCancel(this, mAccount);
mAdapter.mListener.onResume(this);
}
@Override
@ -729,6 +731,7 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
@Override
public void informUserOfStatus() {
mHandler.refreshTitle();
mHandler.dataChanged();
}
@Override
public void accountStatusChanged(BaseAccount account, AccountStats stats) {

View File

@ -960,6 +960,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
@Override
public void onPause() {
super.onPause();
mListener.onPause(getActivity());
mController.removeListener(mListener);
}
@ -1000,6 +1001,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
}
}
mListener.onResume(getActivity());
mController.addListener(mListener);
//Cancel pending new mail notifications when we open an account