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 MAX_NUM_PAGES = 3;
public static final int PROGRESS_UI_UPDATE_INTERVAL = 750;
public static final int REFRESH_UI_INTERVAL = 500;
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) {
this.mProgress = i;
if (SystemClock.elapsedRealtime() - this.mLastGuiRefresh > Config.PROGRESS_UI_UPDATE_INTERVAL) {
this.mLastGuiRefresh = SystemClock.elapsedRealtime();
mXmppConnectionService.updateConversationUi();
}
mXmppConnectionService.updateConversationUi();
}
@Override

View file

@ -55,16 +55,10 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
}
Collections.sort(getListItems());
}
runOnUiThread(new Runnable() {
@Override
public void run() {
getListItemAdapter().notifyDataSetChanged();
}
});
getListItemAdapter().notifyDataSetChanged();
}
@Override
public void OnUpdateBlocklist(final OnUpdateBlocklist.Status status) {
protected void refreshUiReal() {
final Editable editable = getSearchEditText().getText();
if (editable != null) {
filterContacts(editable.toString());
@ -72,4 +66,9 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
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()]);
}
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();
}
@Override
public void OnUpdateBlocklist(final Status status) {
refreshUi();
}
@Override
protected void refreshUiReal() {
invalidateOptionsMenu();
@ -464,16 +469,4 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
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();
updateActionBarTitle();
}
invalidateOptionsMenu();
}
@Override
@ -1310,12 +1311,6 @@ public class ConversationActivity extends XmppActivity
@Override
public void OnUpdateBlocklist(Status status) {
this.refreshUi();
runOnUiThread(new Runnable() {
@Override
public void run() {
invalidateOptionsMenu();
}
});
}
public void unblockConversation(final Blockable conversation) {

View file

@ -151,34 +151,33 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
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
public void onAccountUpdate() {
runOnUiThread(new Runnable() {
@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);
}
}
});
refreshUi();
}
private final UiCallback<Avatar> mAvatarFetchCallback = new UiCallback<Avatar>() {

View file

@ -251,4 +251,8 @@ public class PublishProfilePictureActivity extends XmppActivity {
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
public void onNewKeysAvailable() {
runOnUiThread(new Runnable() {
@Override
public void run() {
final Account account = xmppConnectionService
.findAccountByJid(accountJid);
hasPendingFetches = false;
getFingerprints(account);
refreshUi();
}
});
final Account account = xmppConnectionService.findAccountByJid(accountJid);
hasPendingFetches = false;
getFingerprints(account);
refreshUi();
}
private void commitTrusts() {

View file

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

View file

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