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,10 +244,7 @@ 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) { mXmppConnectionService.updateConversationUi();
this.mLastGuiRefresh = SystemClock.elapsedRealtime();
mXmppConnectionService.updateConversationUi();
}
} }
@Override @Override

View file

@ -55,16 +55,10 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
} }
Collections.sort(getListItems()); Collections.sort(getListItems());
} }
runOnUiThread(new Runnable() { getListItemAdapter().notifyDataSetChanged();
@Override
public void run() {
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,34 +151,33 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
finish(); finish();
} }
}; };
public void refreshUiReal() {
invalidateOptionsMenu();
if (mAccount != null
&& mAccount.getStatus() != Account.State.ONLINE
&& mFetchingAvatar) {
startActivity(new Intent(getApplicationContext(),
ManageAccountActivity.class));
finish();
} else if (jidToEdit == null && mAccount != null
&& mAccount.getStatus() == Account.State.ONLINE) {
if (!mFetchingAvatar) {
mFetchingAvatar = true;
xmppConnectionService.checkForAvatar(mAccount,
mAvatarFetchCallback);
}
} else {
updateSaveButton();
}
if (mAccount != null) {
updateAccountInformation(false);
}
}
@Override @Override
public void onAccountUpdate() { public void onAccountUpdate() {
runOnUiThread(new Runnable() { refreshUi();
@Override
public void run() {
invalidateOptionsMenu();
if (mAccount != null
&& mAccount.getStatus() != Account.State.ONLINE
&& mFetchingAvatar) {
startActivity(new Intent(getApplicationContext(),
ManageAccountActivity.class));
finish();
} else if (jidToEdit == null && mAccount != null
&& mAccount.getStatus() == Account.State.ONLINE) {
if (!mFetchingAvatar) {
mFetchingAvatar = true;
xmppConnectionService.checkForAvatar(mAccount,
mAvatarFetchCallback);
}
} else {
updateSaveButton();
}
if (mAccount != null) {
updateAccountInformation(false);
}
}
});
} }
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,16 +210,10 @@ 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 hasPendingFetches = false;
public void run() { getFingerprints(account);
final Account account = xmppConnectionService refreshUi();
.findAccountByJid(accountJid);
hasPendingFetches = false;
getFingerprints(account);
refreshUi();
}
});
} }
private void commitTrusts() { private void commitTrusts() {

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,10 +901,7 @@ 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) { mXmppConnectionService.updateConversationUi();
this.mLastGuiRefresh = SystemClock.elapsedRealtime();
mXmppConnectionService.updateConversationUi();
}
} }
interface OnProxyActivated { interface OnProxyActivated {