Search in sources :

Example 1 with ShareHandler

use of org.wikipedia.page.shareafact.ShareHandler in project apps-android-wikipedia by wikimedia.

the class PageFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);
    if (callback() != null) {
        callback().onPageInitWebView(webView);
    }
    updateFontSize();
    // Explicitly set background color of the WebView (independently of CSS, because
    // the background may be shown momentarily while the WebView loads content,
    // creating a seizure-inducing effect, or at the very least, a migraine with aura).
    webView.setBackgroundColor(getThemedColor(getActivity(), R.attr.paper_color));
    bridge = new CommunicationBridge(webView, "file:///android_asset/index.html");
    setupMessageHandlers();
    sendDecorOffsetMessage();
    if (!app.getCurrentTheme().isDefault()) {
        ThemeBridgeAdapter.setTheme(bridge);
    }
    errorView.setRetryClickListener((v) -> refreshPage());
    errorView.setBackClickListener((v) -> {
        boolean back = onBackPressed();
        // Needed if we're coming from another activity or fragment
        if (!back && callback() != null) {
            // noinspection ConstantConditions
            callback().onPageLoadErrorBackPressed();
        }
    });
    editHandler = new EditHandler(this, bridge);
    pageFragmentLoadState.setEditHandler(editHandler);
    tocHandler = new ToCHandler(this, tocDrawer, bridge);
    // TODO: initialize View references in onCreateView().
    leadImagesHandler = new LeadImagesHandler(this, bridge, webView, getView().findViewById(R.id.page_header_view));
    bottomContentView.setup(this, bridge, webView);
    shareHandler = new ShareHandler(this, bridge);
    tabsProvider = new TabsProvider(this, tabList);
    tabsProvider.setTabsProviderListener(tabsProviderListener);
    if (callback() != null) {
        LongPressHandler.WebViewContextMenuListener contextMenuListener = new PageContainerLongPressHandler(this);
        new LongPressHandler(webView, HistoryEntry.SOURCE_INTERNAL_LINK, contextMenuListener);
    }
    pageFragmentLoadState.setUp(model, this, refreshView, webView, bridge, leadImagesHandler, getCurrentTab().getBackStack());
    if (shouldLoadFromBackstack(getActivity()) || savedInstanceState != null) {
        if (!pageFragmentLoadState.backStackEmpty()) {
            pageFragmentLoadState.loadFromBackStack();
        } else {
            loadMainPageInForegroundTab();
        }
    }
    if (shouldShowTabList(getActivity())) {
        showTabList();
    }
}
Also used : LongPressHandler(org.wikipedia.LongPressHandler) EditHandler(org.wikipedia.edit.EditHandler) ShareHandler(org.wikipedia.page.shareafact.ShareHandler) TabsProvider(org.wikipedia.page.tabs.TabsProvider) LeadImagesHandler(org.wikipedia.page.leadimages.LeadImagesHandler) CommunicationBridge(org.wikipedia.bridge.CommunicationBridge)

Aggregations

LongPressHandler (org.wikipedia.LongPressHandler)1 CommunicationBridge (org.wikipedia.bridge.CommunicationBridge)1 EditHandler (org.wikipedia.edit.EditHandler)1 LeadImagesHandler (org.wikipedia.page.leadimages.LeadImagesHandler)1 ShareHandler (org.wikipedia.page.shareafact.ShareHandler)1 TabsProvider (org.wikipedia.page.tabs.TabsProvider)1