use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class TabsManager method saveState.
/**
* Saves the state of the current WebViews,
* to a bundle which is then stored in persistent
* storage and can be unparceled.
*/
public void saveState() {
Bundle outState = new Bundle(ClassLoader.getSystemClassLoader());
Log.d(TAG, "Saving tab state");
for (int n = 0; n < mTabList.size(); n++) {
LightningView tab = mTabList.get(n);
if (TextUtils.isEmpty(tab.getUrl())) {
continue;
}
Bundle state = new Bundle(ClassLoader.getSystemClassLoader());
if (tab.getWebView() != null && !UrlUtils.isSpecialUrl(tab.getUrl())) {
tab.getWebView().saveState(state);
outState.putBundle(BUNDLE_KEY + n, state);
} else if (tab.getWebView() != null) {
state.putString(URL_KEY, tab.getUrl());
outState.putBundle(BUNDLE_KEY + n, state);
}
}
FileUtils.writeBundleToStorage(mApp, outState, BUNDLE_STORAGE);
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserPresenter method tabChanged.
/**
* Notifies the presenter that we wish
* to switch to a different tab at the
* specified position. If the position
* is not in the model, this method will
* do nothing.
*
* @param position the position of the
* tab to switch to.
*/
public synchronized void tabChanged(int position) {
Log.d(TAG, "tabChanged: " + position);
if (position < 0 || position >= mTabsModel.size()) {
return;
}
LightningView tab = mTabsModel.switchToTab(position);
onTabChanged(tab);
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class TabsManager method removeTab.
/**
* Removes a tab from the list and destroys the tab.
* If the tab removed is the current tab, the reference
* to the current tab will be nullified.
*
* @param position The position of the tab to remove.
*/
private synchronized void removeTab(final int position) {
if (position >= mTabList.size()) {
return;
}
final LightningView tab = mTabList.remove(position);
if (mCurrentTab == tab) {
mCurrentTab = null;
}
tab.onDestroy();
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method onBackButtonPressed.
@Override
public void onBackButtonPressed() {
final LightningView currentTab = mTabsManager.getCurrentTab();
if (currentTab != null) {
if (currentTab.canGoBack()) {
currentTab.goBack();
closeDrawers(null);
} else {
mPresenter.deleteTab(mTabsManager.positionOf(currentTab));
}
}
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method onHomeButtonPressed.
@Override
public void onHomeButtonPressed() {
final LightningView currentTab = mTabsManager.getCurrentTab();
if (currentTab != null) {
currentTab.loadHomepage();
closeDrawers(null);
}
}
Aggregations