Search in sources :

Example 6 with LightningView

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);
}
Also used : Bundle(android.os.Bundle) LightningView(acr.browser.lightning.view.LightningView)

Example 7 with LightningView

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);
}
Also used : LightningView(acr.browser.lightning.view.LightningView)

Example 8 with LightningView

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();
}
Also used : LightningView(acr.browser.lightning.view.LightningView)

Example 9 with LightningView

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));
        }
    }
}
Also used : LightningView(acr.browser.lightning.view.LightningView)

Example 10 with LightningView

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);
    }
}
Also used : LightningView(acr.browser.lightning.view.LightningView)

Aggregations

LightningView (acr.browser.lightning.view.LightningView)27 Intent (android.content.Intent)3 DialogInterface (android.content.DialogInterface)2 Bundle (android.os.Bundle)2 IOException (java.io.IOException)2 BookmarkPage (acr.browser.lightning.constant.BookmarkPage)1 DownloadsPage (acr.browser.lightning.constant.DownloadsPage)1 HistoryPage (acr.browser.lightning.constant.HistoryPage)1 StartPage (acr.browser.lightning.constant.StartPage)1 HistoryItem (acr.browser.lightning.database.HistoryItem)1 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)1 BookmarksFragment (acr.browser.lightning.fragment.BookmarksFragment)1 TabsFragment (acr.browser.lightning.fragment.TabsFragment)1 IntentUtils (acr.browser.lightning.utils.IntentUtils)1 Dialog (android.app.Dialog)1 ClipData (android.content.ClipData)1 ClipboardManager (android.content.ClipboardManager)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 Fragment (android.support.v4.app.Fragment)1