limit ui refresh rate
This commit is contained in:
parent
67d5ee6b71
commit
a8ec36cda8
|
@ -21,7 +21,8 @@ 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 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
|
public static final boolean NO_PROXY_LOOKUP = false; //useful to debug ibb
|
||||||
|
|
||||||
|
|
|
@ -144,24 +144,17 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConversationUpdate() {
|
public void onConversationUpdate() {
|
||||||
runOnUiThread(new Runnable() {
|
refreshUi();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
updateView();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMucRosterUpdate() {
|
public void onMucRosterUpdate() {
|
||||||
runOnUiThread(new Runnable() {
|
refreshUi();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
protected void refreshUiReal() {
|
||||||
updateView();
|
updateView();
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -139,26 +139,18 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRosterUpdate() {
|
public void onRosterUpdate() {
|
||||||
runOnUiThread(new Runnable() {
|
refreshUi();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
invalidateOptionsMenu();
|
|
||||||
populateView();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountUpdate() {
|
public void onAccountUpdate() {
|
||||||
runOnUiThread(new Runnable() {
|
refreshUi();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
protected void refreshUiReal() {
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
populateView();
|
populateView();
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1006,56 +1006,39 @@ public class ConversationActivity extends XmppActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountUpdate() {
|
protected void refreshUiReal() {
|
||||||
runOnUiThread(new Runnable() {
|
updateConversationList();
|
||||||
|
if (conversationList.size() == 0) {
|
||||||
|
startActivity(new Intent(getApplicationContext(),
|
||||||
|
StartConversationActivity.class));
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
ConversationActivity.this.mConversationFragment.updateMessages();
|
||||||
|
updateActionBarTitle();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void onAccountUpdate() {
|
||||||
updateConversationList();
|
this.refreshUi();
|
||||||
ConversationActivity.this.mConversationFragment.updateMessages();
|
|
||||||
updateActionBarTitle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConversationUpdate() {
|
public void onConversationUpdate() {
|
||||||
runOnUiThread(new Runnable() {
|
this.refreshUi();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
updateConversationList();
|
|
||||||
if (conversationList.size() == 0) {
|
|
||||||
startActivity(new Intent(getApplicationContext(),
|
|
||||||
StartConversationActivity.class));
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
ConversationActivity.this.mConversationFragment.updateMessages();
|
|
||||||
updateActionBarTitle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRosterUpdate() {
|
public void onRosterUpdate() {
|
||||||
runOnUiThread(new Runnable() {
|
this.refreshUi();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
updateConversationList();
|
|
||||||
ConversationActivity.this.mConversationFragment.updateMessages();
|
|
||||||
updateActionBarTitle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void OnUpdateBlocklist(Status status) {
|
public void OnUpdateBlocklist(Status status) {
|
||||||
|
this.refreshUi();
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
ConversationActivity.this.mConversationFragment.updateMessages();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,18 +32,17 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountUpdate() {
|
public void onAccountUpdate() {
|
||||||
|
refreshUi();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void refreshUiReal() {
|
||||||
synchronized (this.accountList) {
|
synchronized (this.accountList) {
|
||||||
accountList.clear();
|
accountList.clear();
|
||||||
accountList.addAll(xmppConnectionService.getAccounts());
|
accountList.addAll(xmppConnectionService.getAccounts());
|
||||||
}
|
}
|
||||||
runOnUiThread(new Runnable() {
|
invalidateOptionsMenu();
|
||||||
|
mAccountAdapter.notifyDataSetChanged();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
invalidateOptionsMenu();
|
|
||||||
mAccountAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -176,15 +176,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRosterUpdate() {
|
public void onRosterUpdate() {
|
||||||
runOnUiThread(new Runnable() {
|
this.refreshUi();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (mSearchEditText != null) {
|
|
||||||
filter(mSearchEditText.getText().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -711,15 +703,14 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void OnUpdateBlocklist(final Status status) {
|
public void OnUpdateBlocklist(final Status status) {
|
||||||
runOnUiThread(new Runnable() {
|
refreshUi();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
protected void refreshUiReal() {
|
||||||
if (mSearchEditText != null) {
|
if (mSearchEditText != null) {
|
||||||
filter(mSearchEditText.getText().toString());
|
filter(mSearchEditText.getText().toString());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MyListFragment extends ListFragment {
|
public static class MyListFragment extends ListFragment {
|
||||||
|
|
|
@ -436,11 +436,11 @@ public class VerifyOTRActivity extends XmppActivity implements XmppConnectionSer
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onConversationUpdate() {
|
public void onConversationUpdate() {
|
||||||
runOnUiThread(new Runnable() {
|
refreshUi();
|
||||||
@Override
|
}
|
||||||
public void run() {
|
|
||||||
updateView();
|
@Override
|
||||||
}
|
protected void refreshUiReal() {
|
||||||
});
|
updateView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,9 @@ import android.nfc.NfcEvent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
@ -99,6 +101,33 @@ public abstract class XmppActivity extends Activity {
|
||||||
protected int mTheme;
|
protected int mTheme;
|
||||||
protected boolean mUsingEnterKey = false;
|
protected boolean mUsingEnterKey = false;
|
||||||
|
|
||||||
|
private long mLastUiRefresh = 0;
|
||||||
|
private Handler mRefreshUiHandler = new Handler();
|
||||||
|
private Runnable mRefreshUiRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mLastUiRefresh = SystemClock.elapsedRealtime();
|
||||||
|
refreshUiReal();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
protected void refreshUi() {
|
||||||
|
final long diff = SystemClock.elapsedRealtime() - mLastUiRefresh;
|
||||||
|
if (diff > Config.REFRESH_UI_INTERVAL) {
|
||||||
|
mRefreshUiHandler.removeCallbacks(mRefreshUiRunnable);
|
||||||
|
runOnUiThread(mRefreshUiRunnable);
|
||||||
|
} else {
|
||||||
|
final long next = Config.REFRESH_UI_INTERVAL - diff;
|
||||||
|
mRefreshUiHandler.removeCallbacks(mRefreshUiRunnable);
|
||||||
|
mRefreshUiHandler.postDelayed(mRefreshUiRunnable,next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void refreshUiReal() {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
protected interface OnValueEdited {
|
protected interface OnValueEdited {
|
||||||
public void onValueEdited(String value);
|
public void onValueEdited(String value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue