1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-15 22:15: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(); refresh();
MessagingController.getInstance(getApplication()).addListener(mListener); MessagingController.getInstance(getApplication()).addListener(mListener);
StorageManager.getInstance(getApplication()).addListener(storageListener); StorageManager.getInstance(getApplication()).addListener(storageListener);
mListener.onResume(this);
} }
@Override @Override
@ -485,6 +486,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
super.onPause(); super.onPause();
MessagingController.getInstance(getApplication()).removeListener(mListener); MessagingController.getInstance(getApplication()).removeListener(mListener);
StorageManager.getInstance(getApplication()).removeListener(storageListener); StorageManager.getInstance(getApplication()).removeListener(storageListener);
mListener.onPause(this);
} }
/** /**

View File

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

View File

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

View File

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