Search in sources :

Example 1 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class PageActivity method loadMainPage.

/**
 * Go directly to the Main Page of the current Wiki, optionally allowing state loss of the
 * fragment manager. Useful for when this function is called from an AsyncTask result.
 */
public void loadMainPage(TabPosition position) {
    PageTitle title = MainPageClient.getMainPageTitle();
    HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_MAIN_PAGE);
    loadPage(title, historyEntry, position);
}
Also used : HistoryEntry(org.wikipedia.history.HistoryEntry)

Example 2 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class PageFragment method handleInternalLink.

private void handleInternalLink(@NonNull PageTitle title) {
    if (!isResumed()) {
        return;
    }
    // in the app very well at this time.
    if (title.isSpecial() || title.isTalkPage()) {
        visitInExternalBrowser(getActivity(), Uri.parse(title.getMobileUri()));
        return;
    }
    dismissBottomSheet();
    if (title.namespace() != Namespace.MAIN || !isLinkPreviewEnabled() || (!DeviceUtil.isOnline() && OfflineManager.instance().titleExists(title.getDisplayText()))) {
        HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_INTERNAL_LINK);
        loadPage(title, historyEntry);
    } else {
        showLinkPreview(title, HistoryEntry.SOURCE_INTERNAL_LINK);
    }
}
Also used : HistoryEntry(org.wikipedia.history.HistoryEntry)

Example 3 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class PageFragment method refreshPage.

public void refreshPage(int stagedScrollY) {
    if (pageFragmentLoadState.isLoading()) {
        refreshView.setRefreshing(false);
        return;
    }
    errorView.setVisibility(View.GONE);
    tabLayout.enableAllTabs();
    errorState = false;
    model.setCurEntry(new HistoryEntry(model.getTitle(), HistoryEntry.SOURCE_HISTORY));
    loadPage(model.getTitle(), model.getCurEntry(), false, stagedScrollY, true);
}
Also used : HistoryEntry(org.wikipedia.history.HistoryEntry)

Example 4 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class PageFragment method addTimeSpentReading.

private void addTimeSpentReading(int timeSpentSec) {
    if (model.getCurEntry() == null) {
        return;
    }
    model.setCurEntry(new HistoryEntry(model.getCurEntry().getTitle(), new Date(), model.getCurEntry().getSource(), timeSpentSec));
    new UpdateHistoryTask(model.getCurEntry(), app).execute();
}
Also used : UpdateHistoryTask(org.wikipedia.history.UpdateHistoryTask) HistoryEntry(org.wikipedia.history.HistoryEntry) Date(java.util.Date)

Example 5 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class BottomContentView method setup.

public void setup(PageFragment parentFragment, CommunicationBridge bridge, ObservableWebView webview) {
    this.parentFragment = parentFragment;
    this.webView = webview;
    this.bridge = bridge;
    setWebView(webview);
    webview.addOnScrollChangeListener(this);
    webview.addOnContentHeightChangedListener(this);
    pageExternalLink.setPaintFlags(pageExternalLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    if (parentFragment.callback() != null) {
        ListViewContextMenuListener contextMenuListener = new LongPressHandler(parentFragment);
        new org.wikipedia.LongPressHandler(readMoreList, HistoryEntry.SOURCE_INTERNAL_LINK, contextMenuListener);
    }
    addOnLayoutChangeListener((View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) -> {
        if (prevLayoutHeight == getHeight()) {
            return;
        }
        prevLayoutHeight = getHeight();
        padWebView();
    });
    readMoreList.setAdapter(readMoreAdapter);
    readMoreList.setOnItemClickListener((AdapterView<?> parent, View view, int position, long id) -> {
        PageTitle title = readMoreAdapter.getItem(position).getPageTitle();
        HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_INTERNAL_LINK);
        parentFragment.loadPage(title, historyEntry);
        funnel.logSuggestionClicked(page.getTitle(), readMoreItems.getResults(), position);
    });
    // hide ourselves by default
    hide();
}
Also used : PageContainerLongPressHandler(org.wikipedia.page.PageContainerLongPressHandler) ListViewContextMenuListener(org.wikipedia.LongPressHandler.ListViewContextMenuListener) PageTitle(org.wikipedia.page.PageTitle) HistoryEntry(org.wikipedia.history.HistoryEntry) AdapterView(android.widget.AdapterView) ConfigurableTextView(org.wikipedia.views.ConfigurableTextView) LinearLayoutOverWebView(org.wikipedia.views.LinearLayoutOverWebView) BindView(butterknife.BindView) GoneIfEmptyTextView(org.wikipedia.views.GoneIfEmptyTextView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) ListView(android.widget.ListView) ObservableWebView(org.wikipedia.views.ObservableWebView)

Aggregations

HistoryEntry (org.wikipedia.history.HistoryEntry)22 PageTitle (org.wikipedia.page.PageTitle)11 WikiSite (org.wikipedia.dataclient.WikiSite)5 Date (java.util.Date)4 Test (org.junit.Test)4 PageBackStackItem (org.wikipedia.page.PageBackStackItem)3 Tab (org.wikipedia.page.tabs.Tab)3 Intent (android.content.Intent)2 Uri (android.net.Uri)2 NonNull (android.support.annotation.NonNull)2 View (android.view.View)2 WebView (android.webkit.WebView)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 OnClick (butterknife.OnClick)2 IOException (java.io.IOException)2 ObservableWebView (org.wikipedia.views.ObservableWebView)2 ProgressDialog (android.app.ProgressDialog)1 Context (android.content.Context)1 AssetManager (android.content.res.AssetManager)1