rely on refreshUi/refreshUiReal and make sure it is being used everywhere

This commit is contained in:
Daniel Gultsch 2015-07-20 15:48:58 +02:00
parent 75a1cfe337
commit 504ef0b72e
14 changed files with 66 additions and 76 deletions

View File

@ -24,7 +24,6 @@ public final class Config {
public static final int PAGE_SIZE = 50; public static final int PAGE_SIZE = 50;
public static final int MAX_NUM_PAGES = 3; public static final int MAX_NUM_PAGES = 3;
public static final int PROGRESS_UI_UPDATE_INTERVAL = 750;
public static final int REFRESH_UI_INTERVAL = 500; public static final int REFRESH_UI_INTERVAL = 500;
public static final boolean NO_PROXY_LOOKUP = false; //useful to debug ibb public static final boolean NO_PROXY_LOOKUP = false; //useful to debug ibb

View File

@ -244,11 +244,8 @@ public class HttpDownloadConnection implements Transferable {
public void updateProgress(int i) { public void updateProgress(int i) {
this.mProgress = i; this.mProgress = i;
if (SystemClock.elapsedRealtime() - this.mLastGuiRefresh > Config.PROGRESS_UI_UPDATE_INTERVAL) {
this.mLastGuiRefresh = SystemClock.elapsedRealtime();
mXmppConnectionService.updateConversationUi(); mXmppConnectionService.updateConversationUi();
} }
}
@Override @Override
public int getStatus() { public int getStatus() {

View File

@ -55,16 +55,10 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
} }
Collections.sort(getListItems()); Collections.sort(getListItems());
} }
runOnUiThread(new Runnable() {
@Override
public void run() {
getListItemAdapter().notifyDataSetChanged(); getListItemAdapter().notifyDataSetChanged();
} }
});
}
@Override protected void refreshUiReal() {
public void OnUpdateBlocklist(final OnUpdateBlocklist.Status status) {
final Editable editable = getSearchEditText().getText(); final Editable editable = getSearchEditText().getText();
if (editable != null) { if (editable != null) {
filterContacts(editable.toString()); filterContacts(editable.toString());
@ -72,4 +66,9 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
filterContacts(); filterContacts();
} }
} }
@Override
public void OnUpdateBlocklist(final OnUpdateBlocklist.Status status) {
refreshUi();
}
} }

View File

@ -103,4 +103,8 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
}); });
} }
public void refreshUiReal() {
}
} }

View File

@ -149,4 +149,8 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
return result.toArray(new String[result.size()]); return result.toArray(new String[result.size()]);
} }
public void refreshUiReal() {
//nothing to do. This Activity doesn't implement any listeners
}
} }

View File

@ -158,6 +158,11 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
refreshUi(); refreshUi();
} }
@Override
public void OnUpdateBlocklist(final Status status) {
refreshUi();
}
@Override @Override
protected void refreshUiReal() { protected void refreshUiReal() {
invalidateOptionsMenu(); invalidateOptionsMenu();
@ -464,16 +469,4 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
populateView(); populateView();
} }
} }
@Override
public void OnUpdateBlocklist(final Status status) {
runOnUiThread(new Runnable() {
@Override
public void run() {
invalidateOptionsMenu();
populateView();
}
});
}
} }

View File

@ -1290,6 +1290,7 @@ public class ConversationActivity extends XmppActivity
ConversationActivity.this.mConversationFragment.updateMessages(); ConversationActivity.this.mConversationFragment.updateMessages();
updateActionBarTitle(); updateActionBarTitle();
} }
invalidateOptionsMenu();
} }
@Override @Override
@ -1310,12 +1311,6 @@ public class ConversationActivity extends XmppActivity
@Override @Override
public void OnUpdateBlocklist(Status status) { public void OnUpdateBlocklist(Status status) {
this.refreshUi(); this.refreshUi();
runOnUiThread(new Runnable() {
@Override
public void run() {
invalidateOptionsMenu();
}
});
} }
public void unblockConversation(final Blockable conversation) { public void unblockConversation(final Blockable conversation) {

View File

@ -151,12 +151,8 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
finish(); finish();
} }
}; };
@Override
public void onAccountUpdate() {
runOnUiThread(new Runnable() {
@Override public void refreshUiReal() {
public void run() {
invalidateOptionsMenu(); invalidateOptionsMenu();
if (mAccount != null if (mAccount != null
&& mAccount.getStatus() != Account.State.ONLINE && mAccount.getStatus() != Account.State.ONLINE
@ -178,7 +174,10 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
updateAccountInformation(false); updateAccountInformation(false);
} }
} }
});
@Override
public void onAccountUpdate() {
refreshUi();
} }
private final UiCallback<Avatar> mAvatarFetchCallback = new UiCallback<Avatar>() { private final UiCallback<Avatar> mAvatarFetchCallback = new UiCallback<Avatar>() {

View File

@ -251,4 +251,8 @@ public class PublishProfilePictureActivity extends XmppActivity {
this.publishButton.setTextColor(getSecondaryTextColor()); this.publishButton.setTextColor(getSecondaryTextColor());
} }
public void refreshUiReal() {
//nothing to do. This Activity doesn't implement any listeners
}
} }

View File

@ -180,4 +180,8 @@ public class SettingsActivity extends XmppActivity implements
} }
} }
public void refreshUiReal() {
//nothing to do. This Activity doesn't implement any listeners
}
} }

View File

@ -228,4 +228,8 @@ public class ShareWithActivity extends XmppActivity {
} }
public void refreshUiReal() {
//nothing to do. This Activity doesn't implement any listeners
}
} }

View File

@ -210,17 +210,11 @@ public class TrustKeysActivity extends XmppActivity implements OnNewKeysAvailabl
@Override @Override
public void onNewKeysAvailable() { public void onNewKeysAvailable() {
runOnUiThread(new Runnable() { final Account account = xmppConnectionService.findAccountByJid(accountJid);
@Override
public void run() {
final Account account = xmppConnectionService
.findAccountByJid(accountJid);
hasPendingFetches = false; hasPendingFetches = false;
getFingerprints(account); getFingerprints(account);
refreshUi(); refreshUi();
} }
});
}
private void commitTrusts() { private void commitTrusts() {
for(IdentityKey identityKey:ownKeysToTrust.keySet()) { for(IdentityKey identityKey:ownKeysToTrust.keySet()) {

View File

@ -125,7 +125,7 @@ public abstract class XmppActivity extends Activity {
protected ConferenceInvite mPendingConferenceInvite = null; protected ConferenceInvite mPendingConferenceInvite = null;
protected void refreshUi() { protected final void refreshUi() {
final long diff = SystemClock.elapsedRealtime() - mLastUiRefresh; final long diff = SystemClock.elapsedRealtime() - mLastUiRefresh;
if (diff > Config.REFRESH_UI_INTERVAL) { if (diff > Config.REFRESH_UI_INTERVAL) {
mRefreshUiHandler.removeCallbacks(mRefreshUiRunnable); mRefreshUiHandler.removeCallbacks(mRefreshUiRunnable);
@ -137,9 +137,7 @@ public abstract class XmppActivity extends Activity {
} }
} }
protected void refreshUiReal() { abstract protected void refreshUiReal();
};
protected interface OnValueEdited { protected interface OnValueEdited {
public void onValueEdited(String value); public void onValueEdited(String value);

View File

@ -60,7 +60,6 @@ public class JingleConnection implements Transferable {
private String contentCreator; private String contentCreator;
private int mProgress = 0; private int mProgress = 0;
private long mLastGuiRefresh = 0;
private boolean receivedCandidate = false; private boolean receivedCandidate = false;
private boolean sentCandidate = false; private boolean sentCandidate = false;
@ -902,11 +901,8 @@ public class JingleConnection implements Transferable {
public void updateProgress(int i) { public void updateProgress(int i) {
this.mProgress = i; this.mProgress = i;
if (SystemClock.elapsedRealtime() - this.mLastGuiRefresh > Config.PROGRESS_UI_UPDATE_INTERVAL) {
this.mLastGuiRefresh = SystemClock.elapsedRealtime();
mXmppConnectionService.updateConversationUi(); mXmppConnectionService.updateConversationUi();
} }
}
interface OnProxyActivated { interface OnProxyActivated {
public void success(); public void success();