зеркало из https://github.com/mozilla/gecko-dev.git
Bug 969492 - Move LOAD_PROGRESS constants into Tab. r=lucasr
This commit is contained in:
Родитель
8b18eca111
Коммит
a1fa8181df
|
@ -74,6 +74,11 @@ public class Tab {
|
|||
public static final int STATE_SUCCESS = 2;
|
||||
public static final int STATE_ERROR = 3;
|
||||
|
||||
public static final int LOAD_PROGRESS_START = 20;
|
||||
public static final int LOAD_PROGRESS_LOCATION_CHANGE = 60;
|
||||
public static final int LOAD_PROGRESS_LOADED = 80;
|
||||
public static final int LOAD_PROGRESS_STOP = 100;
|
||||
|
||||
private static final int DEFAULT_BACKGROUND_COLOR = Color.WHITE;
|
||||
|
||||
public enum ErrorType {
|
||||
|
@ -628,6 +633,7 @@ public class Tab {
|
|||
setHasTouchListeners(false);
|
||||
setBackgroundColor(DEFAULT_BACKGROUND_COLOR);
|
||||
setErrorType(ErrorType.NONE);
|
||||
setLoadProgress(LOAD_PROGRESS_LOCATION_CHANGE);
|
||||
|
||||
Tabs.getInstance().notifyListeners(this, Tabs.TabEvents.LOCATION_CHANGE, oldUrl);
|
||||
}
|
||||
|
@ -639,6 +645,7 @@ public class Tab {
|
|||
}
|
||||
|
||||
void handleDocumentStart(boolean showProgress, String url) {
|
||||
setLoadProgress(LOAD_PROGRESS_START);
|
||||
setState(showProgress ? STATE_LOADING : STATE_SUCCESS);
|
||||
updateIdentityData(null);
|
||||
setReaderEnabled(false);
|
||||
|
@ -649,6 +656,7 @@ public class Tab {
|
|||
|
||||
final String oldURL = getURL();
|
||||
final Tab tab = this;
|
||||
tab.setLoadProgress(LOAD_PROGRESS_STOP);
|
||||
ThreadUtils.getBackgroundHandler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -659,7 +667,11 @@ public class Tab {
|
|||
ThumbnailHelper.getInstance().getAndProcessThumbnailFor(tab);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
void handleLoaded() {
|
||||
setLoadProgress(LOAD_PROGRESS_LOADED);
|
||||
}
|
||||
|
||||
protected void saveThumbnailToDB() {
|
||||
try {
|
||||
|
|
|
@ -51,11 +51,6 @@ public class Tabs implements GeckoEventListener {
|
|||
private AccountManager mAccountManager;
|
||||
private OnAccountsUpdateListener mAccountListener = null;
|
||||
|
||||
private static final int LOAD_PROGRESS_START = 20;
|
||||
private static final int LOAD_PROGRESS_LOCATION_CHANGE = 60;
|
||||
private static final int LOAD_PROGRESS_LOADED = 80;
|
||||
private static final int LOAD_PROGRESS_STOP = 100;
|
||||
|
||||
public static final int LOADURL_NONE = 0;
|
||||
public static final int LOADURL_NEW_TAB = 1 << 0;
|
||||
public static final int LOADURL_USER_ENTERED = 1 << 1;
|
||||
|
@ -440,7 +435,6 @@ public class Tabs implements GeckoEventListener {
|
|||
} else if (event.equals("Tab:Select")) {
|
||||
selectTab(tab.getId());
|
||||
} else if (event.equals("Content:LocationChange")) {
|
||||
tab.setLoadProgress(LOAD_PROGRESS_LOCATION_CHANGE);
|
||||
tab.handleLocationChange(message);
|
||||
} else if (event.equals("Content:SecurityChange")) {
|
||||
tab.updateIdentityData(message.getJSONObject("identity"));
|
||||
|
@ -454,20 +448,19 @@ public class Tabs implements GeckoEventListener {
|
|||
if ((state & GeckoAppShell.WPL_STATE_START) != 0) {
|
||||
boolean showProgress = message.getBoolean("showProgress");
|
||||
tab.handleDocumentStart(showProgress, message.getString("uri"));
|
||||
tab.setLoadProgress(LOAD_PROGRESS_START);
|
||||
notifyListeners(tab, Tabs.TabEvents.START);
|
||||
} else if ((state & GeckoAppShell.WPL_STATE_STOP) != 0) {
|
||||
tab.handleDocumentStop(message.getBoolean("success"));
|
||||
tab.setLoadProgress(LOAD_PROGRESS_STOP);
|
||||
notifyListeners(tab, Tabs.TabEvents.STOP);
|
||||
}
|
||||
}
|
||||
} else if (event.equals("Content:LoadError")) {
|
||||
tab.setLoadProgress(LOAD_PROGRESS_LOADED);
|
||||
tab.handleLoaded();
|
||||
notifyListeners(tab, Tabs.TabEvents.LOAD_ERROR);
|
||||
} else if (event.equals("Content:PageShow")) {
|
||||
notifyListeners(tab, TabEvents.PAGE_SHOW);
|
||||
} else if (event.equals("DOMContentLoaded")) {
|
||||
tab.handleLoaded();
|
||||
String backgroundColor = message.getString("bgColor");
|
||||
if (backgroundColor != null) {
|
||||
tab.setBackgroundColor(backgroundColor);
|
||||
|
@ -476,7 +469,6 @@ public class Tabs implements GeckoEventListener {
|
|||
tab.setBackgroundColor(Color.WHITE);
|
||||
}
|
||||
tab.setErrorType(message.optString("errorType"));
|
||||
tab.setLoadProgress(LOAD_PROGRESS_LOADED);
|
||||
notifyListeners(tab, Tabs.TabEvents.LOADED);
|
||||
} else if (event.equals("DOMTitleChanged")) {
|
||||
tab.updateTitle(message.getString("title"));
|
||||
|
|
Загрузка…
Ссылка в новой задаче