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,11 +244,8 @@ 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();
}
}
@Override
public int getStatus() {

View File

@ -55,16 +55,10 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
}
Collections.sort(getListItems());
}
runOnUiThread(new Runnable() {
@Override
public void run() {
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,12 +151,8 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
finish();
}
};
@Override
public void onAccountUpdate() {
runOnUiThread(new Runnable() {
@Override
public void run() {
public void refreshUiReal() {
invalidateOptionsMenu();
if (mAccount != null
&& mAccount.getStatus() != Account.State.ONLINE
@ -178,7 +174,10 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
updateAccountInformation(false);
}
}
});
@Override
public void onAccountUpdate() {
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,17 +210,11 @@ public class TrustKeysActivity extends XmppActivity implements OnNewKeysAvailabl
@Override
public void onNewKeysAvailable() {
runOnUiThread(new Runnable() {
@Override
public void run() {
final Account account = xmppConnectionService
.findAccountByJid(accountJid);
final Account account = xmppConnectionService.findAccountByJid(accountJid);
hasPendingFetches = false;
getFingerprints(account);
refreshUi();
}
});
}
private void commitTrusts() {
for(IdentityKey identityKey:ownKeysToTrust.keySet()) {

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,11 +901,8 @@ 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();
}
}
interface OnProxyActivated {
public void success();